예제 #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()
예제 #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')
예제 #3
0
 def data_getEntries(self, ctx, data):
     num = ctx.arg('num', '60')
     return IBlog(IStore(ctx)).getPosts(int(num))
예제 #4
0
 def locateChild(self, ctx, segments):
     return IStore(ctx).transact(rend.Page.locateChild, self, ctx, segments)
예제 #5
0
 def renderHTTP(self, ctx):
     return IStore(ctx).transact(rend.Page.renderHTTP, self, ctx)
예제 #6
0
 def data_get_posts(self, ctx, data):
     return IBlog(IStore(ctx)).getPosts(15)
예제 #7
0
 def data_getFirstPost(self, ctx, data):
     for post in IBlog(IStore(ctx)).getPosts(1):
         return post
예제 #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()