当前位置: 首页>>代码示例>>Python>>正文


Python Session.add方法代码示例

本文整理汇总了Python中privacyidea.model.meta.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在privacyidea.model.meta.Session的用法示例。


在下文中一共展示了Session.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
 def __init__(self, machineuser_id, key, value):
     log.debug("setting %r to %r for MachineUser %s" % (key,
                                                        value,
                                                        machineuser_id))
     self.machineuser_id = machineuser_id
     self.mu_key = key
     self.mu_value = value
     Session.add(self)
     Session.commit()
开发者ID:cyclefusion,项目名称:privacyidea,代码行数:11,代码来源:__init__.py

示例2: save

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
    def save(self):
        '''
        enforce the saveing of a challenge
        - will guarentee the uniqness of the transaction id

        :return: transaction id of the stored challeng
        '''
        try:
            Session.add(self)
            Session.commit()
            log.debug('save challenge : success')

        except Exception as exce:
            log.error('Error during saving challenge: %r' % exce)
            log.error("%s" % traceback.format_exc())

        return self.transid
开发者ID:cyclefusion,项目名称:privacyidea,代码行数:19,代码来源:__init__.py

示例3: set_config

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
def set_config(key, value, typ, description=None):
    '''
    create an intial config entry, if it does not exist

    :param key: the key
    :param value: the value
    :param description: the description of the key

    :return: nothing
    '''

    count = Session.query(model.Config).filter(
                        model.Config.Key == "privacyidea." + key).count()

    if count == 0:
        config_entry = model.Config(key, value, Type=typ, Description=description)
        Session.add(config_entry)

    return
开发者ID:asifiqbal,项目名称:privacyidea,代码行数:21,代码来源:base.py

示例4: _storeConfigDB

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
def _storeConfigDB(key, val, typ=None, desc=None):
    value = val

    if (not key.startswith("privacyidea.")):
        key = "privacyidea." + key

    confEntries = Session.query(Config).filter(Config.Key == unicode(key))
    theConf = None

    if typ is not None and typ == 'password':
        value = encryptPassword(val)
        en = decryptPassword(value)
        if (en != val):
            raise Exception("StoreConfig: Error during encoding password type!")

    ## update
    if confEntries.count() == 1:
        theConf = confEntries[0]
        theConf.Value = unicode(value)
        if (typ is not None):
            theConf.Type = unicode(typ)
        if (desc is not None):
            theConf.Description = unicode(desc)

    ## insert
    elif confEntries.count() == 0:
        theConf = Config(
                        Key=unicode(key),
                        Value=unicode(value),
                        Type=unicode(typ),
                        Description=unicode(desc)
                        )
    if theConf is not None:
        Session.add(theConf)

    return 101
开发者ID:cyclefusion,项目名称:privacyidea,代码行数:38,代码来源:config.py

示例5: store

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
 def store(self):
     Session.add(self)
     Session.commit()
     return True
开发者ID:cyclefusion,项目名称:privacyidea,代码行数:6,代码来源:__init__.py

示例6: storeToken

# 需要导入模块: from privacyidea.model.meta import Session [as 别名]
# 或者: from privacyidea.model.meta.Session import add [as 别名]
 def storeToken(self):
     Session.add(self)
     Session.flush()
     Session.commit()
     return True
开发者ID:cyclefusion,项目名称:privacyidea,代码行数:7,代码来源:__init__.py


注:本文中的privacyidea.model.meta.Session.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。