本文整理匯總了Python中MaKaC.common.ObjectHolders.ObjectHolder類的典型用法代碼示例。如果您正苦於以下問題:Python ObjectHolder類的具體用法?Python ObjectHolder怎麽用?Python ObjectHolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ObjectHolder類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
def __init__(self):
ObjectHolder.__init__(self)
# These imports are done like this in order to avoid circular imports problems.
from indico.modules import cssTpls
ModuleHolder._availableModules = {
cssTpls.CssTplsModule.id: cssTpls.CssTplsModule
}
示例2: __init__
def __init__(self):
""" Creates / Returns a PluginsHolder object,
which is the "gateway" to all the methods for getting plugin meta-data.
"""
ObjectHolder.__init__(self)
if not self.hasKey("globalPluginOptions"):
self.add(GlobalPluginOptions())
if len(self._getIdx()) == 0: #no plugins
self.loadAllPlugins()
示例3: __init__
def __init__(self):
ObjectHolder.__init__(self)
# These imports are done like this in order to avoid circular imports problems.
from indico.modules import news
from indico.modules import cssTpls
from indico.modules import upcoming
ModuleHolder._availableModules = {
news.NewsModule.id: news.NewsModule,
cssTpls.CssTplsModule.id: cssTpls.CssTplsModule,
upcoming.UpcomingEventsModule.id: upcoming.UpcomingEventsModule,
}
示例4: update
def update(self, old_token, new_token):
ObjectHolder.remove(self, old_token)
Catalog.getIdx('user_oauth_request_token').unindex_obj(old_token)
ObjectHolder.add(self, new_token)
Catalog.getIdx('user_oauth_request_token').index_obj(new_token)
示例5: remove
def remove(self, token):
ObjectHolder.remove(self, token)
Catalog.getIdx('user_oauth_request_token').unindex_obj(token)
示例6: add
def add(self, token):
ObjectHolder.add(self, token)
Catalog.getIdx('user_oauth_request_token').index_obj(token)
示例7: _newId
def _newId( self ):
id = ObjectHolder._newId( self )
return "%s"%id
示例8: remove
def remove(self, item):
# METHOD HAS TO BE IMPLEMENTED...
ObjectHolder.remove(self, item)
TrashCanManager().add(item)
示例9: split_avatars
def split_avatars(file):
"""Step 2: Split the merged avatars - run this on the POST-MERGE database"""
data = json.load(file)
if len(data) != 2:
echo('Invalid data: Expected two items, found {}'.format(len(data)))
raise click.Abort()
avatars = [AvatarHolder().getById(x['id']) for x in data]
if avatars.count(None) != 1:
echo('Expected exactly one unreferenced avatar, got {}'.format(avatars))
raise click.Abort()
if avatars[0] is None:
orig = avatars[1]
orig_data = data[1]
merged_data = data[0]
else:
orig = avatars[0]
orig_data = data[0]
merged_data = data[1]
merged = [av for av in orig._mergeFrom if av.getId() == merged_data['id']]
if len(merged) != 1:
echo("Avatars don't seem to be merged into each other")
raise click.Abort()
merged = merged[0]
if merged not in orig._mergeFrom or merged._mergeTo != orig:
echo("Avatars don't seem to be merged into each other")
raise click.Abort()
# Remove merge references
orig._mergeFrom.remove(merged)
merged._mergeTo = None
# Clean secondary emails
orig.setSecondaryEmails(orig_data['secondary_emails'])
merged.setSecondaryEmails(merged_data['secondary_emails'])
# Clean identities
for identity in merged.getIdentityList(create_identities=True):
orig.removeIdentity(identity)
identity.setUser(merged)
# Re-index the avatars
# noinspection PyCallByClass
ObjectHolder.add(AvatarHolder(), merged)
for index in {'organisation', 'email', 'name', 'surName', 'status'}:
IndexesHolder().getById(index).unindexUser(orig)
IndexesHolder().getById(index).indexUser(orig)
IndexesHolder().getById(index).indexUser(merged)
# Restore links for the merged avatar
for key, links in merged_data['links'].iteritems():
objtype, role = key.split('.')
for link in links:
# TODO: Add extra items here as necessary (use show_links to check if anything is missing)!
if objtype == 'conference':
event = ConferenceHolder().getById(link, quiet=True)
if event is None:
echo('Event not found: {}'.format(link))
continue
if event not in set(orig.linkedTo[objtype][role]):
echo('{!r} not linked to avatar via {}'.format(event, key))
continue
if role == 'access':
event.revokeAccess(orig)
event.grantAccess(merged)
else:
echo('Unexpected link type: {}'.format(key))
raise click.Abort()
# print 'Updated {} - {!r}'.format(key, event)
elif objtype == 'contribution':
event_id, contrib_id = link
event = ConferenceHolder().getById(event_id)
if event is None:
echo('Event not found: {}'.format(event_id))
continue
contrib = event.getContributionById(contrib_id)
if contrib is None:
echo('Contrib not found: {}.{}'.format(event_id, contrib_id))
continue
if contrib not in set(orig.linkedTo[objtype][role]):
echo('{} not linked to avatar via {}'.format(contrib, key))
continue
if role == 'submission':
contrib.revokeSubmission(orig)
contrib.grantSubmission(merged)
elif role == 'manager':
contrib.revokeModification(orig)
contrib.grantModification(merged)
else:
echo('Unexpected link type: {}'.format(key))
raise click.Abort()
# print 'Updated {} - {}'.format(key, contrib)
else:
# This results in inconsistent data in redis, but since we flush the redis
# links after a successful merge, that's not an issue. Also, we only reach
# this branch if someone is using different versions of this script...
echo('Unexpected link type: {}'.format(key))
raise click.Abort()
if not click.confirm('Do you want to commit the changes now?'):
transaction.abort() # not really necessary, but let's stay on the safe side
raise click.Abort()
transaction.commit()
# Refresh redis links
avatar_links.delete_avatar(orig)
avatar_links.delete_avatar(merged)
avatar_links.init_links(orig)
#.........這裏部分代碼省略.........