Back to index

plone3  3.1.7
Classes | Functions
CMFPlone.PloneBatch Namespace Reference

Classes

class  LazyPrevBatch
class  LazyNextBatch
class  LazySequenceLength
class  Batch

Functions

def opt
def calculate_pagenumber
def calculate_pagerange
def calculate_quantum_leap_gap
def calculate_leapback
def calculate_leapforward

Function Documentation

def CMFPlone.PloneBatch.calculate_leapback (   pagenumber,
  numpages,
  pagerange 
)
Check the distance between start and 0 and add links as necessary 

Definition at line 177 of file PloneBatch.py.

00177 
00178 def calculate_leapback(pagenumber, numpages, pagerange):
00179     """ Check the distance between start and 0 and add links as necessary """
00180     leapback = []
00181     quantum_leap_gap = calculate_quantum_leap_gap(numpages, pagerange)
00182     num_back_leaps = max(0,min(3, int(round(float(pagenumber - pagerange)/quantum_leap_gap) - 0.3)))
00183     if num_back_leaps:
00184         pagerange, pagerangestart, pagerangeend = calculate_pagerange( pagenumber, numpages, pagerange)
00185         leapback = range(pagerangestart - num_back_leaps * quantum_leap_gap, pagerangestart, quantum_leap_gap)
00186     return leapback

Here is the call graph for this function:

def CMFPlone.PloneBatch.calculate_leapforward (   pagenumber,
  numpages,
  pagerange 
)
Check the distance between end and length and add links as necessary 

Definition at line 187 of file PloneBatch.py.

00187 
00188 def calculate_leapforward(pagenumber, numpages, pagerange):
00189     """ Check the distance between end and length and add links as necessary """
00190     leapforward = []
00191     quantum_leap_gap = calculate_quantum_leap_gap(numpages, pagerange)
00192     num_forward_leaps = max(0,min(3, int(round(float(numpages - pagenumber - pagerange)/quantum_leap_gap) - 0.3)))
00193     if num_forward_leaps:
00194         pagerange, pagerangestart, pagerangeend = calculate_pagerange( pagenumber, numpages, pagerange)
00195         leapforward = range(pagerangeend-1 + quantum_leap_gap, pagerangeend-1 + (num_forward_leaps+1) * quantum_leap_gap, quantum_leap_gap)
00196     return leapforward

Here is the call graph for this function:

def CMFPlone.PloneBatch.calculate_pagenumber (   elementnumber,
  batchsize,
  overlap = 0 
)
Calculate the pagenumber for the navigation 

Definition at line 150 of file PloneBatch.py.

00150 
00151 def calculate_pagenumber(elementnumber, batchsize, overlap=0):
00152     """ Calculate the pagenumber for the navigation """
00153     # To find first element in a page,
00154     # elementnumber = pagenumber * (size - overlap) - size (- orphan?)
00155     try:
00156         pagenumber,remainder = divmod(elementnumber, batchsize - overlap)
00157     except ZeroDivisionError:
00158         pagenumber, remainder = divmod(elementnumber, 1)
00159     if remainder > overlap:
00160         pagenumber = pagenumber + 1
00161     pagenumber = max(pagenumber, 1)
00162     return pagenumber

def CMFPlone.PloneBatch.calculate_pagerange (   pagenumber,
  numpages,
  pagerange 
)
Calculate the pagerange for the navigation quicklinks 

Definition at line 163 of file PloneBatch.py.

00163 
00164 def calculate_pagerange(pagenumber, numpages, pagerange):
00165     """ Calculate the pagerange for the navigation quicklinks """
00166     # Pagerange is the number of pages linked to in the navigation, odd number
00167     pagerange = max(0 , pagerange + pagerange % 2 - 1)
00168     # Making sure the list will not start with negative values
00169     pagerangestart = max ( 1, pagenumber - (pagerange - 1 ) / 2 )
00170     # Making sure the list does not expand beyond the last page
00171     pagerangeend = min ( pagenumber + (pagerange - 1 ) / 2, numpages) + 1
00172     return pagerange, pagerangestart, pagerangeend

Here is the caller graph for this function:

def CMFPlone.PloneBatch.calculate_quantum_leap_gap (   numpages,
  pagerange 
)
Find the QuantumLeap gap. Current width of list is 6 clicks (30/5) 

Definition at line 173 of file PloneBatch.py.

00173 
00174 def calculate_quantum_leap_gap(numpages, pagerange):
00175     """ Find the QuantumLeap gap. Current width of list is 6 clicks (30/5) """
00176     return int(max(1,round(float(numpages - pagerange)/30))*5)

Here is the caller graph for this function:

def CMFPlone.PloneBatch.opt (   start,
  end,
  size,
  orphan,
  sequence 
)

Definition at line 123 of file PloneBatch.py.

00123 
00124 def opt(start,end,size,orphan,sequence):
00125     length = len(sequence)
00126     if size < 1:
00127         if start > 0 and end > 0 and end >= start:
00128             size = end + 1 - start
00129         else: size = 25
00130     if start > 0: 
00131         if start>length: 
00132             start = length
00133         if end > 0:
00134             if end < start: end = start
00135         else:
00136             end = start + size - 1
00137             if (end+orphan)>=length:
00138                 end = length
00139     elif end > 0:
00140         if (end)>length:
00141             end = length
00142         start = end + 1 - size
00143         if start - 1 < orphan: start = 1
00144     else:
00145         start = 1
00146         end = start + size - 1
00147         if (end+orphan)>=length:
00148             end = length
00149     return start,end,size

Here is the caller graph for this function: