本文整理汇总了Python中Products.ZenModel.ZenModelRM.ZenModelRM.zmanage_editProperties方法的典型用法代码示例。如果您正苦于以下问题:Python ZenModelRM.zmanage_editProperties方法的具体用法?Python ZenModelRM.zmanage_editProperties怎么用?Python ZenModelRM.zmanage_editProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.ZenModel.ZenModelRM.ZenModelRM
的用法示例。
在下文中一共展示了ZenModelRM.zmanage_editProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zmanage_editProperties
# 需要导入模块: from Products.ZenModel.ZenModelRM import ZenModelRM [as 别名]
# 或者: from Products.ZenModel.ZenModelRM.ZenModelRM import zmanage_editProperties [as 别名]
def zmanage_editProperties(self, REQUEST, redirect=False):
"""
Edit a ZenPack object
"""
if self.isEggPack():
# Handle the dependencies fields and recreate self.dependencies
newDeps = {}
depNames = REQUEST.get('dependencies', [])
if not isinstance(depNames, list):
depNames = [depNames]
newDeps = {}
for depName in depNames:
fieldName = 'version_%s' % depName
vers = REQUEST.get(fieldName, '').strip()
if vers and vers[0] in string.digits:
vers = '==' + vers
try:
req = pkg_resources.Requirement.parse(depName + vers)
except ValueError:
messaging.IMessageSender(self).sendToBrowser(
'Error',
'%s is not a valid version specification.' % vers,
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
zp = self.dmd.ZenPackManager.packs._getOb(depName, None)
if not zp:
messaging.IMessageSender(self).sendToBrowser(
'Error',
'%s is not installed.' % depName,
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
if not req.__contains__(zp.version):
messaging.IMessageSender(self).sendToBrowser(
'Error',
('The required version for %s (%s) ' % (depName, vers) +
'does not match the installed version (%s).' %
zp.version),
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
newDeps[depName] = vers
REQUEST.form[fieldName] = vers
self.dependencies = newDeps
# Check the value of compatZenossVers and the dependencies to
# make sure that they match installed versions
compatZenossVers = REQUEST.form['compatZenossVers'] or ''
if compatZenossVers:
if compatZenossVers[0] in string.digits:
compatZenossVers = '==' + compatZenossVers
try:
req = pkg_resources.Requirement.parse(
'zenoss%s' % compatZenossVers)
except ValueError:
messaging.IMessageSender(self).sendToBrowser(
'Error',
('%s is not a valid version specification for Zenoss.'
% compatZenossVers),
priority=messaging.WARNING
)
if not req.__contains__(ZENOSS_VERSION):
messaging.IMessageSender(self).sendToBrowser(
'Error',
('%s does not match this version of Zenoss (%s).' %
(compatZenossVers, ZENOSS_VERSION)),
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
REQUEST.form['compatZenossVers'] = compatZenossVers
if 'Select or specify your own' in REQUEST.get('license', ''):
REQUEST.form['license'] = ''
result = ZenModelRM.zmanage_editProperties(self, REQUEST, redirect,
audit=False)
audit('UI.ZenPack.Edit',
self.id,
data_=REQUEST.form,
skipFields_=('redirect',
'zenScreenName',
'zmanage_editProperties'))
if self.isEggPack():
self.writeSetupValues()
self.writeLicense()
self.buildEggInfo()
return result