本文整理汇总了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()
示例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
示例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
示例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
示例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
示例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