當前位置: 首頁>>代碼示例>>Python>>正文


Python Session.query方法代碼示例

本文整理匯總了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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:9,代碼來源:__init__.py

示例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=''
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:11,代碼來源:__init__.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:17,代碼來源:tiles.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:9,代碼來源:windows.py

示例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)
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:10,代碼來源:properties.py

示例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)
開發者ID:nak,項目名稱:Team-Works,代碼行數:11,代碼來源:Visualization.py

示例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)
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:15,代碼來源:properties.py

示例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()
開發者ID:nak,項目名稱:Team-Works,代碼行數:19,代碼來源:Visualization.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:8,代碼來源:windows.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:4,代碼來源:__init__.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:8,代碼來源:tiles.py

示例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)

開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:30,代碼來源:__init__.py

示例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)
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:8,代碼來源:Main.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:8,代碼來源:Main.py

示例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
開發者ID:lonefeifei,項目名稱:Team-Works,代碼行數:8,代碼來源:Main.py


注:本文中的calypso.model.meta.Session.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。