本文整理汇总了Python中zope.component.getAllUtilitiesRegisteredFor函数的典型用法代码示例。如果您正苦于以下问题:Python getAllUtilitiesRegisteredFor函数的具体用法?Python getAllUtilitiesRegisteredFor怎么用?Python getAllUtilitiesRegisteredFor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAllUtilitiesRegisteredFor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initConnections
def initConnections(site, event):
# this is called on first Plone traverse
portal_quickinstaller = getToolByName(site, 'portal_quickinstaller')
if portal_quickinstaller.isProductInstalled('collective.behavior.sql'):
if not getAllUtilitiesRegisteredFor(ISQLConnectionsUtility):
ftis = [a for a in getAllUtilitiesRegisteredFor(IDexterityFTI) if 'collective.behavior.sql.behavior.behaviors.ISQLContent' in a.behaviors and getattr(a, 'sql_table', None)]
if ftis:
for fti in ftis:
initConnectionForFTI(fti)
else:
gsm = getGlobalSiteManager()
gsm.registerUtility(SQLConnectionsUtility(), ISQLConnectionsUtility)
示例2: getImportFormatNames
def getImportFormatNames(self, with_unavailables=False, with_disabled=False):
"""
returns a list with the names of the supported import formats
"""
parsers = component.getAllUtilitiesRegisteredFor(IBibliographyParser)
return [parser.getFormatName() \
for parser in parsers if (parser.isAvailable() or with_unavailables) and (parser.isEnabled() or with_disabled) ]
示例3: getMenuItems
def getMenuItems(self, context, request):
"""Return menu item entries in a TAL-friendly form."""
types = []
for type_ in getAllUtilitiesRegisteredFor(ITileType):
if checkPermission(type_.add_permission, context):
try:
if request.traverseName(
context, "@@" + type_.__name__):
types.append(type_)
except NotFound:
continue
types.sort(lambda x, y: cmp(x.title, y.title))
normalizer = getUtility(IIDNormalizer)
return [{
'title': type_.title,
'description': type_.description,
'action': "%s/@@add-tile?form.button.Create=1&type=%s"\
% (context.absolute_url(), type_.__name__),
'selected': False,
'icon': None,
'extra': {
'id': "add-%s" % normalizer.normalize(type_.__name__),
'separator': None, 'class': ''
},
'submenu': None,
} for type_ in types]
示例4: moveIntIdSubscriber
def moveIntIdSubscriber(ob, event):
"""A subscriber to ObjectMovedEvent
Updates the stored path for the object in all the unique
id utilities.
"""
utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
if not utilities:
return
try:
key = IKeyReference(ob, None)
except NotYet:
key = None
# Register only objects that adapt to key reference
if key is None:
return
# Update objects that adapt to key reference
for utility in utilities:
try:
uid = utility.getId(ob)
utility.refs[uid] = key
utility.ids[key] = uid
except KeyError:
pass
示例5: execute
def execute(self, proc, inst):
if not utils.checkCondition(proc, inst):
return
modes = component.getAllUtilitiesRegisteredFor(IARMLSMAddressingMode)
for mode in modes:
if utils.testInstruction(mode, inst):
start_address, end_address = mode.getVal(proc, inst)
break
register_list = Bitset(utils.getBits(inst, 0, 16), 32)
address = start_address
print "Entra"
for i in range(16):
if register_list[i]:
print i, getattr(proc, 'r' + str(i))
proc.saveAddr(address, getattr(proc, 'r' + str(i)))
address += 4
print "Sale"
if end_address != address - 4:
raise exceptions.DataAbort()
示例6: addPloneSiteForm
def addPloneSiteForm(dispatcher):
"""
Wrap the PTF in 'dispatcher'.
"""
wrapped = PageTemplateFile('addSite', WWW_DIR).__of__(dispatcher)
base_profiles = []
extension_profiles = []
not_installable = []
utils = getAllUtilitiesRegisteredFor(INonInstallable)
for util in utils:
not_installable.extend(util.getNonInstallableProfiles())
for info in profile_registry.listProfileInfo():
if info.get('type') == EXTENSION and \
info.get('for') in (IPloneSiteRoot, None):
if info.get('id') not in not_installable:
extension_profiles.append(info)
for info in profile_registry.listProfileInfo():
if info.get('type') == BASE and \
info.get('for') in (IPloneSiteRoot, None):
if info.get('id') not in not_installable:
base_profiles.append(info)
return wrapped(base_profiles=tuple(base_profiles),
extension_profiles=tuple(extension_profiles),
default_profile=_DEFAULT_PROFILE)
示例7: profiles
def profiles(self):
base_profiles = []
extension_profiles = []
# profiles available for install/uninstall, but hidden at the time
# the Plone site is created
not_installable = ["Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow"]
utils = getAllUtilitiesRegisteredFor(INonInstallable)
for util in utils:
not_installable.extend(util.getNonInstallableProfiles())
for info in profile_registry.listProfileInfo():
if info.get("type") == EXTENSION and info.get("for") in (IPloneSiteRoot, None):
profile_id = info.get("id")
if profile_id not in not_installable:
if profile_id in self.default_extension_profiles:
info["selected"] = "selected"
extension_profiles.append(info)
def _key(v):
# Make sure implicitly selected items come first
selected = v.get("selected") and "automatic" or "manual"
return "%s-%s" % (selected, v.get("title", ""))
extension_profiles.sort(key=_key)
for info in profile_registry.listProfileInfo():
if info.get("type") == BASE and info.get("for") in (IPloneSiteRoot, None):
base_profiles.append(info)
return dict(base=tuple(base_profiles), default=_DEFAULT_PROFILE, extensions=tuple(extension_profiles))
示例8: get_items
def get_items(self):
""" Look up all Dexterity FTIs via the component registry.
(These utilities are created via an IObjectCreated handler for the DexterityFTI class,
configured in plone.dexterity.)
"""
ftis = getAllUtilitiesRegisteredFor(IDexterityFTI)
return [(fti.__name__, fti) for fti in ftis]
示例9: __call__
def __call__(self, context):
ftis = getAllUtilitiesRegisteredFor(IDexterityFTI)
if ISQLTypeSchemaContext.providedBy(context):
ftis = [context.fti]
else:
ftis = [fti for fti in ftis if 'collective.behavior.sql.behavior.behaviors.ISQLContent' in fti.behaviors]
return SimpleVocabulary([SimpleTerm(fti.__name__,fti.__name__, fti) for fti in ftis])
示例10: availableWorkflows
def availableWorkflows(context):
utilities = getAllUtilitiesRegisteredFor(IPossibleNotificationTemplates)
terms = []
for utility in utilities:
terms.extend([SimpleTerm(value, value, title) for value, title in utility.names(context)])
return SimpleVocabulary(terms)
示例11: __call__
def __call__(self, context):
providers = component.getAllUtilitiesRegisteredFor(IAllcontentStyleProvider)
terms = []
for provider in providers:
for value, title in provider.classes():
terms.append(vocabulary.SimpleTerm(value, None, title))
return vocabulary.SimpleVocabulary(terms)
示例12: run
def run(self):
processor = self
instructions = component.getAllUtilitiesRegisteredFor(IARMInstruction)
instructionLog = open('ilog', 'w')
while self.__running:
inst = processor.fetch()
processor.step()
executed = False
if inst == 0:
break
try:
for instruction in instructions:
if testInstruction(instruction, inst):
instructionLog.write(str(type(instruction)) + '\n')
instructionLog.flush()
instruction.execute(processor, inst)
executed = True
break
except exceptions.ProcessorException as ex:
ex.preprocess(self)
executed = True
if not executed:
print "Instruction not recognized %x" % inst
self.__running = False
示例13: _execute
def _execute(self, cmd, args):
name = yield db.get(self.context, '__name__')
parent = yield db.get(self.context, '__parent__')
submitter = IVirtualizationContainerSubmitter(parent)
yield submitter.submit(IUndeployVM, name)
@db.transact
def finalize_vm():
ippools = db.get_root()['oms_root']['ippools']
ip = netaddr.IPAddress(self.context.ipv4_address.split('/')[0])
if ippools.free(ip):
ulog = UserLogger(principal=cmd.protocol.interaction.participations[0].principal,
subject=self.context, owner=self.context.__owner__)
ulog.log('Deallocated IP: %s', ip)
vm = traverse1(canonical_path(self.context))
if vm is not None:
noLongerProvides(vm, IDeployed)
alsoProvides(vm, IUndeployed)
yield finalize_vm()
vm_parameters = yield self.get_parameters()
utils = getAllUtilitiesRegisteredFor(IPostUndeployHook)
for util in utils:
yield defer.maybeDeferred(util.execute, self.context, cmd, vm_parameters)
示例14: createAccount
def createAccount(obj, event):
# Transitioning from pending to created
if event.new_state.id == 'created':
# Look up utilities, call them to do actual registration
handlers = getAllUtilitiesRegisteredFor(IRegistrationHandler)
for handler in handlers:
handler.register(obj)
示例15: moveIntIdSubscriber
def moveIntIdSubscriber(ob, event):
"""A subscriber to ObjectMovedEvent
Updates the stored path for the object in all the unique
id utilities.
"""
if IObjectRemovedEvent.providedBy(event) or \
IObjectAddedEvent.providedBy(event):
return
utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
if utilities:
key = None
try:
key = IKeyReference(ob, None)
except NotYet: # @@ temporary fix
pass
# Update objects that adapt to key reference
if key is not None:
for utility in utilities:
try:
uid = utility.getId(ob)
utility.refs[uid] = key
utility.ids[key] = uid
except KeyError:
pass