Show More
@@ -109,16 +109,9 b" page's items by their index number pleas" | |||||
109 | """ |
|
109 | """ | |
110 |
|
110 | |||
111 | import re |
|
111 | import re | |
112 | import sys |
|
|||
113 | from string import Template |
|
112 | from string import Template | |
114 | from webhelpers2.html import literal |
|
113 | from webhelpers2.html import literal | |
115 |
|
114 | |||
116 | # are we running at least python 3.x ? |
|
|||
117 | PY3 = sys.version_info[0] >= 3 |
|
|||
118 |
|
||||
119 | if PY3: |
|
|||
120 | unicode = str |
|
|||
121 |
|
||||
122 |
|
115 | |||
123 | def make_html_tag(tag, text=None, **params): |
|
116 | def make_html_tag(tag, text=None, **params): | |
124 | """Create an HTML tag string. |
|
117 | """Create an HTML tag string. | |
@@ -907,9 +900,12 b' class SqlalchemyOrmWrapper(object):' | |||||
907 | self.pager = pager |
|
900 | self.pager = pager | |
908 | self.collection = collection |
|
901 | self.collection = collection | |
909 |
|
902 | |||
910 |
def __getitem__(self, |
|
903 | def __getitem__(self, key): | |
|
904 | if not isinstance(key, slice): | |||
|
905 | raise ValueError('Pagination without a slice not supported') | |||
|
906 | ||||
911 | # Return a range of objects of an sqlalchemy.orm.query.Query object |
|
907 | # Return a range of objects of an sqlalchemy.orm.query.Query object | |
912 |
return self.collection[ |
|
908 | return self.collection[key] | |
913 |
|
909 | |||
914 | def __len__(self): |
|
910 | def __len__(self): | |
915 | # support empty types, without actually making a query. |
|
911 | # support empty types, without actually making a query. | |
@@ -1033,7 +1029,7 b' class RepoCommitsWrapper(object):' | |||||
1033 | self.pager = pager |
|
1029 | self.pager = pager | |
1034 | self.collection = collection |
|
1030 | self.collection = collection | |
1035 |
|
1031 | |||
1036 |
def __getitem__(self, |
|
1032 | def __getitem__(self, key): | |
1037 | cur_page = self.pager.page |
|
1033 | cur_page = self.pager.page | |
1038 | items_per_page = self.pager.items_per_page |
|
1034 | items_per_page = self.pager.items_per_page | |
1039 | first_item = max(0, (len(self.collection) - (cur_page * items_per_page))) |
|
1035 | first_item = max(0, (len(self.collection) - (cur_page * items_per_page))) |
General Comments 0
You need to be logged in to leave comments.
Login now