本文整理汇总了Python中Products.CMFCore.FSMetadata.FSMetadata._getSectionDict方法的典型用法代码示例。如果您正苦于以下问题:Python FSMetadata._getSectionDict方法的具体用法?Python FSMetadata._getSectionDict怎么用?Python FSMetadata._getSectionDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFCore.FSMetadata.FSMetadata
的用法示例。
在下文中一共展示了FSMetadata._getSectionDict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read_validator_metadata
# 需要导入模块: from Products.CMFCore.FSMetadata import FSMetadata [as 别名]
# 或者: from Products.CMFCore.FSMetadata.FSMetadata import _getSectionDict [as 别名]
def _read_validator_metadata(self, id, filepath):
self.validators = FormValidatorContainer()
metadata = FSMetadata(filepath)
cfg = CMFConfigParser()
if os.path.exists(filepath + '.metadata'):
cfg.read(filepath + '.metadata')
_buttons_for_status = {}
validators = metadata._getSectionDict(cfg, 'validators')
if validators is None:
validators = {}
for (k, v) in validators.items():
# validators.CONTEXT_TYPE.BUTTON = LIST
component = k.split('.')
while len(component) < 3:
component.append('')
if component[0] != 'validators':
raise ValueError, '%s: Format for .metadata validators is validators.CONTEXT_TYPE.BUTTON = LIST (not %s)' % (filepath, k)
context_type = component[1]
self.validators.set(FormValidator(id, component[1], component[2], v))
status_key = str(context_type)
if _buttons_for_status.has_key(status_key):
_buttons_for_status[status_key].append(component[2])
else:
_buttons_for_status[status_key] = [component[2]]
for (k, v) in _buttons_for_status.items():
if v and not '' in v:
content_type = k
if not content_type:
content_type = 'ANY'
log('%s: No default validators specified for content type %s. Users of IE can submit pages using the return key, resulting in no button in the REQUEST. Please specify default validators for this case.' % (str(filepath), content_type))
示例2: _read_action_metadata
# 需要导入模块: from Products.CMFCore.FSMetadata import FSMetadata [as 别名]
# 或者: from Products.CMFCore.FSMetadata.FSMetadata import _getSectionDict [as 别名]
def _read_action_metadata(self, id, filepath):
self.actions = FormActionContainer()
metadata = FSMetadata(filepath)
cfg = CMFConfigParser()
if os.path.exists(filepath + ".metadata"):
cfg.read(filepath + ".metadata")
_buttons_for_status = {}
actions = metadata._getSectionDict(cfg, "actions")
if actions is None:
actions = {}
for (k, v) in actions.items():
# action.STATUS.CONTEXT_TYPE.BUTTON = ACTION_TYPE:ACTION_ARG
component = k.split(".")
while len(component) < 4:
component.append("")
if component[0] != "action":
raise ValueError, "%s: Format for .metadata actions is action.STATUS.CONTEXT_TYPE.BUTTON = ACTION_TYPE:ACTION_ARG (not %s)" % (
filepath,
k,
)
act = v.split(":", 1)
while len(act) < 2:
act.append("")
context_type = component[2]
self.actions.set(FormAction(id, component[1], component[2], component[3], act[0], act[1]))
status_key = str(component[1]) + "." + str(context_type)
if _buttons_for_status.has_key(status_key):
_buttons_for_status[status_key].append(component[3])
else:
_buttons_for_status[status_key] = [component[3]]
for (k, v) in _buttons_for_status.items():
if v and not "" in v:
sk = k.split(".")
status = sk[0]
content_type = sk[1]
if not status:
status = "ANY"
if not content_type:
content_type = "ANY"
log(
"%s: No default action specified for status %s, content type %s. Users of IE can submit pages using the return key, resulting in no button in the REQUEST. Please specify a default action for this case."
% (str(filepath), status, content_type),
log_level=logging.DEBUG,
)