本文整理汇总了Python中repoze.workflow.get_workflow函数的典型用法代码示例。如果您正苦于以下问题:Python get_workflow函数的具体用法?Python get_workflow怎么用?Python get_workflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_workflow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:cguardia,项目名称:karl,代码行数:35,代码来源:evolve20.py
示例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)
开发者ID:Falmarri,项目名称:karl,代码行数:31,代码来源:mailin.py
示例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
开发者ID:getpenelope,项目名称:por.dashboard,代码行数:30,代码来源:state_change.py
示例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
开发者ID:VoteIT,项目名称:voteit.core,代码行数:7,代码来源:helpers.py
示例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)
开发者ID:lslaz1,项目名称:karl,代码行数:35,代码来源:commenting.py
示例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)
开发者ID:Falmarri,项目名称:karl,代码行数:27,代码来源:evolve19.py
示例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)
开发者ID:cguardia,项目名称:karl,代码行数:28,代码来源:evolve35.py
示例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)
开发者ID:claytron,项目名称:karl,代码行数:26,代码来源:people.py
示例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()
开发者ID:araymund,项目名称:karl,代码行数:26,代码来源:apiviews.py
示例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)
开发者ID:boothead,项目名称:karl,代码行数:31,代码来源:people.py
示例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)
开发者ID:lslaz1,项目名称:karl,代码行数:31,代码来源:usersync.py
示例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
开发者ID:boothead,项目名称:karl,代码行数:7,代码来源:files.py
示例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
开发者ID:wyldebeast-wunderliebe,项目名称:w20e.pycms,代码行数:8,代码来源:base.py
示例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)
开发者ID:wyldebeast-wunderliebe,项目名称:w20e.pycms.workflow,代码行数:8,代码来源:workflow.py
示例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)
开发者ID:MatthewWilkes,项目名称:repoze.workflow,代码行数:8,代码来源:test_workflow.py
示例16: get_context_workflow
def get_context_workflow(context):
"""
If context is content and part of a workflow will return the workflow.
Otherwise returns None.
"""
if is_content(context):
content_type = get_content_type(context)
return get_workflow(content_type, 'security', context)
开发者ID:Falmarri,项目名称:karl,代码行数:8,代码来源:acl.py
示例17: syncuser
def syncuser(self, data, missing):
for key in self.required_keys:
if not data.get(key):
raise ValueError("Invalid user data: '%s' key is required" % key)
users = find_users(self.context)
profiles = find_profiles(self.context)
username = data.pop("username")
profile = profiles.get(username)
active = profile and profile.security_state == "active"
if username in missing:
missing.remove(username)
if not profile:
profile = self.createuser(data)
self.update(profile, data)
profiles[username] = profile
activate = data.pop("active", "true")
security_state = "active" if activate else "inactive"
log.info("Created user: %s", username)
else:
objectEventNotify(ObjectWillBeModifiedEvent(profile))
self.update(profile, data)
objectEventNotify(ObjectModifiedEvent(profile))
activate = data.pop("active", None)
if activate is not None:
security_state = "active" if activate else "inactive"
else:
security_state = profile.security_state
activate = active
if type(missing) is Empty:
log.info("Updated user: %s", username)
profile.usersync_managed = True
if active:
info = users.get(username)
password = data.pop("password", info["password"])
groups = data.pop("groups", info["groups"])
login = data.pop("login", info["login"])
users.remove(username)
elif activate: # reactivate
log.info("Reactivating user: %s", username)
login = data.pop("login", username)
password = data.pop("password", None)
groups = data.pop("groups", [])
if not password:
raise ValueError("Invalid user data: 'password' key is required to " "reactivate user")
if activate:
users.add(username, login, password, groups, encrypted=True)
if security_state != getattr(profile, "security_state", None):
workflow = get_workflow(IProfile, "security", profile)
workflow.transition_to_state(profile, None, security_state)
if security_state == "inactive":
log.info("Deactivated user: %s", username)
if data:
raise ValueError("Unrecognized keys in sync data for user: %s: %s" % (username, data.keys()))
开发者ID:araymund,项目名称:karl,代码行数:58,代码来源:usersync.py
示例18: proposal_states_widget
def proposal_states_widget(node, kw):
wf = get_workflow(IProposal, 'Proposal')
state_values = []
ts = _
for info in wf._state_info(IProposal): # Public API goes through permission checker
item = [info['name']]
item.append(ts(info['title']))
state_values.append(item)
return deform.widget.CheckboxChoiceWidget(values=state_values)
开发者ID:VoteIT,项目名称:voteit.core,代码行数:9,代码来源:proposal.py
示例19: workflow
def workflow(self):
try:
self.content_type
except AttributeError:
raise WorkflowError("context doesn't have content_type attribute set")
for iface in self.__class__.__implemented__.interfaces():
wf = get_workflow(iface, self.content_type, self)
if wf is not None:
return wf
raise WorkflowError("Workflow not found for %s" % self)
开发者ID:VoteIT,项目名称:voteit.core,代码行数:11,代码来源:workflow_aware.py
示例20: add_sample_users
def add_sample_users(site):
profiles = site['profiles']
users = site.users
for login, firstname, lastname, email, groups in [
('staff1','Staff','One','[email protected]',
('group.KarlStaff',)),
('staff2','Staff','Two','[email protected]',
('group.KarlStaff',)),
('staff3','Staff','Three','[email protected]',
('group.KarlStaff',)),
('staff4','Staff','Four','[email protected]',
('group.KarlStaff',)),
('staff5','Staff','Five','[email protected]',
('group.KarlStaff',)),
('staff6','Staff','Six','[email protected]',
('group.KarlStaff',)),
('staff7','Staff','Seven','[email protected]',
('group.KarlStaff',)),
('staff8','Staff','Eight','[email protected]',
('group.KarlStaff',)),
('staff9','Staff','Nine','[email protected]',
('group.KarlStaff',)),
('affiliate1','Affiliate','One','[email protected]',
('groups.KarlAffiliate',)),
('affiliate2','Affiliate','Two','[email protected]',
('groups.KarlAffiliate',)),
('affiliate3','Affiliate','Three','[email protected]',
('groups.KarlAffiliate',)),
('affiliate4','Affiliate','Four','[email protected]',
('groups.KarlAffiliate',)),
('affiliate5','Affiliate','Five','[email protected]',
('groups.KarlAffiliate',)),
('affiliate6','Affiliate','Six','[email protected]',
('groups.KarlAffiliate',)),
('affiliate7','Affiliate','Seven','[email protected]',
('groups.KarlAffiliate',)),
('affiliate8','Affiliate','Eight','[email protected]',
('groups.KarlAffiliate',)),
('affiliate9','Affiliate','Nine','[email protected]',
('groups.KarlAffiliate',)),
]:
if users.get(login=login) is None:
users.add(login, login, login, groups)
if not login in profiles:
profile = profiles[login] = create_content(
IProfile,
firstname=firstname,
lastname=lastname,
email=email,
)
workflow = get_workflow(IProfile, 'security', profiles)
if workflow is not None:
workflow.initialize(profile)
开发者ID:lslaz1,项目名称:karl,代码行数:54,代码来源:samplegen.py
注:本文中的repoze.workflow.get_workflow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论