Permalink
Browse files

allow [:2] slicing

  • Loading branch information...
1 parent 4d5fa93 commit 850593519d7989ee2c25176d7efc08e69a8085a9 @HonzaKral HonzaKral committed May 9, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 ella/core/managers.py
View
@@ -154,11 +154,15 @@ def __init__(self, category, children=NONE, content_types=[], date_range=(), exc
self.exclude = exclude
def __getitem__(self, k):
- if not isinstance(k, slice) or (k.start is None or k.start < 0) or (k.stop is None or k.stop < k.start):
+ if not isinstance(k, slice) or k.step:
raise TypeError, '%s, %s' % (k.start, k.stop)
- offset = k.start
- count = k.stop - k.start
+ offset = k.start or 0
+
+ if offset < 0 or k.stop is None or k.stop < offset:
+ raise TypeError, '%s, %s' % (k.start, k.stop)
+
+ count = k.stop - offset
return self.get_listings(offset, count)

0 comments on commit 8505935

Please sign in to comment.