本文整理汇总了Python中zope.component.getAllUtilitiesRegisteredFor函数的典型用法代码示例。如果您正苦于以下问题:Python getAllUtilitiesRegisteredFor函数的具体用法?Python getAllUtilitiesRegisteredFor怎么用?Python getAllUtilitiesRegisteredFor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAllUtilitiesRegisteredFor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Martronic-SA,项目名称:collective.behavior.sql,代码行数:12,代码来源:content.py
示例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) ]
开发者ID:collective,项目名称:Products.CMFBibliographyAT,代码行数:7,代码来源:bibliography.py
示例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]
开发者ID:datakurre,项目名称:jyu.portfolio.layout,代码行数:28,代码来源:behaviors.py
示例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
开发者ID:plone,项目名称:five.intid,代码行数:26,代码来源:intid.py
示例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()
开发者ID:iamedu,项目名称:armdev,代码行数:26,代码来源:ldstr.py
示例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)
开发者ID:dtgit,项目名称:dtedu,代码行数:29,代码来源:factory.py
示例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))
开发者ID:adam139,项目名称:Products.CMFPlone,代码行数:31,代码来源:admin.py
示例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]
开发者ID:headnet,项目名称:plone.app.dexterity,代码行数:7,代码来源:types.py
示例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])
开发者ID:Martronic-SA,项目名称:collective.behavior.sql,代码行数:7,代码来源:vocabularies.py
示例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)
开发者ID:Raptus,项目名称:raptus.workflownotificationtemplates,代码行数:7,代码来源:vocabulary.py
示例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)
开发者ID:Raptus,项目名称:raptus.article.allcontent,代码行数:7,代码来源:vocabulary.py
示例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
开发者ID:iamedu,项目名称:armdev,代码行数:26,代码来源:arm9processor.py
示例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)
开发者ID:murisfurder,项目名称:opennode-knot,代码行数:29,代码来源:compute.py
示例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)
开发者ID:syslabcom,项目名称:slc.accountrequest,代码行数:7,代码来源:eventhandlers.py
示例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
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:26,代码来源:intid.py
示例16: fields
def fields(self):
terms = []
for reg in getAllUtilitiesRegisteredFor(IRecipientSourceRegistration):
if not reg.enabled:
continue
terms.append(schema.vocabulary.SimpleTerm(
value = reg,
token = reg.name,
title = reg.title,
))
# if only one source, redirect to it
if len(terms) <= 1:
self._redirect_url = '%s/@@add-recipient?form.widgets.recipient_type=%s' % (self.context.absolute_url(), terms[0].value.name)
return field.Fields()
vocab = schema.vocabulary.SimpleVocabulary(terms)
fields = field.Fields(schema.Choice(
__name__ = 'recipient_type',
title = _(u'Recipient type'),
description = _(u'Select the type of recipient you want to add.'),
vocabulary = vocab,
default = vocab.by_token['standard'].value,
))
fields['recipient_type'].widgetFactory = DescriptiveRadioWidget
return fields
开发者ID:collective,项目名称:collective.megaphone,代码行数:26,代码来源:recipients_step.py
示例17: _get_profile
def _get_profile(self, product_id, name, strict=True, allow_hidden=False):
"""Return profile with given name.
Also return None when no profiles are found at all.
:param product_id: id of product/package.
For example CMFPlone or plone.app.registry.
:type product_id: string
:param name: name of profile.
Usually 'default' or 'uninstall'.
:type name: string
:param strict: When True, return None when name is not found.
Otherwise fall back to the first profile.
:type strict: boolean
:param allow_hidden: Allow getting hidden profile.
A non hidden profile is always preferred.
:type allow_hidden: boolean
:returns: True on success, False otherwise.
:rtype: boolean
"""
profiles = self._install_profile_info(product_id)
if not profiles:
return
utils = getAllUtilitiesRegisteredFor(INonInstallable)
hidden = []
for util in utils:
gnip = getattr(util, 'getNonInstallableProfiles', None)
if gnip is None:
continue
hidden.extend(gnip())
# We have prime candidates that we prefer, and have hidden candidates
# in case allow_hidden is True.
prime_candidates = []
hidden_candidates = []
for profile in profiles:
profile_id = profile['id']
profile_id_parts = profile_id.split(':')
if len(profile_id_parts) != 2:
logger.error("Profile with id '%s' is invalid." % profile_id)
continue
if allow_hidden and profile_id in hidden:
if profile_id_parts[1] == name:
# This will especially be true for uninstall profiles,
# which are usually hidden.
return profile
hidden_candidates.append(profile)
continue
if profile_id_parts[1] == name:
return profile
prime_candidates.append(profile)
if strict:
return
if prime_candidates:
# QI used to pick the first profile.
# Return the first profile after all.
return prime_candidates[0]
if allow_hidden and hidden_candidates:
# Return the first hidden profile.
return hidden_candidates[0]
开发者ID:zmijunkie,项目名称:Products.CMFPlone,代码行数:60,代码来源:quickinstaller.py
示例18: execute
def execute(self, proc, inst):
shifter_operand = 0
shifter_carry_out = 0
if not checkCondition(proc, inst):
return
rn = utils.getBits(inst, 16, 4)
rn = 'r' + str(rn)
rnVal = getattr(proc, rn)
modes = component.getAllUtilitiesRegisteredFor(IARMDPAddressingMode)
for mode in modes:
if testInstruction(mode, inst):
shifter_operand, shifter_carry_out = mode.getVal(proc, inst)
break
rnBitset = Bitset(rnVal, 32)
shifterBitset = Bitset(shifter_operand, 32)
alu_out, carry = rnBitset + shifter_operand
if utils.getBits(rnVal, 31) == 0 and utils.getBits(int(result), 31) == 1:
v = 1
else:
v = 0
proc.setStatusFlag('N', utils.getBits(int(alu_out), 31))
proc.setStatusFlag('Z', int(int(alu_out) == 0))
proc.setStatusFlag('C', carry)
proc.setStatusFlag('V', v)
开发者ID:iamedu,项目名称:armdev,代码行数:28,代码来源:dp.py
示例19: removeIntIdSubscriber
def removeIntIdSubscriber(ob, event):
"""A subscriber to ObjectRemovedEvent
Removes the unique ids registered 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
# Notify the catalogs that this object is about to be removed.
notify(IntIdRemovedEvent(ob, event))
for utility in utilities:
try:
utility.unregister(key)
except KeyError:
pass
开发者ID:plone,项目名称:five.intid,代码行数:25,代码来源:intid.py
示例20: addIntIdSubscriber
def addIntIdSubscriber(ob, event):
"""A subscriber to ObjectAddedEvent
Registers the object added in all unique id utilities and fires
an event for the catalogs.
"""
factorytool = getToolByName(ob, 'portal_factory', None)
if factorytool is not None and factorytool.isTemporary(ob):
# Ignore objects marked as temporary in the CMFPlone portal_factory
# tool
return
utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
if utilities: # assert that there are any utilites
key = None
try:
key = IKeyReference(ob, None)
except NotYet:
pass
# Register only objects that adapt to key reference
if key is not None:
for utility in utilities:
utility.register(key)
# Notify the catalogs that this object was added.
notify(IntIdAddedEvent(ob, event))
开发者ID:plone,项目名称:five.intid,代码行数:26,代码来源:intid.py
注:本文中的zope.component.getAllUtilitiesRegisteredFor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论