summaryrefslogtreecommitdiff
path: root/repoze/bfg/sampleapp/models.py
blob: 7da6f1033a2db5629d9ad5e241deb5b6006a46ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from zope.interface import Interface
from zope.interface import implements
from zope.location.interfaces import ILocation
from zope.location.location import Location

from repoze.bfg.security import Everyone
from repoze.bfg.security import Allow

import datetime

class IMapping(Interface):
    pass

class IBlog(Interface):
    pass

class Blog(dict, Location):
    __acl__ = [
        (Allow, Everyone, 'view'),
        (Allow, 'group:editors', 'add'),
        (Allow, 'group:editors', 'edit'),
        ]
    implements(IBlog, IMapping, ILocation)

class IBlogEntry(Interface):
    pass

class BlogEntry(object):
    implements(IBlogEntry)
    def __init__(self, title, body, author):
        self.title = title
        self.body =  body
        self.author = author
        self.created = datetime.datetime.now()

blog = Blog()
blog['sample'] = BlogEntry('Sample Blog Entry',
                           '<p>This is a sample blog entry</p>',
                           'chrism')
def get_root(environ):
    return blog