当前位置: 首页>>代码示例>>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;未经允许,请勿转载。