コード例 #1
0
    def _POST(self, *param, **params):

        if not validates_user(self):
            return web.badrequest(self.view.alert)

        engine = get_engine()
        metadata = get_metadata()
        session = get_session()

        try:
            metadata.drop_all()   
            metadata.tables['machine2jobgroup'].create()
            metadata.create_all()   
        except Exception, e:
            traceback.format_exc()
            raise Exception('Initializing/Updating a database error - %s' % ''.join(e.args))
コード例 #2
0
#print opts
#sys.exit()

engine = get_engine()
metadata = get_metadata()

try:
    metadata.drop_all()   
    metadata.tables['machine2jobgroup'].create()
    metadata.create_all()   
except Exception, e:
    traceback.format_exc()
    raise Exception('Initializing/Updating a database error - %s' % ''.join(e.args))

session = get_session()
try:
    (password, salt) = sha1encrypt(u"%s" % password)
    user = session.query(User).filter(User.email == email).first()

    if user is None:
        # User Table set.
        new_user  = User(u"%s" % email,
                              unicode(password),
                              unicode(salt),
                              u"Administrator",
                              u"%s" % lang,
                              )

        if string.atof(sqlalchemy.__version__[0:3]) >= 0.6:
            session.add(new_user)