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


Python Session.add方法代碼示例

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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