예제 #1
0
파일: Author.py 프로젝트: TomDunn/flog
    def create(cls, email, passwd, first_name, last_name, sync=True, session=None):
        author = cls()

        author.email  = email
        author.set_passwd(passwd)

        author.first_name = first_name
        author.last_name  = last_name

        author.created  = now()
        author.modified = now()

        if sync:
            add_and_refresh(session, author)

        return author
예제 #2
0
파일: Post.py 프로젝트: TomDunn/flog
    def create(cls, author, title=None, body=None, sync=False, session=None):
        post = cls()
        #post.author_id = author.id

        time = now()
        post.created  = time
        post.modified = time

        if body is None:
            post.body = '<p>no content yet</p>'

        if title is None:
            post.set_title("Post created at %s" % str(time))

        if sync is True and session is not None:
            add_and_refresh(session, post)

        return post