Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of Search_Pagination


Ignore:
Timestamp:
03/22/06 06:10:14 (13 years ago)
Author:
fredlin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Search_Pagination

    v1 v2  
    8080}}} 
    8181 
    82 Yes it works correctly. Let's put it in real template(kid) 
     82Yes it works correctly.  
     83 
     84We can read each entry from generator by using "for" loop.  
     85 
     86To get subsets of the context generator type, we use list-like function to draw target sets. "context[start:end]"  
     87 
     88ex: for the first 10 records: 
    8389 
    8490{{{ 
    85 <div> 
     91context[0:10] 
     92}}} 
     93 
     94and for the next 10: 
     95 
     96{{{ 
     97context[10:20] 
     98}}} 
     99 
     100and so on.  
     101 
     102Let's put those python expressions into real kid template 
     103 
     104{{{ 
    86105<?python 
    87106    query_size = context.count()+1 
    88107    end = start*10 +offset 
    89108?> 
     109<ul> 
     110  <li py:for="post in context[start:end]">[${post.fieldA}] ${post.fieldB}: ${post.fieldC}</li> 
     111</ul> 
     112 
     113<div> 
    90114 | <span py:for = " i in xrange((query_size/offset)+1)"> <a href="/?start=${i}">${i+1}</a> | </span> 
    91115</div> 
    92116}}} 
    93117 
    94  
     118kid template's "py:for" is equal to python "for" loop. 
    95119"query_size" is equal to "context.count()", which "context.count()" will return total queried entry numbers.  
    96120 
    97121and we get "offset" param from "index" method's return dict. 
     122 
    98123 
    99124"|" is used only for pretty.