本文整理汇总了Python中repoze.workflow.get_workflow函数的典型用法代码示例。如果您正苦于以下问题:Python get_workflow函数的具体用法?Python get_workflow怎么用?Python get_workflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_workflow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evolve
def evolve(root):
former_id = 'formeruser'
profiles = find_profiles(root)
search = ICatalogSearch(root)
catalog = find_catalog(root)
creators = catalog['creator']._fwd_index.keys()
modifiers = catalog['modified_by']._fwd_index.keys()
userids = set(creators) | set(modifiers)
for userid in userids:
if userid not in profiles:
if former_id not in profiles:
workflow = get_workflow(IProfile, 'security')
former_id = make_unique_name(profiles, 'formeruser')
print "Creating profile for former user content:", former_id
former_profile = create_content(
IProfile, firstname='Former', lastname='User'
)
profiles[former_id] = former_profile
workflow.initialize(former_profile)
workflow.transition_to_state(former_profile, None, 'inactive')
count, docids, resolver = search(creator=userid)
for docid in docids:
doc = resolver(docid)
print "Updating 'creator' for", model_path(doc)
doc.creator = former_id
count, docids, resolver = search(modified_by=userid)
for docid in docids:
doc = resolver(docid)
print "Updating 'modified_by' for", model_path(doc)
doc.modified_by = former_id
示例2: handle
def handle(self, message, info, text, attachments):
""" See IMailinHandler.
"""
entry = create_content(
IBlogEntry,
title=info['subject'],
creator=info['author'],
text=text,
description=extract_description(text),
)
entry.created = info['date']
if attachments:
if 'attachments' not in entry:
# XXX Not a likely code path, left here for safety
entry['attachments'] = att_folder = AttachmentsFolder()
att_folder.title = 'Attachments'
att_folder.creator = info['author']
else:
att_folder = entry['attachments']
_addAttachments(att_folder, info, attachments)
entry_id = make_unique_name(self.context, entry.title)
self.context[entry_id] = entry
workflow = get_workflow(IBlogEntry, 'security', self.context)
if workflow is not None:
workflow.initialize(entry)
alerts = queryUtility(IAlerts, default=Alerts())
alerts.emit(entry, offline_request)
示例3: state_contract_change
def state_contract_change(self):
new_state = self.request.POST['new_state']
new_contract = self.request.POST['new_contract']
invoice_number = self.request.POST['invoice_number']
te_ids = set(int(s[3:])
for s, checkbox_state in self.request.POST.iteritems()
if s.startswith('te_') and checkbox_state=='on')
qry = DBSession.query(TimeEntry).filter(TimeEntry.id.in_(te_ids))
done_state = set()
done_contract = set()
errors = {}
for te in qry:
if new_state:
try:
workflow = get_workflow(te, te.__class__.__name__)
workflow.transition_to_state(te, self.request, new_state, skip_same=True)
done_state.add(te.id)
if new_state == 'invoiced' and invoice_number:
te.invoice_number = invoice_number
except WorkflowError as msg:
errors[te.id] = msg
if new_contract:
done_contract.add(te.id)
te.contract_id = new_contract
return done_state, done_contract, errors
示例4: get_wf_state_titles
def get_wf_state_titles(request, iface, type_name):
wf = get_workflow(iface, type_name)
results = {}
tstring = _
for sinfo in wf.state_info(None, request):
results[sinfo['name']] = request.localizer.translate(tstring(sinfo['title']))
return results
示例5: handle_submit
def handle_submit(self, converted):
context = self.context
request = self.request
parent = context.__parent__
creator = authenticated_userid(request)
comment = create_content(
IComment,
'Re: %s' % parent.title,
converted['add_comment'],
extract_description(converted['add_comment']),
creator,
)
next_id = parent['comments'].next_id
parent['comments'][next_id] = comment
workflow = get_workflow(IComment, 'security', context)
if workflow is not None:
workflow.initialize(comment)
if 'security_state' in converted:
workflow.transition_to_state(comment, request,
converted['security_state'])
if support_attachments(comment):
upload_attachments(converted['attachments'], comment,
creator, request)
relocate_temp_images(comment, request)
if converted.get('sendalert'):
alerts = queryUtility(IAlerts, default=Alerts())
alerts.emit(comment, request)
location = resource_url(parent, request)
msg = 'Comment added'
location = '%s?status_message=%s' % (location, urllib.quote(msg))
self.filestore.clear()
return HTTPFound(location=location)
示例6: evolve
def evolve(context):
out = codecs.getwriter('UTF-8')(sys.stdout)
# Fix strange user db inconsistency from (hopefully) distant past.
# Some users in the db have user info but their login is missing from
# the logins dict.
users = find_users(context)
logins = users.logins
for id in users.byid.keys():
login = users.get_by_id(id)['login']
if login not in logins:
logins[login] = id
# Convert profiles to new workflow.
workflow = get_workflow(IProfile, 'security')
for profile in find_profiles(context).values():
print >>out, ("Updating security workflow for profile: %s" %
profile.__name__)
if not hasattr(profile, 'security_state'):
# 'formeruser' was added without initializing workflow, oops.
workflow.initialize(profile)
workflow.transition_to_state(profile, None, 'inactive')
continue
assert profile.security_state == 'profile'
assert not has_custom_acl(profile)
profile.security_state = 'active'
workflow.reset(profile)
示例7: evolve
def evolve(site):
offices = site.get('offices')
if offices is None:
return
for doc in postorder(offices):
if hasattr(doc, '__custom_acl__'):
continue
try:
ct = get_content_type(doc)
except:
continue
if ct is None:
continue
wf = get_workflow(ct, 'security', doc)
if wf is None:
continue
if wf.name != 'intranet-content':
continue
print 'Resetting workflow for', model_path(doc)
wf.reset(doc)
_reindex(offices)
示例8: deactivate_profile_view
def deactivate_profile_view(context, request):
name = context.__name__
myself = authenticated_userid(request) == context.__name__
confirm = request.params.get('confirm')
if confirm:
try:
find_users(context).remove(name)
except KeyError:
pass
workflow = get_workflow(IProfile, 'security', context)
workflow.transition_to_state(context, request, 'inactive')
if myself:
return logout_view(context, request, reason='User removed')
query = {'status_message': 'Deactivated user account: %s' % name}
parent = context.__parent__
location = resource_url(parent, request, query=query)
return HTTPFound(location=location)
page_title = 'Deactivate user account for %s %s' % (context.firstname,
context.lastname)
api = TemplateAPI(context, request, page_title)
# Show confirmation page.
return dict(api=api, myself=myself)
示例9: stop
def stop(self):
"""
PATCH /arc2box/communities/<community>/
{"action": "stop"}
Tell the archiver to stop copying content from this community to box
and to take the community out of the 'copying' state. The community
must be in the 'copying' or 'reviewing' state. The community will
return to normal operation and will not be in any archiving state.
"""
community = self.context
status = getattr(community, 'archive_status', None)
if status not in ('copying', 'reviewing', 'exception'):
return HTTPBadRequest(
"Community must be in 'copying' or 'reviewing' state.")
# Restore normal ACL for workflow state
wf = get_workflow(ICommunity, 'security', community)
wf.reset(community)
del community.__custom_acl__
# If still in the copy queue, the archiver will skip this community
del community.archive_status
logger.info('arc2box: stop community: ' + community.title)
return HTTPAccepted()
示例10: handle_submit
def handle_submit(self, converted):
context = self.context
request = self.request
userid = converted['login']
users = self.users
if (users.get_by_id(userid) is not None or
users.get_by_login(userid) is not None or
userid in context):
msg = "User ID '%s' is already in use" % userid
raise ValidationError(login=msg)
users.add(userid, userid, converted['password'], converted['groups'])
# prepend http:// to the website URL if necessary
if converted.get('website', '').startswith('www.'):
converted['website'] = 'http://%s' % converted['website']
kw = {}
for k, v in converted.items():
if k in ('login', 'password', 'password_confirm',
'photo', 'groups'):
continue
kw[k] = v
profile = create_content(IProfile, **kw)
context[userid] = profile
workflow = get_workflow(IProfile, 'security', context)
if workflow is not None:
workflow.initialize(profile)
handle_photo_upload(profile, converted, thumbnail=True)
location = model_url(profile, request)
return HTTPFound(location=location)
示例11: sync
def sync(self, data):
context = self.context
timestamp = data.pop('timestamp', None)
if timestamp:
context.usersync_timestamp = timestamp
elif hasattr(context, 'usersync_timestamp'):
del context.usersync_timestamp
deactivate_missing = data.pop('deactivate_missing', False)
if deactivate_missing:
profiles = find_profiles(self.context)
missing = set([p.__name__ for p in profiles.values()
if p.security_state == 'active' and
getattr(p, 'usersync_managed', False)])
else:
missing = Empty()
users = data.pop('users')
for user in users:
self.syncuser(user, missing)
if data:
raise ValueError("Unrecognized keys in user sync data: %s" %
data.keys())
if missing:
users = find_users(self.context)
for username in missing:
profile = profiles[username]
workflow = get_workflow(IProfile, 'security', profile)
workflow.transition_to_state(profile, None, 'inactive')
users.remove(username)
示例12: __init__
def __init__(self, context, request):
self.context = context
self.request = request
self.workflow = get_workflow(ICommunityFile, 'security', context)
self.filestore = get_filestore(context, request, 'add-file')
self.show_sendalert = get_show_sendalert(self.context, self.request)
self.check_upload_size = check_upload_size # for testing
示例13: wf_state
def wf_state(self):
""" get the workflow state via the repoze.workflow API """
state = ''
if HAS_WORKFLOW:
workflow = get_workflow(self, 'security')
state = workflow.state_of(self) or ''
return state
示例14: __init__
def __init__(self, context, request):
self.context = context
self.request = request
self.wf = get_workflow(self.context, 'security')
assert(self.wf is not None)
示例15: _callFUT
def _callFUT(self, iface, name, workflows=None, context=None):
if workflows is None:
wokflows = []
def process_workflow_list(wf_list, context):
if workflows:
return workflows.pop()
from repoze.workflow import get_workflow
return get_workflow(iface, name, context, process_workflow_list)