def getRecentPosts(blog_id, username, password, numberOfPosts): """docstring for getRecentPosts""" print '---\nrunning metaWeblog.getRecentPosts' if blog_id == 'Static': return [page_to_struct(page) for page in Page.get_all(numberOfPosts)] else: return [page_to_struct(page) for page in Post.get_all(numberOfPosts)]
def static_page(slug): """docstring for static_page""" page = Page.get_by_slug(slug) if page: response = make_response(render_template('page.html', page=page)) response.headers['Last-Modified'] = page.updated_at.strftime('%a, %d %b %Y %H:%M:%S GMT') return response else: return render_template('404.html'), 404
def newPost(blog_id, username, password, struct, publish): """docstring for newPost""" print '---\nrunning metaWeblog.newPost' if blog_id == 'Static': page = Page(title=struct['title'], content=struct['description'], draft=not publish) page.slug = struct['link'] else: page = Post(title=struct['title'], content=struct['description'], draft=not publish) if 'categories' in struct: page.categories = [Category.get_by_name(cat) for cat in struct['categories']] else: page.categories = [] try: page.save() except IntegrityError: raise Fault("DBase Error", "Title not unique") else: return page.slug