• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python base.transaction_commit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qon.base.transaction_commit函数的典型用法代码示例。如果您正苦于以下问题:Python transaction_commit函数的具体用法?Python transaction_commit怎么用?Python transaction_commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了transaction_commit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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)
开发者ID:mrmaple,项目名称:open_qon,代码行数:34,代码来源:api.py


示例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)
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:26,代码来源:api.py


示例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()
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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)
                )
            )
开发者ID:mrmaple,项目名称:open_qon,代码行数:31,代码来源:api.py


示例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)    
开发者ID:mrmaple,项目名称:open_qon,代码行数:32,代码来源:api.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:34,代码来源:api.py


示例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)
开发者ID:mrmaple,项目名称:open_qon,代码行数:7,代码来源:api.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:populate_parent_blogitem_for_comments.py


示例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()
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:wiki.py


示例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()
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:wiki.py


示例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
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:populate_parent_blogitem_for_comments.py


示例16: update_stats

def update_stats():
    """Update the expensive site-wide stats."""
    list_db = get_list_database()

    list_db.group_stats_force_update()
    transaction_commit(None, 'GroupStatsUpdate')

    list_db.user_stats_force_update()
    transaction_commit(None, 'UserStatsUpdate')
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:cron-hourly.py


示例17: upgrade_cap_subpoints

def upgrade_cap_subpoints():
    """Remove pending subpoints from users whose banks are capped."""
    from qon.base import get_user_database, transaction_commit
    
    for user_id, user in get_user_database().root.iteritems():
        if user.bank_is_capped():
            if user._HasKarmaBank__subpoints > 0:
                user._HasKarmaBank__subpoints = 0
                transaction_commit(None, 'UpgradeCapSubpoints')
开发者ID:mrmaple,项目名称:open_qon,代码行数:9,代码来源:karma.py


示例18: upgrade_inbound_refs

def upgrade_inbound_refs():
    """Recreate all pages' inbound_references."""
    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():
            refs = g.wiki.references_to(p)
        transaction_commit()
        print g.get_user_id()
开发者ID:mrmaple,项目名称:open_qon,代码行数:10,代码来源:wiki.py


示例19: upgrade_invalidate_outbound_refs

def upgrade_invalidate_outbound_refs():
    """Invalidate all outbound references due to type change."""
    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.outbound_references = None
            p.invalidate_html_cache()
        transaction_commit()
开发者ID:mrmaple,项目名称:open_qon,代码行数:10,代码来源:wiki.py


示例20: karma_give_good

def karma_give_good(fr, to, message=None, message_anon=True, karma=qon.karma.HasKarma.good_karma):
    message = _unicode_fix(message)
    
    if to.can_get_karma_from(fr):
        try:
            fr.give_karma(to, karma)
            _karma_send_message(fr, to, 'positive', '+%d' % karma, message, message_anon)
            transaction_commit(fr, 'KarmaGiveGood')
            qon.search.searchengine.notify_karma_given(to)
        except qon.karma.NoKarmaToGive:
            pass
开发者ID:mrmaple,项目名称:open_qon,代码行数:11,代码来源:api.py



注:本文中的qon.base.transaction_commit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python timeutils.parse_isotime函数代码示例发布时间:2022-05-26
下一篇:
Python node.getNode函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap