Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
CMFPlone.PloneBatch.Batch Class Reference

List of all members.

Public Member Functions

def __init__
def pageurl
def navurls
def prevurls
def nexturls

Public Attributes

 start
 end
 orphan
 overlap
 first
 length
 b_start_str
 last
 previous
 pagenumber
 pagerangeend
 navlist
 prevlist
 nextlist
 quantumleap
 leapback
 leapforward

Static Public Attributes

tuple previous = LazyPrevBatch()
tuple next = LazyNextBatch()
tuple sequence_length = LazySequenceLength()
 size = firststartendorphanoverlapnavlistNone
 numpages = pagenumberpagerangepagerangeendpagerangestartpagenumberquantumleapNone

Private Attributes

 _sequence
 _size

Static Private Attributes

int __allow_access_to_unprotected_subobjects__ = 1

Detailed Description

Create a sequence batch

Definition at line 28 of file PloneBatch.py.


Constructor & Destructor Documentation

def CMFPlone.PloneBatch.Batch.__init__ (   self,
  sequence,
  size,
  start = 0,
  end = 0,
  orphan = 0,
  overlap = 0,
  pagerange = 7,
  quantumleap = 0,
  b_start_str = 'b_start' 
)
Encapsulate sequence in batches of size
sequence    - the data to batch.
size        - the number of items in each batch. This will be computed if left out.
start       - the first element of sequence to include in batch (0-index)
end         - the last element of sequence to include in batch (0-index, optional)
orphan      - the next page will be combined with the current page if it does not contain more than orphan elements
overlap     - the number of overlapping elements in each batch
pagerange   - the number of pages to display in the navigation
quantumleap - 0 or 1 to indicate if bigger increments should be used in the navigation list for big results.
b_start_str - the request variable used for start, default 'b_start'

Definition at line 39 of file PloneBatch.py.

00039 
00040     def __init__( self, sequence, size, start=0, end=0, orphan=0, overlap=0, pagerange=7, quantumleap=0, b_start_str='b_start'):
00041         """ Encapsulate sequence in batches of size
00042         sequence    - the data to batch.
00043         size        - the number of items in each batch. This will be computed if left out.
00044         start       - the first element of sequence to include in batch (0-index)
00045         end         - the last element of sequence to include in batch (0-index, optional)
00046         orphan      - the next page will be combined with the current page if it does not contain more than orphan elements
00047         overlap     - the number of overlapping elements in each batch
00048         pagerange   - the number of pages to display in the navigation
00049         quantumleap - 0 or 1 to indicate if bigger increments should be used in the navigation list for big results.
00050         b_start_str - the request variable used for start, default 'b_start'
00051         """
00052         start = start + 1
00053 
00054         start,end,sz = opt(start,end,size,orphan,sequence)
00055 
00056         self._sequence = sequence
00057         self.size = sz
00058         self._size = size
00059         self.start = start
00060         self.end = end
00061         self.orphan = orphan
00062         self.overlap = overlap
00063         self.first = max(start - 1, 0)
00064         self.length = self.end - self.first
00065 
00066         self.b_start_str = b_start_str
00067 
00068         self.last = self.sequence_length - size
00069 
00070         # Set up next and previous
00071         if self.first == 0:
00072             self.previous = None
00073 
00074         # Set up the total number of pages
00075         self.numpages = calculate_pagenumber(self.sequence_length - self.orphan, self.size, self.overlap)
00076 
00077         # Set up the current page number
00078         self.pagenumber = calculate_pagenumber(self.start, self.size, self.overlap)
00079 
00080         # Set up pagerange for the navigation quick links
00081         self.pagerange, self.pagerangestart, self.pagerangeend = calculate_pagerange(self.pagenumber,self.numpages,pagerange)
00082 
00083         # Set up the lists for the navigation: 4 5 [6] 7 8
00084         #  navlist is the complete list, including pagenumber
00085         #  prevlist is the 4 5 in the example above
00086         #  nextlist is 7 8 in the example above
00087         self.navlist = self.prevlist = self.nextlist = []
00088         if self.pagerange and self.numpages >= 1:
00089             self.navlist  = range(self.pagerangestart, self.pagerangeend)
00090             self.prevlist = range(self.pagerangestart, self.pagenumber)
00091             self.nextlist = range(self.pagenumber + 1, self.pagerangeend)
00092 
00093         # QuantumLeap - faster navigation for big result sets
00094         self.quantumleap = quantumleap
00095         self.leapback = self.leapforward = []
00096         if self.quantumleap:
00097             self.leapback = calculate_leapback(self.pagenumber, self.numpages, self.pagerange)
00098             self.leapforward = calculate_leapforward(self.pagenumber, self.numpages, self.pagerange)

Here is the call graph for this function:


Member Function Documentation

def CMFPlone.PloneBatch.Batch.navurls (   self,
  formvariables,
  navlist = [] 
)
Returns the page number and url for the navigation quick links 

Definition at line 106 of file PloneBatch.py.

00106 
00107     def navurls(self, formvariables, navlist=[]):
00108         """ Returns the page number and url for the navigation quick links """
00109         if not navlist: navlist = self.navlist
00110         return map(lambda x, formvariables = formvariables: (x, self.pageurl(formvariables, x)), navlist)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneBatch.Batch.nexturls (   self,
  formvariables 
)
Helper method to get next navigation list from templates 

Definition at line 115 of file PloneBatch.py.

00115 
00116     def nexturls(self, formvariables):
00117         """ Helper method to get next navigation list from templates """
00118         return self.navurls(formvariables, self.nextlist)
00119 
00120 # Calculate start, end, batchsize
00121 # This is copied from ZTUtils.Batch.py because orphans were not correct there.
00122 # 04/16/04 modified by Danny Bloemendaal (_ender_). Removed try/except structs because
# in some situations they cause some unexpected problems. Also fixed some problems with the orphan stuff. Seems to work now.

Here is the call graph for this function:

def CMFPlone.PloneBatch.Batch.pageurl (   self,
  formvariables,
  pagenumber = -1 
)
Makes the url for a given page 

Definition at line 99 of file PloneBatch.py.

00099 
00100     def pageurl(self, formvariables, pagenumber=-1):
00101         """ Makes the url for a given page """
00102         if pagenumber == -1:
00103             pagenumber = self.pagenumber
00104         b_start = pagenumber * (self.size - self.overlap) - self.size
00105         return make_query(formvariables, {self.b_start_str:b_start})

Here is the caller graph for this function:

def CMFPlone.PloneBatch.Batch.prevurls (   self,
  formvariables 
)
Helper method to get prev navigation list from templates 

Definition at line 111 of file PloneBatch.py.

00111 
00112     def prevurls(self, formvariables):
00113         """ Helper method to get prev navigation list from templates """
00114         return self.navurls(formvariables, self.prevlist)

Here is the call graph for this function:


Member Data Documentation

Definition at line 30 of file PloneBatch.py.

Definition at line 55 of file PloneBatch.py.

Definition at line 57 of file PloneBatch.py.

Definition at line 65 of file PloneBatch.py.

Definition at line 59 of file PloneBatch.py.

Definition at line 62 of file PloneBatch.py.

Definition at line 67 of file PloneBatch.py.

Definition at line 94 of file PloneBatch.py.

Definition at line 94 of file PloneBatch.py.

Definition at line 63 of file PloneBatch.py.

Definition at line 86 of file PloneBatch.py.

Definition at line 33 of file PloneBatch.py.

Definition at line 86 of file PloneBatch.py.

CMFPlone.PloneBatch.Batch.numpages = pagenumberpagerangepagerangeendpagerangestartpagenumberquantumleapNone [static]

Definition at line 37 of file PloneBatch.py.

Definition at line 60 of file PloneBatch.py.

Definition at line 61 of file PloneBatch.py.

Definition at line 77 of file PloneBatch.py.

Definition at line 80 of file PloneBatch.py.

Definition at line 32 of file PloneBatch.py.

Definition at line 71 of file PloneBatch.py.

Definition at line 86 of file PloneBatch.py.

Definition at line 93 of file PloneBatch.py.

Definition at line 34 of file PloneBatch.py.

CMFPlone.PloneBatch.Batch.size = firststartendorphanoverlapnavlistNone [static]

Definition at line 36 of file PloneBatch.py.

Definition at line 58 of file PloneBatch.py.


The documentation for this class was generated from the following file: