Skip to content

Commit

Permalink
Rename option to no_default, only available for alphabetical batch.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Feb 21, 2012
1 parent 7c5ad42 commit 64fca23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/zeam/utils/batch/alphabetical/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class AlphabeticalBatch(ActiveBatch):
def __init__(
self, collection,
start=None, count=None, name='', request=None, factory=None,
letters=string.uppercase, default_all=False):
letters=string.uppercase, no_default=False):
assert len(letters), 'need a list of letters to iterate through'
if request is not None:
key = 'bstart'
if name:
key += '_' + name
if key in request.form:
start = request.form[key]
if start is None and not default_all:
if start is None and not no_default:
start = letters[0]
super(AlphabeticalBatch, self).__init__(
collection,
Expand All @@ -45,19 +45,21 @@ def last(self):
@property
def previous(self):
try:
index = self.letters.index(self.start)
if index:
return self.letters[index - 1]
if self.start:
index = self.letters.index(self.start)
if index:
return self.letters[index - 1]
except ValueError:
pass
return None

@property
def next(self):
try:
index = self.letters.index(self.start)
if index < len(self.letters) - 1:
return self.letters[index + 1]
if self.start:
index = self.letters.index(self.start)
if index < len(self.letters) - 1:
return self.letters[index + 1]
except ValueError:
pass
return None
5 changes: 2 additions & 3 deletions src/zeam/utils/batch/date/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class DateBatch(ActiveBatch):

def __init__(
self, collection,
start=None, count=BATCH_MONTH, name='', request=None, factory=None,
default_all=False):
start=None, count=BATCH_MONTH, name='', request=None, factory=None):
if request is not None:
key = 'bstart'
if name:
Expand All @@ -26,7 +25,7 @@ def __init__(
start = datetime.strptime(request.form[key], '%Y-%m')
except (ValueError, TypeError):
pass
if start is None and not default_all:
if start is None:
start = datetime.now()
super(DateBatch, self).__init__(
collection,
Expand Down

0 comments on commit 64fca23

Please sign in to comment.