Changeset 966:79609d716c2c
- Timestamp:
- 01/11/09 01:24:16 (3 years ago)
- Branch:
- default
- Parents:
- 965:788f7d6bbbdc (diff), 961:3a38045dbdaf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 4 edited
-
README (modified) (1 diff)
-
zine/__init__.py (modified) (1 diff)
-
zine/models.py (modified) (1 diff)
-
zine/models.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
README
r965 r966 3 3 =================================== 4 4 5 This is Zine 0.1.3, the third bugfix version of the first stable 6 release of Zine. 5 This is Zine 0.2 the second release of Zine. 7 6 It already provides quite a few features: 8 7 -
zine/__init__.py
r965 r966 25 25 :license: BSD, see LICENSE for more details. 26 26 """ 27 __version__ = '0. 1.3-dev'27 __version__ = '0.2-dev' 28 28 __url__ = 'http://zine.pocoo.org/' 29 29 -
zine/models.py
r955 r966 568 568 if prefix: 569 569 prefix += '/' 570 full_slug = u'%s%04d/% 02d/%02d/%s' % (570 full_slug = u'%s%04d/%d/%d/%s' % ( 571 571 prefix, 572 572 self.pub_date.year, -
zine/models.py
r962 r966 9 9 :license: BSD, see LICENSE for more details. 10 10 """ 11 from math import ceil,log11 from math import log 12 12 from datetime import date, datetime, timedelta 13 13 from urlparse import urljoin … … 274 274 """Add some extra methods to the post model.""" 275 275 276 def lightweight(self, deferred=None, lazy= ('comments',)):276 def lightweight(self, deferred=None, lazy=None): 277 277 """Send a lightweight query which deferes some more expensive 278 278 things such as comment queries or even text and parser data. 279 279 """ 280 args = map(db.lazyload, lazy or ()) 280 if lazy is None: 281 lazy = ('comments',) 282 args = map(db.lazyload, lazy) 283 undefer_comment_count = 'comments' in lazy 281 284 if deferred: 285 deferred = set(deferred) 286 if 'comment_count' in deferred: 287 undefer_comment_count = False 288 deferred.remove('comment_count') 282 289 args.extend(map(db.defer, deferred)) 283 290 # undefer the _comment_count query which is used by comment_count 284 291 # for lightweight post objects. See Post.comment_count for more 285 292 # details. 286 if lazy and 'comments' in lazy:293 if undefer_comment_count: 287 294 args.append(db.undefer('_comment_count')) 288 295 return self.options(*args) 296 297 def theme_lightweight(self, key): 298 """A query for lightweight settings based on the theme. For example 299 to use the lightweight settings for the author overview page you can 300 use this query:: 301 302 Post.query.theme_lightweight('author_overview') 303 """ 304 theme_settings = get_application().theme.settings 305 deferred = theme_settings.get('sql.%s.deferred' % key) 306 lazy = theme_settings.get('sql.%s.lazy' % key) 307 return self.lightweight(deferred, lazy) 289 308 290 309 def type(self, content_type): … … 769 788 return self.filter(Comment.status == COMMENT_MODERATED) 770 789 771 def blocked(self): 772 """Filter all blocked comments. Blocked comments are all comments but 773 unmoderated and moderated comments. 790 def all_blocked(self): 791 """Return all blocked comments, by user, by spam checker or by system. 774 792 """ 775 793 return self.filter(Comment.status.in_([COMMENT_BLOCKED_USER, 776 794 COMMENT_BLOCKED_SPAM, 777 795 COMMENT_BLOCKED_SYSTEM])) 796 797 def blocked(self): 798 """Filter all comments blocked by user(s) 799 """ 800 return self.filter(Comment.status == COMMENT_BLOCKED_USER) 801 778 802 def unmoderated(self): 779 803 """Filter all the unmoderated comments and comments blocked by a user 780 804 or system. 781 805 """ 782 return self.filter(Comment.status.in_([COMMENT_UNMODERATED, 783 COMMENT_BLOCKED_USER, 784 COMMENT_BLOCKED_SYSTEM])) 806 return self.filter(Comment.status == COMMENT_UNMODERATED) 785 807 786 808 def spam(self): 787 809 """Filter all the spam comments.""" 788 810 return self.filter(Comment.status == COMMENT_BLOCKED_SPAM) 811 812 def system(self): 813 """Filter all the spam comments.""" 814 return self.filter(Comment.status == COMMENT_BLOCKED_SYSTEM) 789 815 790 816 def latest(self, limit=None, ignore_privileges=False, ignore_blocked=True): … … 1040 1066 'posts': db.dynamic_loader(Post, 1041 1067 backref=db.backref('author', lazy=False), 1068 query_class=PostQuery, 1042 1069 cascade='all, delete, delete-orphan'), 1043 1070 'comments': db.dynamic_loader(Comment, … … 1052 1079 'id': groups.c.group_id, 1053 1080 'users': db.dynamic_loader(User, backref=db.backref('groups', lazy=True), 1081 query_class=UserQuery, 1054 1082 secondary=group_users), 1055 1083 '_privileges': db.relation(_Privilege, lazy=True, … … 1063 1091 db.mapper(Category, categories, properties={ 1064 1092 'id': categories.c.category_id, 1065 'posts': db.dynamic_loader(Post, secondary=post_categories) 1093 'posts': db.dynamic_loader(Post, secondary=post_categories, 1094 query_class=PostQuery) 1066 1095 }, order_by=categories.c.name) 1067 1096 db.mapper(Comment, comments, properties={ … … 1084 1113 db.mapper(Tag, tags, properties={ 1085 1114 'id': tags.c.tag_id, 1086 'posts': db.dynamic_loader(Post, secondary=post_tags) 1115 'posts': db.dynamic_loader(Post, secondary=post_tags, 1116 query_class=PostQuery) 1087 1117 }, order_by=tags.c.name) 1088 1118 db.mapper(Post, posts, properties={
Note: See TracChangeset
for help on using the changeset viewer.