本文整理汇总了Python中substanced.util.get_oid函数的典型用法代码示例。如果您正苦于以下问题:Python get_oid函数的具体用法?Python get_oid怎么用?Python get_oid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_oid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _add_modal
def _add_modal(self, explanations, process, soup, tag, context, request):
context_oid = get_oid(context)
dace_ui_api = get_current_registry().getUtility(IDaceUIAPI,
'dace_ui_api')
explanationitemaction = None
explanationitem_actions = process.get_actions('explanationitem')
if explanationitem_actions:
explanationitemaction = explanationitem_actions[0]
if explanationitemaction:
values = {'url': request.resource_url(context, '@@explanationjson',
query={'op': 'getform',
'itemid': tag['data-item']}),
'item': explanations[tag['data-item']],
}
body = renderers.render(self.explanation_template, values, request)
explanation_item_soup = BeautifulSoup(body)
actionurl_update = dace_ui_api.updateaction_viewurl(
request=request,
action_uid=str(get_oid(explanationitemaction)),
context_uid=str(context_oid))
values = {'url': actionurl_update,
'item': explanations[tag['data-item']],
}
modal_body = renderers.render(self.modal_template, values, request)
explanation_item_modal_soup = BeautifulSoup(modal_body)
soup.body.append(explanation_item_modal_soup.body)
tag.append(explanation_item_soup.body)
tag.body.unwrap()
开发者ID:ecreall,项目名称:nova-ideo,代码行数:29,代码来源:amendment_viewer.py
示例2: serialize_roles
def serialize_roles(roles, root=None):
result = []
principal_root = getSite()
if principal_root is None:
return []
if root is None:
root = principal_root
root_oid = str(get_oid(root, ''))
principal_root_oid = str(get_oid(principal_root, ''))
for role in roles:
if isinstance(role, tuple):
obj_oid = str(get_oid(role[1], ''))
result.append((role[0]+'_'+obj_oid).lower())
superiors = getattr(DACE_ROLES.get(role[0], _marker),
'all_superiors', [])
result.extend([(r.name+'_'+obj_oid).lower()
for r in superiors])
else:
result.append(role.lower()+'_'+root_oid)
superiors = getattr(DACE_ROLES.get(role, _marker),
'all_superiors', [])
result.extend([(r.name+'_'+root_oid).lower() for r in
superiors])
for superior in superiors:
if superior.name == 'Admin':
result.append('admin_'+principal_root_oid)
break
return list(set(result))
开发者ID:ecreall,项目名称:nova-ideo,代码行数:32,代码来源:core.py
示例3: serialize
def serialize(self, field, cstruct, **kw):
if cstruct in (null, None):
cstruct = ()
is_multiple = getattr(self, 'multiple', False)
if is_multiple and not isinstance(cstruct, (list, tuple, set)):
cstruct = [cstruct]
if cstruct and is_multiple and \
not isinstance(list(cstruct)[0], string_types):
try:
cstruct = [str(get_oid(value)) for value in cstruct]
except Exception:
pass
elif isinstance(cstruct, string_types):
try:
cstruct = str(get_oid(cstruct))
except Exception:
pass
readonly = kw.get('readonly', self.readonly)
values = kw.get('values', self.values)
kw['values'] = _normalize_choices(values)
template = readonly and self.readonly_template or self.template
tmpl_values = self.get_template_values(field, cstruct, kw)
return field.renderer(template, **tmpl_values)
开发者ID:ecreall,项目名称:pontus,代码行数:26,代码来源:widget.py
示例4: start
def start(self, context, request, appstruct, **kw):
appstruct.pop('_csrf_token_')
user = request.user
appstruct['user'] = 'Anonymous'
if user:
appstruct['user'] = get_oid(user)
now = datetime.datetime.now(tz=pytz.timezone('Europe/Paris'))
appstruct['date'] = now.isoformat()
site = get_site_folder(True, request)
appstruct['site'] = get_oid(site)
alert('arango', [], ["lac."+appstruct['id']], appstruct)
#alert slack
appstruct['date'] = to_localized_time(
now, translate=True)
text = 'Aimez-vous la nouvelle version: {new_version}\n '
if appstruct['new_version'] == 'False':
text += 'Pourquoi non: {explanation}\n '
text += 'Aimeriez-vous une application mobile: {mobile_application}\n \n User: {user}\n Email: {email}\n Date: {date}'
text = text.format(**appstruct)
alert('slack', [], ['questionnaire'], {'text': text})
if user and not getattr(user, 'email', ''):
user.email = appstruct.get('email', '')
return {}
开发者ID:ecreall,项目名称:lagendacommun,代码行数:26,代码来源:behaviors.py
示例5: clean_reviews
def clean_reviews(root, registry):
import json
from substanced.util import get_oid
from dace.util import find_catalog
wapis = [s for s in root.site_folders if s.title == 'Sortir Wapi']
lilles = [s for s in root.site_folders if s.title == 'Sortir Lille']
wapi_site = wapis[0]
wapi_site_oid = get_oid(wapi_site)
lille_site = lilles[0]
lille_site_oid = get_oid(lille_site)
with open('critiques.json') as data_file:
entities = json.load(data_file)
entities_with_ids = [entity for entity in entities
if entity.get('source_data', {}).get('id', None)]
ids = {str(entity['source_data']['id'] + '_' + entity['source_data']['source_id']): entity
for entity in entities_with_ids}
lac_catalog = find_catalog('lac')
object_id_index = lac_catalog['object_id']
reviews = object_id_index.any(list(ids.keys())).execute()
len_entities = str(len(reviews))
for index, review in enumerate(reviews):
reviwe_site = getattr(review, 'source_data', {}).get('site', None)
if reviwe_site != 'wapi':
review.access_control = PersistentList(
[wapi_site_oid, lille_site_oid])
review.reindex()
log.info("Wapi-Lille: "+str(index) + "/" + len_entities)
else:
log.info("Wapi: "+str(index) + "/" + len_entities)
log.info('Clean review evolved.')
开发者ID:ecreall,项目名称:lagendacommun,代码行数:32,代码来源:__init__.py
示例6: get_roles
def get_roles(user=None, obj=None,
root=None, ignore_groups=False):
if user is None:
user = get_current()
if isinstance(user, Anonymous):
return [RoleAnonymous.name]
if root is None:
root = getSite()
if obj is None:
obj = root
opts = {u'source_id': get_oid(user),
u'target_id': get_oid(obj)}
opts[u'reftype'] = 'Role'
roles = [r.relation_id for r in find_relations(obj, opts).all()]
principals = find_service('principals')
sd_admin = principals['users']['admin']
if sd_admin is user and 'Admin' not in roles:
roles.append('Admin')
groups = []
if not ignore_groups:
groups.extend(getattr(user, 'user_groups', []))
for group in groups:
roles.extend(get_roles(group, obj, root))
return list(set(roles))
开发者ID:ecreall,项目名称:dace,代码行数:31,代码来源:util.py
示例7: update
def update(self):
result = {}
duplicates = get_duplicates(self.context)
diff_bodies = {}
context_view = self.content(
args={'object': self.context},
template=self.context.templates.get('diff', None))['body']
for duplicate in duplicates:
duplicate_view = self.content(
args={'object': duplicate},
template=duplicate.templates.get('diff', None))['body']
soupt, textdiff = html_diff_wrapper.render_html_diff(
context_view, duplicate_view)
diff_bodies[duplicate] = (textdiff, get_oid(duplicate))
values = {'context': self.context,
'oid': get_oid(self.context),
'context_view': context_view,
'contents': diff_bodies,
'view': self}
body = self.content(args=values, template=self.template)['body']
item = self.adapt_item(body, self.viewid)
result['coordinates'] = {self.coordinates: [item]}
return result
开发者ID:ecreall,项目名称:lagendacommun,代码行数:25,代码来源:manage_duplicates.py
示例8: get_access_keys
def get_access_keys(user, root=None, to_exclude=[]):
if isinstance(user, Anonymous):
return ['anonymous']
principals = find_service('principals')
sd_admin = principals['users']['admin']
pricipal_root = getSite()
if root is None:
root = pricipal_root
root_oid = get_oid(root)
principal_root_oid = get_oid(pricipal_root)
if sd_admin is user:
return list(set([('admin'+'_'+str(root_oid)).lower(),
('admin'+'_'+str(principal_root_oid)).lower()]))
groups = list(getattr(user, 'user_groups', []))
groups.append(user)
relations = []
for group in groups:
opts = {u'source_id': get_oid(group)}
opts[u'reftype'] = 'Role'
relations.extend(list(find_relations(group, opts).all()))
result = [(t.relation_id+'_'+str(t.target_id)).lower() \
for t in relations if t.target_id not in to_exclude]
for relation in relations:
if relation.relation_id == 'Admin':
result.append(('admin'+'_'+str(principal_root_oid)).lower())
break
return list(set(result))
开发者ID:ecreall,项目名称:dace,代码行数:32,代码来源:util.py
示例9: bind
def bind(self):
bindings = {}
user = get_current(self.request)
dace_catalog = find_catalog('dace')
novaideo_catalog = find_catalog('novaideo')
object_authors_index = novaideo_catalog['object_authors']
container_index = dace_catalog['container_oid']
query = container_index.eq(get_oid(self.context))
objects = find_entities(
interfaces=[IAmendment],
user=user,
add_query=query)
query = query & object_authors_index.any([get_oid(user)])
my_objs = find_entities(
interfaces=[IAmendment],
user=user,
add_query=query)
len_result = len(objects)
len_my = len(my_objs)
len_others = len_result - len_my
bindings['user'] = user
bindings['len_result'] = len_result
bindings['len_my'] = len_my
bindings['len_others'] = len_others
setattr(self, '_bindings', bindings)
开发者ID:ecreall,项目名称:nova-ideo,代码行数:25,代码来源:see_amendments.py
示例10: _get_query
def _get_query(self, user):
dace_catalog = find_catalog('dace')
novaideo_catalog = find_catalog('novaideo')
object_authors_index = novaideo_catalog['object_authors']
container_index = dace_catalog['container_oid']
return container_index.eq(get_oid(self.context)) & \
object_authors_index.notany([get_oid(user)])
开发者ID:ecreall,项目名称:nova-ideo,代码行数:7,代码来源:see_amendments.py
示例11: content_added_or_removed
def content_added_or_removed(event):
""" Generates ContentAdded and ContentRemoved audit events """
if IObjectWillBeRemoved.providedBy(event):
event_name = 'ContentRemoved'
elif IObjectAdded.providedBy(event):
event_name = 'ContentAdded'
else:
return False # for testing
userinfo = get_userinfo()
eventscribe = AuditScribe(event.object)
parent = event.parent
# this is an event related to the *container*, not to the object.
folder_oid = get_oid(parent, None)
object_oid = get_oid(event.object, None)
folder_path = resource_path(parent)
object_name = event.name
moving = bool(event.moving)
loading = bool(event.loading)
content_type = str(event.registry.content.typeof(event.object))
eventscribe.add(
event_name,
folder_oid,
object_oid=object_oid,
folder_oid=folder_oid,
folder_path=folder_path,
object_name=object_name,
content_type=content_type,
userinfo=userinfo,
moving=moving,
loading=loading,
)
开发者ID:seletz,项目名称:substanced,代码行数:31,代码来源:subscribers.py
示例12: reviwes_access_control_evolve
def reviwes_access_control_evolve(root, registry):
from lac.views.filter import find_entities
from lac.content.interface import IBaseReview
from substanced.util import get_oid
reviews = find_entities(interfaces=[IBaseReview])
len_entities = str(len(reviews))
wapis = [s for s in root.site_folders if s.title == 'Sortir Wapi']
lilles = [s for s in root.site_folders if s.title == 'Sortir Lille']
wapi_site = wapis[0]
wapi_site_oid = get_oid(wapi_site)
lille_site = lilles[0]
lille_site_oid = get_oid(lille_site)
for index, review in enumerate(reviews):
reviwe_site = getattr(review, 'source_data', {}).get('site', None)
reviwe_siteid = getattr(review, 'source_data', {}).get('source_id', None)
if reviwe_site == 'wapi':
review.source_site = wapi_site_oid
review.access_control = PersistentList([wapi_site_oid])
log.info("Wapi: "+str(index) + "/" + len_entities)
elif reviwe_siteid == 'sortir':
review.source_site = lille_site_oid
review.access_control = PersistentList([lille_site_oid])
#log.info("Lille: "+str(index) + "/" + len_entities)
else:
source_site = review.source_site if review.source_site else 'all'
review.access_control = PersistentList([source_site])
#log.info("CrerationCulturelle: "+str(index) + "/" + len_entities)
review.reindex()
log.info('Review access_control evolved.')
开发者ID:ecreall,项目名称:lagendacommun,代码行数:32,代码来源:__init__.py
示例13: calculate_votes
def calculate_votes(self, votes):
"""Return the result of ballot"""
result = {}
for subject in self.report.subjects:
try:
subject_id = get_oid(subject)
except Exception:
subject_id = subject
result[subject_id] = 0
for vote in votes:
subject = get_obj(vote.value)
if subject is None:
subject = vote.value
try:
subject_id = get_oid(vote.value)
except Exception:
subject_id = vote.value
if subject in self.report.subjects:
result[subject_id] += 1
return result
开发者ID:jean,项目名称:nova-ideo,代码行数:26,代码来源:ballot.py
示例14: test_disconnect_relation
def test_disconnect_relation(self):
before = len(get_relations_container(self.app))
source, target, relation = self._create_relation()
self.assertEqual(len(get_relations_container(source)), before + 1)
results = find_relations(source, {'target_id': get_oid(target)})
before = len(get_relations_container(self.app))
disconnect(relation)
self.assertEqual(len(get_relations_container(source)), before - 1)
results = find_relations(source, {'target_id': get_oid(target)})
self.assertEqual(len(list(results)), 0)
开发者ID:ecreall,项目名称:dace,代码行数:11,代码来源:test_relations.py
示例15: test_remove_target
def test_remove_target(self):
before = len(get_relations_container(self.app))
source, target, relation = self._create_relation()
self.assertEqual(len(get_relations_container(source)), before + 1)
results = find_relations(source, {'target_id': get_oid(target)})
self.assertEqual(len(list(results)), 1)
before = len(get_relations_container(self.app))
del target.__parent__[target.__name__]
self.assertEqual(len(get_relations_container(source)), before - 1)
results = find_relations(source, {'target_id': get_oid(target)})
self.assertEqual(len(list(results)), 0)
开发者ID:ecreall,项目名称:dace,代码行数:12,代码来源:test_relations.py
示例16: all_alerts
def all_alerts(self):
novaideo_catalog = find_catalog('novaideo')
dace_catalog = find_catalog('dace')
alert_keys_index = novaideo_catalog['alert_keys']
alert_exclude_keys_index = novaideo_catalog['alert_exclude_keys']
object_provides_index = dace_catalog['object_provides']
exclude = [str(get_oid(self))]
if self.mask:
exclude.append(str(get_oid(self.mask)))
query = object_provides_index.any([IAlert.__identifier__]) & \
alert_keys_index.any(self.get_alerts_keys()) & \
alert_exclude_keys_index.notany(exclude)
return query.execute()
开发者ID:ecreall,项目名称:nova-ideo,代码行数:14,代码来源:person.py
示例17: setUp
def setUp(self):
super(TestVoteIntegration, self).setUp()
self.user1 = self.root['principals']['users']['user1'] = User()
self.user2 = self.root['principals']['users']['user2'] = User()
self.user3 = self.root['principals']['users']['user3'] = User()
self.user4 = self.root['principals']['users']['user4'] = User()
self.subject1 = self.root['subject1'] = SubjectType(title='subject1')
self.subject2 = self.root['subject2'] = SubjectType(title='subject2')
self.subject3 = self.root['subject3'] = SubjectType(title='subject3')
self.subject4 = self.root['subject4'] = SubjectType(title='subject4')
self.oid_subject1 = get_oid(self.subject1)
self.oid_subject2 = get_oid(self.subject2)
self.oid_subject3 = get_oid(self.subject3)
self.oid_subject4 = get_oid(self.subject4)
开发者ID:jean,项目名称:nova-ideo,代码行数:14,代码来源:test_vote.py
示例18: _identify_corrections
def _identify_corrections(self, soup, correction, descriminator, content, user):
correction_tags = soup.find_all('span', {'id': "correction"})
correction_oid = str(get_oid(correction))
user_oid = get_oid(user)
for correction_tag in correction_tags:
correction_tag['data-correction'] = correction_oid
correction_tag['data-item'] = str(descriminator)
correction_tag['data-content'] = content
init_vote = {'favour': [user_oid],
'against': [], 'content': content}
correction.corrections[str(descriminator)] = init_vote
descriminator += 1
return descriminator
开发者ID:ecreall,项目名称:nova-ideo,代码行数:14,代码来源:behaviors.py
示例19: action_infomrations
def action_infomrations(self, action, context, request=None, **args):
action_id = action.behavior_id
view_title = action.title
view = DEFAULTMAPPING_ACTIONS_VIEWS.get(action._class_, None)
if view:
view_title = getattr(view, 'title', view_title)
action_oid = 'start'
context_oid = get_oid(context)
try:
action_oid = get_oid(action)
except Exception:
pass
action_id = action_id + str(action_oid) + '_' + str(context_oid)
if action_oid == 'start':
after_url = self.afterexecution_viewurl(
request=request,
isstart=True,
context_uid=str(context_oid),
pd_id=action.node.process.id,
action_id=action.node.__name__,
behavior_id=action.behavior_id)
actionurl_update = self.updateaction_viewurl(
request=request,
isstart=True,
context_uid=str(context_oid),
pd_id=action.node.process.id,
action_id=action.node.__name__,
behavior_id=action.behavior_id)
else:
after_url = self.afterexecution_viewurl(
request=request,
action_uid=str(action_oid),
context_uid=str(context_oid))
actionurl_update = self.updateaction_viewurl(
request=request,
action_uid=str(action_oid),
context_uid=str(context_oid))
informations = {}
informations.update({'action': action,
'action_id': action_id,
'actionurl_update': actionurl_update,
'actionurl_after': after_url,
'view_title': view_title
})
return informations
开发者ID:ecreall,项目名称:daceui,代码行数:49,代码来源:util.py
示例20: get_action_body
def get_action_body(
self, context, request, action,
add_action_discriminator=False, unwrap=True,
include_resources=False):
body = ''
resources = {
'css_links': [],
'js_links': []
}
if action is not None:
view = DEFAULTMAPPING_ACTIONS_VIEWS[action._class_]
view_instance = view(context, request, behaviors=[action])
if add_action_discriminator:
action_oid = get_oid(action)
view_instance.viewid += str(action_oid)
if unwrap:
view_instance.wrapper_template = 'daceui:templates/simple_view_wrapper.pt'
view_result = view_instance()
body = ''
if isinstance(view_result, dict) and 'coordinates' in view_result:
resources['css_links'] = view_result.get('css_links', [])
resources['js_links'] = view_result.get('js_links', [])
body = view_instance.render_item(view_result['coordinates'][view_instance.coordinates][0],
view_instance.coordinates, None)
if include_resources:
return body, resources
return body
开发者ID:ecreall,项目名称:daceui,代码行数:30,代码来源:util.py
注:本文中的substanced.util.get_oid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论