Zine

open source content publishing system


Changeset 966:79609d716c2c


Ignore:
Timestamp:
01/11/09 01:24:16 (3 years ago)
Author:
mitsuhiko
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.
Message:

Automated merge with  file:///Users/mitsuhiko/Development/zine-0.1

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • README

    r965 r966  
    33=================================== 
    44 
    5 This is Zine 0.1.3, the third bugfix version of the first stable 
    6 release of Zine. 
     5This is Zine 0.2 the second release of Zine. 
    76It already provides quite a few features: 
    87 
  • zine/__init__.py

    r965 r966  
    2525    :license: BSD, see LICENSE for more details. 
    2626""" 
    27 __version__ = '0.1.3-dev' 
     27__version__ = '0.2-dev' 
    2828__url__ = 'http://zine.pocoo.org/' 
    2929 
  • zine/models.py

    r955 r966  
    568568        if prefix: 
    569569            prefix += '/' 
    570         full_slug = u'%s%04d/%02d/%02d/%s' % ( 
     570        full_slug = u'%s%04d/%d/%d/%s' % ( 
    571571            prefix, 
    572572            self.pub_date.year, 
  • zine/models.py

    r962 r966  
    99    :license: BSD, see LICENSE for more details. 
    1010""" 
    11 from math import ceil, log 
     11from math import log 
    1212from datetime import date, datetime, timedelta 
    1313from urlparse import urljoin 
     
    274274    """Add some extra methods to the post model.""" 
    275275 
    276     def lightweight(self, deferred=None, lazy=('comments',)): 
     276    def lightweight(self, deferred=None, lazy=None): 
    277277        """Send a lightweight query which deferes some more expensive 
    278278        things such as comment queries or even text and parser data. 
    279279        """ 
    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 
    281284        if deferred: 
     285            deferred = set(deferred) 
     286            if 'comment_count' in deferred: 
     287                undefer_comment_count = False 
     288                deferred.remove('comment_count') 
    282289            args.extend(map(db.defer, deferred)) 
    283290        # undefer the _comment_count query which is used by comment_count 
    284291        # for lightweight post objects.  See Post.comment_count for more 
    285292        # details. 
    286         if lazy and 'comments' in lazy: 
     293        if undefer_comment_count: 
    287294            args.append(db.undefer('_comment_count')) 
    288295        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) 
    289308 
    290309    def type(self, content_type): 
     
    769788        return self.filter(Comment.status == COMMENT_MODERATED) 
    770789 
    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. 
    774792        """ 
    775793        return self.filter(Comment.status.in_([COMMENT_BLOCKED_USER, 
    776794                                               COMMENT_BLOCKED_SPAM, 
    777795                                               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 
    778802    def unmoderated(self): 
    779803        """Filter all the unmoderated comments and comments blocked by a user 
    780804        or system. 
    781805        """ 
    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) 
    785807 
    786808    def spam(self): 
    787809        """Filter all the spam comments.""" 
    788810        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) 
    789815 
    790816    def latest(self, limit=None, ignore_privileges=False, ignore_blocked=True): 
     
    10401066    'posts':            db.dynamic_loader(Post, 
    10411067                                          backref=db.backref('author', lazy=False), 
     1068                                          query_class=PostQuery, 
    10421069                                          cascade='all, delete, delete-orphan'), 
    10431070    'comments':         db.dynamic_loader(Comment, 
     
    10521079    'id':               groups.c.group_id, 
    10531080    'users':            db.dynamic_loader(User, backref=db.backref('groups', lazy=True), 
     1081                                          query_class=UserQuery, 
    10541082                                          secondary=group_users), 
    10551083    '_privileges':      db.relation(_Privilege, lazy=True, 
     
    10631091db.mapper(Category, categories, properties={ 
    10641092    '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) 
    10661095}, order_by=categories.c.name) 
    10671096db.mapper(Comment, comments, properties={ 
     
    10841113db.mapper(Tag, tags, properties={ 
    10851114    '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) 
    10871117}, order_by=tags.c.name) 
    10881118db.mapper(Post, posts, properties={ 
Note: See TracChangeset for help on using the changeset viewer.