Example #1
0
 def childFactory(self, ctx, segment):
     id = segment.isdigit() and segment or '-1'
     if int(id) >= 0:
         return IBlog(IStore(ctx)).getOne(int(id))
     elif segment == 'rpc2':
         return BlogRPC(IStore(ctx))
     elif segment == 'atom.xml':
         return Atom()
Example #2
0
 def insert(self, ctx, id, title, author, category, content):
     newPost = Post(store=IStore(ctx),
                    id=int(id),
                    author=unicode(author),
                    title=unicode(title),
                    category=unicode(category),
                    content=unicode(content))
     IBlog(IStore(ctx)).addNewPost(newPost)
     inevow.IRequest(ctx).setComponent(iformless.IRedirectAfterPost, '/thx')
Example #3
0
 def data_getEntries(self, ctx, data):
     num = ctx.arg('num', '60')
     return IBlog(IStore(ctx)).getPosts(int(num))
Example #4
0
 def locateChild(self, ctx, segments):
     return IStore(ctx).transact(rend.Page.locateChild, self, ctx, segments)
Example #5
0
 def renderHTTP(self, ctx):
     return IStore(ctx).transact(rend.Page.renderHTTP, self, ctx)
Example #6
0
 def data_get_posts(self, ctx, data):
     return IBlog(IStore(ctx)).getPosts(15)
Example #7
0
 def data_getFirstPost(self, ctx, data):
     for post in IBlog(IStore(ctx)).getPosts(1):
         return post
Example #8
0
 def render_forms(self, ctx, data):
     d = iformless.IFormDefaults(ctx).getAllDefaults('insert')
     d['author'] = 'Anonymous'
     d['id'] = IBlog(IStore(ctx)).getNextId()
     return webform.renderForms()