Seite 1 von 1

tal-Große Datenmengen aufteilen

Verfasst: Freitag 4. Juli 2008, 15:41
von draci
Hallo Forum!

Ich habe folgendes Problem:
Ich möchte aus einem B2Tree-Ordner alle Objekte mit tal:repeat auflisten.
Mit Python ist die Verarbeitung kein Problem, aber natürlich genauso wie in TAL die Ausgabe.

Gibt es eine Möglichkeit möglichst einfach die Menge der Objekte, die ausgegeben werden zu begrenzen und automatisch weiter,zurück bzw. Sprunglinks (z.B. gehe zu 200-300)
(Wie hier im Forum mit den Seiten) zu generieren ?

draci

Re: tal-Große Datenmengen aufteilen

Verfasst: Freitag 4. Juli 2008, 17:29
von gerold
Hallo draci!

Dafür ist ``ZTUtils.Batch`` zuständig.

Das ist eine Seite, die mit dem "Z Search Interface" erstellt wurde. Die wichtigen Dinge musst du dir selber raus holen. Da habe ich jetzt keine Geduld dafür.

Code: Alles auswählen

<html>
  <body tal:define="results  here/addresses_search_sql;
                    start request/start|python:0;
                    batch python:modules['ZTUtils'].Batch(results,
                                                          size=20,
                                                          start=start);
                    previous python:batch.previous;
                    next python:batch.next">

  <p>
    <a tal:condition="previous"
       tal:attributes="href string:${request/URL0}?start:int=${previous/first}"
       href="previous_url">previous <span tal:replace="previous/length">20</span> results</a>
    <a tal:condition="next"
       tal:attributes="href string:${request/URL0}?start:int=${next/first}"
       href="next_url">next <span tal:replace="next/length">20</span> results</a>
  </p>

  <table border>
        <tr>
          <th>VORNAME</th>
          <th>NACHNAME</th>
        </tr>
       
  <tal:x repeat="result batch" >
  
         <tr>
          <td><span tal:replace="result/VORNAME">VORNAME goes here</span></td>
          <td><span tal:replace="result/NACHNAME">NACHNAME goes here</span></td>
        </tr>

  </tal:x>

      </table>
  <p>
    <a tal:condition="previous"
       tal:attributes="href string:${request/URL0}?start:int=${previous/first}"
       href="previous_url">previous <span tal:replace="previous/length">20</span> results</a>
    <a tal:condition="next"
       tal:attributes="href string:${request/URL0}?start:int=${next/first}"
       href="next_url">next <span tal:replace="next/length">20</span> results</a>
  </p>

  </body>
</html>
mfg
Gerold
:-)

Verfasst: Freitag 4. Juli 2008, 18:29
von draci
Cool werd's mir mal ansehen
Danke :D

PS: Schön kurz :mrgreen:

Verfasst: Montag 7. Juli 2008, 19:58
von draci
Hier noch mal Aufgeschlüsselt :D

Code: Alles auswählen

<html>
  <body tal:define="results  ABFRAGE (z.B. here/objectValues);
                    start request/start|python:0;
                    batch python:modules['ZTUtils'].Batch(results,
                                                          size="Menge der Elemente pro Seite",
                                                          start=start);
                    previous python:batch.previous;
                    next python:batch.next">

  <p>
    <a tal:condition="previous"
       tal:attributes="href string:${request/URL0}?start:int=${previous/first}"
       href="previous_url">"Text vor der Zahl"<span tal:replace="previous/length">"Menge der Elemente pro Seite"</span>"Test nach der Zahl"</a>
    <a tal:condition="next"
       tal:attributes="href string:${request/URL0}?start:int=${next/first}"
       href="next_url">"Text vor der Zahl"<span tal:replace="next/length">"Menge der Elemente pro Seite"</span>"Test nach der Zahl"</a>
  </p>

  <table border>
        <tr>
          <th>VORNAME</th>
          <th>NACHNAME</th>
        </tr>
       
  <tal:x repeat="result batch" >
 
         <tr>
          <td><span tal:replace="result/VORNAME">VORNAME goes here</span></td>
          <td><span tal:replace="result/NACHNAME">NACHNAME goes here</span></td>
        </tr>

  </tal:x>

      </table>
  <p>
    <a tal:condition="previous"
       tal:attributes="href string:${request/URL0}?start:int=${previous/first}"
       href="previous_url">"Text vor der Zahl"<span tal:replace="previous/length">"Menge der Elemente pro Seite"</span>"Test nach der Zahl"</a>
    <a tal:condition="next"
       tal:attributes="href string:${request/URL0}?start:int=${next/first}"
       href="next_url">"Text vor der Zahl"<span tal:replace="next/length">"Menge der Elemente pro Seite"</span>"Test nach der Zahl"</a>
  </p>

  </body>
</html>