Ejemplo n.º 1
0
def init_db(uri):
    engine = create_engine(uri, convert_unicode=True)
    db_session = scoped_session(
        sessionmaker(autocommit=False, autoflush=False, bind=engine))
    Base = declarative_base()
    Base.query = db_session.query_property()
    Package, InstallMethod = register_models(Base)
    Base.metadata.create_all(bind=engine)
    return db_session, Package, InstallMethod
Ejemplo n.º 2
0
 def create_all(self):
     models.register_models(self.engine)
Ejemplo n.º 3
0
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2010-2011 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Not Yet PEP8 standardized


from models import register_models
from session import get_session, get_engine

session = get_session()
engine = get_engine()
register_models(session, engine)
Ejemplo n.º 4
0
class Index(BlogHandler):
    def get(self):
        #new_post = self.database.blog.i18n.BlogPost()
        #new_post['title'] = 'test'
        #print new_post.save()
        #self.write("Hello, world")
        print self.database.BlogPost.find()
        self.render("index.html", title="My title", posts=self.database.BlogPost.find())

class AdminIndex(BlogHandler):
    def get(self):
        self.render("admin/index.html",
            title="My title",
            posts=self.database.BlogPost.find()
        )

if __name__ == "__main__":
    from mongokit import *
    conn = Connection()
    models.register_models(conn) 
    new_post = conn.blog.BlogPost()
    print new_post
    new_post.title= u'sss'
    new_post.author = u'Me'
    #new_post.save()
    cur = conn.blog.BlogPost.find()
    for p in cur:
        print p
    #new_post.save()
Ejemplo n.º 5
0
import models
models.register_models()