本文整理汇总了Python中qon.base.transaction_commit函数的典型用法代码示例。如果您正苦于以下问题:Python transaction_commit函数的具体用法?Python transaction_commit怎么用?Python transaction_commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了transaction_commit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: group_set_settings
def group_set_settings(user, group, **kwargs):
if not group_can_manage(user, group):
raise AccessError
_set_attributes(group, **kwargs)
transaction_commit(None, 'GroupSetSettings') # moved from group/form.ptl/SettingsForm.commit()
qon.search.searchengine.notify_edited_group(group)
示例2: user_new
def user_new(email):
# create user and get the initial password in plaintext.
email = _unicode_fix(email)
user, password = get_user_database().new_user_from_email(email)
transaction_commit(None, 'NewUser') # moved from user.ptl/NewUserForm.commit()
# send email
e = url_quote(email)
p = url_quote(password)
s = url_quote("Sign in")
message = _(_new_user_message) % dict(email=email,
password=password,
auto_login_url=messages.login_url + "?email=" + e + "&password=" + p + "&submit-login=" + s + "&from_url=Y")
extra_headers = ['Content-Type: text/html'] # because of the href
sendmail("Welcome to ned.com", message, [email], extra_headers=extra_headers)
# send pm using _live_tmpl_pm_new_user in sitedev as the template
template_text = qon.util.get_page_template('pm_new_user', format='text')
if template_text:
message_anon_send(user, "Welcome to ned.com!", template_text, True)
# add orientation page to all new users' watch lists
try:
orientation = get_group_database()['help'].get_wiki().pages['start_here']
user.get_watch_list().watch_item(orientation)
except:
pass
qon.search.searchengine.notify_new_user(user)
return (email, message)
示例3: user_delete
def user_delete(user):
"""Deletes a user object from the ZODB and the Search DB. Does not attempt to
find items authored by the user and delete those too.
"""
get_user_database().remove_user(user.get_user_id())
transaction_commit(None, 'AdminDeleteUser') # moved from admin.ptl/DeleteUserForm.commit()
qon.search.searchengine.notify_deleted_user(user)
示例4: user_set_settings
def user_set_settings(user, **kwargs):
"""Set user profile:
name Full name
bio about-me text
anon_blog 'yes' if anon users can read personal news
email_notify 'yes' if user should receive e-mail notices of incoming messages
"""
user.set_contact_name(_unicode_fix(kwargs['name']))
user.bio = _unicode_fix(kwargs['bio'])
user.location = _unicode_fix(kwargs['location'])
user.latitude = kwargs['latitude']
user.longitude = kwargs['longitude']
user.deliciousID = kwargs['deliciousID']
user.flickrID = kwargs['flickrID']
user.skypeID = kwargs['skypeID']
user.blogURL = kwargs['blogURL']
user.get_user_data().set_anon_can_read_blog(kwargs['anon_blog'] == 'yes')
user.set_email_notify(kwargs['email_notify'] == 'yes')
user.set_copy_self(kwargs['copy_self'] == 'yes')
transaction_commit(user, 'UserPrefs') # moved from user.ptl/UserPrefsForm.commit()
qon.search.searchengine.notify_edited_user(user)
get_observe_database().notify_changed(user) # FIXME this should be in user.py somewhere
示例5: user_set_disabled
def user_set_disabled(user, disabled):
user.set_disabled(disabled)
if disabled:
note = 'AdminDisableUser'
else:
note = 'AdminEnableUser'
transaction_commit(None, note) # moved from admin.ptl/UserUI.enable() & admin.ptl/DisableUserForm.commit()
示例6: group_invite_user
def group_invite_user(user, group, email, inviter):
"""Invite email to join group. May raise smtplib.SMTPRecipientsRefused if server
rejects email.
"""
if not group.is_accepted() or not group.get_members().can_manage(user):
raise AccessError
group.add_invitation(email, inviter)
transaction_commit(inviter, 'InviteToGroup') # moved from group/form.ptl/InviteForm.commit()
try:
user = get_user_database().get_user_by_email(email)
except KeyError:
# e-mail address is not registered, send an e-mail (rather than internal message)
subject=_(_email_invite_subject) % dict(group_name=group.name)
body=_(_email_invite_body) % dict(email=email,
home_url=messages.home_url,
inviter=qon.ui.blocks.user.display_name_plain(inviter),
group_name=qon.ui.blocks.group.display_name_plain(group))
sendmail(subject, body, [email])
else:
message_send(inviter, user,
subject=_(_message_invite_subject) % dict(group_name=group.name),
body=_(_message_invite_body) % dict(
email=email,
inviter=qon.ui.blocks.user.display_name_plain(inviter),
group_name=qon.ui.blocks.group.display_name_plain(group)
)
)
示例7: message_send
def message_send(fr, to, subject, body, suppress_email=False, copy_self=False):
"""Send a message to one or more recipients."""
subject = _unicode_fix(subject)
body = _unicode_fix(body)
if type(to) is not list:
to = [to]
# only send messages to users
to = [recipient for recipient in to if type(recipient) is User]
for recipient in to:
msg = message.Message(sender=fr, subject=subject, body=body)
recipient.add_message(msg)
#qon.log.admin_info('added message for %s' % qon.ui.blocks.util.display_name_plain(recipient))
# log the activity
fr.get_user_data().get_activity().new_pm_sent()
# let's commit here so that if the commit fails, we won't accidentally
# send out an email notice with the wrong msg # in the URL
transaction_commit(None, 'NewMessage')
# email notification
if (not suppress_email):
for recipient in to:
if recipient.email_notify():
message_email(recipient, msg)
# email notification to self
if (not suppress_email) and copy_self:
message_email_copy_self(fr, to, msg)
示例8: ticket_new_item
def ticket_new_item(tracker, user, title, category, priority, text):
title = _unicode_fix(title)
text = _unicode_fix(text)
t = tracker.new_ticket(user, title, category, priority, text)
transaction_commit(user, 'NewTicket') # moved from ticket.ptl/NewTicketForm.commit()
return t
示例9: wiki_new_page_like
def wiki_new_page_like(wiki, page, author):
np = wiki.new_page(wiki.get_unique_name(page))
np.versions[-1].set_raw('<include %s latest>\n' % page.name)
np.versions[-1].set_author(author)
transaction_commit(None, 'NewLikeWikiPage') # moved from wiki/wiki.ptl/WikiPageUI.newlike()
qon.search.searchengine.notify_new_wiki_page(np)
return np
示例10: poll_create_custom
def poll_create_custom(polls, creator, title, description, end_date, choices, custom):
title = _unicode_fix(title)
description = _unicode_fix(description)
choices = [_unicode_fix(x) for x in choices]
"""Create a custom poll. custom is a dict with the following keys:
min_choice
max_choice
vote_access
results_access
intermediate_access
vote_required_to_view
voter_can_revise
display_voters
min_karma
karma_cost
Raises KeyError if custom contains keys not recognized by PollData.
"""
poll = qon.poll.Poll(creator=creator,
title=title,
description=description,
end_date=end_date,
choices=choices)
# set custom settings
poll.get_data().set_extended_data(custom)
poll = polls.add_poll(poll)
transaction_commit(None, 'PollCreateCustom')
qon.search.searchengine.notify_new_poll(poll)
return poll
示例11: user_delete_email
def user_delete_email(user, email):
"""Delete a confirmed or unconfirmed e-mail. Raise KeyError if attempt to delete last e-mail.
Raise ValueError if email is not in user's email list.
"""
get_user_database().remove_user_email(user, email)
transaction_commit(user, 'UserDeleteEmail') # moved from user.ptl/UserDeleteEmailForm.commit()
qon.search.searchengine.notify_edited_user(user)
示例12: do_all_user_blogitems
def do_all_user_blogitems():
""" iterate through each user and index each news item """
i = 1
for userid, user in db.user_db.root.items():
for bi in user.get_blog().get_items():
print "%s) %s BlogItem: %s" % (i, userid, bi.title)
bi.populate_parent_blogitem_for_comments()
transaction_commit()
i+=1
示例13: upgrade_invalidate_html_caches
def upgrade_invalidate_html_caches():
"""Invalidate all HTML caches"""
from base import get_group_database
group_db = get_group_database()
for g in group_db.root.values():
for p in g.wiki.pages.values():
p.invalidate_html_cache()
transaction_commit()
示例14: upgrade_refresh_html_caches
def upgrade_refresh_html_caches():
"""Refresh all html caches."""
from base import get_group_database
group_db = get_group_database()
for g in group_db.root.values():
for p in g.wiki.pages.values():
html = p.get_cached_html()
transaction_commit()
示例15: do_all_group_blogitems
def do_all_group_blogitems():
""" iterate through each group and index each discussion topic """
i = 1
for groupid, group in db.group_db.root.items():
for bi in group.get_blog().get_items():
print "%s) %s BlogItem: %s" % (i, groupid, bi.title)
bi.populate_parent_blogitem_for_comments()
transaction_commit()
i+=1