Beispiel #1
0
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