本文整理汇总了Python中calypso.model.meta.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calypso.model.meta.Session
的用法示例。
在下文中一共展示了Session.add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self, user, name, parentname, displayname, type):
self.type = type
self.user = user
self.display=displayname
self.parent=parentname
self.name=name
sqlsession.add(self)
sqlsession.commit()
示例2: get_name
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def get_name(self):
try:
return self.dao.name
except:
sqlsession.commit()
sqlsession.add(self.dao)
sqlsession.commit()
return self.dao.name
示例3: set_value
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def set_value( self, value ):
self.dao.set_value(str(value))
try:
sqlsession.add(self.dao)
except:
pass
sqlsession.commit()
print "SET VALUE OF " +self.dao.parent +" TO " + self.dao.name + " TO " + self.dao.value
示例4: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self,id,name):
self.id = id
self.name = name
try:
if (sqlsession.query(Role).filter_by(id=self.id).count() == 0):
sqlsession.add(self)
except:
sqlsession.add(self)
示例5: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self, name, user, ownername, displayname, value, type):
self.name=name
self.user=user
self.parent=ownername
self.display=displayname
self.type=type
if value==None:
self.value='0'
else:
self.value=value
sqlsession.add(self)
sqlsession.commit()
示例6: copy_to
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def copy_to(self, newname):
olddisplay = self
oldname = self.dao.name
if newname == oldname:
return
daos = sqlsession.query(DisplayModel.DAO).filter_by(user=self.dao.user, name=newname).all()
if len(daos) > 0:
raise Exception("Name already exists")
sqlsession.commit()
format = self.dao.format
user = self.dao.user
self.dao = None
self.dao = DisplayModel(user=user, name=newname, format=format).dao
sqlsession.add(self.dao)
sqlsession.commit()
if oldname == "unnamed":
olddisplay.delete()
示例7: __call__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __call__(self):
"""
Treat this class like a function to be called with no parameters
It will return the value of the property item it holds
"""
try:
sqlsession.add(self.dao)
except:
pass
try:
if self.name=='x_pos' or self.name=='y_pos' or \
self.name=='col_span' or self.name=='row_span':
return int(self.dao.value)
else:
return self.dao.value
except:
import traceback
traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
return ''
示例8: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self, name, format, user):
self.name = name
self.format = format
self.user = user
sqlsession.add(self)
sqlsession.commit()
示例9: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self, project_name, contract_id, project_type):
self.project_name = project_name
self.contract_id = contract_id
self.project_type = project_type
sqlsession.add(self)
sqlsession.commit()
示例10: set_parent
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def set_parent(self, parentname):
self.dao.parent=parentname
sqlsession.add(self.dao)
sqlsession.commit()
示例11: create
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def create(self, admin):
if admin.verify_has_admin():
sqlsession.add(self)
示例12: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def __init__(self, user, name, displayname):
self.name = name
self.user = user
self.display=displayname
sqlsession.add(self)
sqlsession.commit()
示例13: set_name
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
def set_name(self, name):
self.dao.name = name
sqlsession.add(self.dao)
sqlsession.commit()
示例14: Column
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import add [as 别名]
UserRoleMapping.table=sqlalchemy.Table('userroles',metadata,
Column('id',Integer,primary_key=True),
Column('userid',String(80), nullable=False),
Column('roleid',Integer, nullable=False),
useexisting=True)
"""map tables to database"""
sqlalchemy.orm.mapper(User, User.table)
sqlalchemy.orm.mapper(Role, Role.table)
sqlalchemy.orm.mapper(UserRoleMapping, UserRoleMapping.table)
"""Setup user and user roles for basic admin"""
import hashlib
try:
User.ROOT = sqlsession.query(User).filter_by(userid="admin").one()
User.ROOT.password=hashlib.md5("admin").hexdigest()
sqlsession.commit()
except:
User.ROOT= User("admin", hashlib.md5("admin").hexdigest())
sqlsession.add(User.ROOT)
sqlsession.commit()
Role.ADMIN = Role(1,"admin")
Role.DEVELOPER = Role(2,"developer")
Role.PRODCUT_MANAGER=Role(3,"product_manager")
UserRoleMapping.ROOT = UserRoleMapping(User.ROOT,Role.ADMIN)