本文整理汇总了Python中calypso.model.meta.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Python Session.query方法的具体用法?Python Session.query怎么用?Python Session.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calypso.model.meta.Session
的用法示例。
在下文中一共展示了Session.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_is_admin
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def verify_is_admin(self):
try:
user = sqlsession.query(User).filter_by(userid=self.userid,password=self.password).one()
return sqlsession.query(UserRoleMapping).filter_by(userid=self.userid,roleid=Role.ADMIN.id).count()>0
except:
print "No such user"
return False
示例2: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self,name,password):
self.password=password
self.userid = name
try:
self.lastname=sqlsession.query(User).filter_by(userid=self.userid).one().lastname
self.firstname=sqlsession.query(User).filter_by(userid=self.userid).one().firstname
except:
self.lastname=self.userid
self.firstname=''
示例3: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self, user, name, parentname, displayname, type):
daos = sqlsession.query(TileModel.DAO).filter_by(user=user, display=displayname, parent=parentname, name=name).all()
if len(daos)>0:
self.dao=daos[0]
self.dao.type=type
else:
self.dao = TileModel.DAO(name=name, user=user, parentname=parentname, displayname=displayname, type=type)
monitors=sqlsession.query(MonitorView.DAO).filter_by \
(display=displayname, parent=name).order_by(MonitorView.DAO.index).all()
self.monitors=[]
for mon in monitors:
try:
self.monitors.append(MonitorView(name=mon.name, user=user, parentname=self.get_name(), displayname=displayname))
except:
del mon
示例4: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self, user, name, displayname):
daos= sqlsession.query(TelemetryWindowModel.DAO).filter_by(user=user,display=displayname, name=name).all()
if len(daos)>0:
self.dao = daos[0]
else:
self.dao = TelemetryWindowModel.DAO(user=user,name=name, displayname=displayname)
index=0
示例5: get_properties
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def get_properties(user, parent, display):
daos= sqlsession.query(DisplayPropertyItem.DAO).filter_by( user=user, display=display.get_name(), parent=parent.get_name()).all()
params={}
for dao in daos:
tag=dao.name
if tag != "name":
params[tag]=dao.value
return DisplayProperties(name=parent, user=user, parent=parent, display=display, **params)
示例6: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self, user, name, format):
daos = sqlsession.query(DisplayModel.DAO).filter_by(user=user, name=name).all()
if len(daos) > 0:
self.dao = daos[0]
else:
if format == None:
self.dao = DisplayModel.DAO(name=name, format=Format.DEFAULT_FORMAT.get_name(), user=user)
else:
self.dao = DisplayModel.DAO(name=name, format=format, user=user)
示例7: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self, name, user, owner, displayname, value, type):
self.name=name
self.owner=owner
daos= sqlsession.query(DisplayPropertyItem.DAO).filter_by(name=name, user=user, display=displayname, parent=owner.get_name()).all()
if len(daos)>0:
self.dao =daos[0]
self.dao.type=type
else:
if (name=='col_span' or name=='row_span') and value==None:
value=1
elif value==None:
value=0
self.dao=DisplayPropertyItem.DAO(name=name, user=user, ownername=owner.get_name(), displayname=displayname, value=value, type=type)
示例8: copy_to
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [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()
示例9: get_models
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def get_models(display, user):
daos= sqlsession.query(TelemetryWindowModel.DAO).filter_by(user=user, display=display.get_name()).all()
models=[]
for dao in daos:
models.append(TelemetryWindowModel(user=user, name=dao.name, displayname=display.get_name()))
return models
示例10: verify
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def verify(self):
return sqlsession.query(User).filter_by(userid=self.userid,password=self.password).count()>0
示例11: get_models
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def get_models(user, displayname, parentname):
daos= sqlsession.query(TileModel.DAO).filter_by(user = user, display=displayname, parent=parentname).all()
models=[]
for dao in daos:
models.append(TileModel(name=dao.name, user=user, displayname=displayname, parentname=parentname, type=dao.type))
return models
示例12: Column
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [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)
示例13: __init__
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def __init__(self, project_name, contract_id, project_type):
daos=sqlsession.query(Project.DAO).filter_by(project_name=project_name).all()
if (len(daos)>0):
self.dao=daos[0]
else:
self.dao=Project.DAO(project_name, contract_id, project_type=project_type)
示例14: query_workbooks
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def query_workbooks():
daos=sqlsession.query(Workbook.DAO).all()
workbooks={}
for dao in daos:
workbooks[dao.project_name + "." + dao.workbook_name] = Workbook(dao.project_name, dao.workbook_name)
return workbooks
示例15: query_projects
# 需要导入模块: from calypso.model.meta import Session [as 别名]
# 或者: from calypso.model.meta.Session import query [as 别名]
def query_projects():
daos=sqlsession.query(Project.DAO).all()
projects={}
for dao in daos:
projects[dao.project_name] = Project(dao.project_name, dao.contract_id, dao.project_type)
return projects