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

Python app_globals.post_event函数代码示例

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

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



在下文中一共展示了post_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _update_mounts

 def _update_mounts(self, subproject=None, tool=None, new=None, **kw):
     if subproject is None:
         subproject = []
     if tool is None:
         tool = []
     for sp in subproject:
         p = M.Project.query.get(shortname=sp['shortname'],
                                 neighborhood_id=c.project.neighborhood_id)
         if sp.get('delete'):
             require_access(c.project, 'admin')
             M.AuditLog.log('delete subproject %s', sp['shortname'])
             h.log_action(log, 'delete subproject').info(
                 'delete subproject %s', sp['shortname'],
                 meta=dict(name=sp['shortname']))
             p.removal = 'deleted'
             plugin.ProjectRegistrationProvider.get().delete_project(
                 p, c.user)
         elif not new:
             M.AuditLog.log('update subproject %s', sp['shortname'])
             p.name = sp['name']
             p.ordinal = int(sp['ordinal'])
     for p in tool:
         if p.get('delete'):
             require_access(c.project, 'admin')
             M.AuditLog.log('uninstall tool %s', p['mount_point'])
             h.log_action(log, 'uninstall tool').info(
                 'uninstall tool %s', p['mount_point'],
                 meta=dict(mount_point=p['mount_point']))
             c.project.uninstall_app(p['mount_point'])
         elif not new:
             M.AuditLog.log('update tool %s', p['mount_point'])
             options = c.project.app_config(p['mount_point']).options
             options.mount_label = p['mount_label']
             options.ordinal = int(p['ordinal'])
     if new and new.get('install'):
         ep_name = new.get('ep_name', None)
         if not ep_name:
             require_access(c.project, 'create')
             mount_point = new['mount_point'].lower() or h.nonce()
             M.AuditLog.log('create subproject %s', mount_point)
             h.log_action(log, 'create subproject').info(
                 'create subproject %s', mount_point,
                 meta=dict(mount_point=mount_point, name=new['mount_label']))
             sp = c.project.new_subproject(mount_point)
             sp.name = new['mount_label']
             sp.ordinal = int(new['ordinal'])
         else:
             require_access(c.project, 'admin')
             installable_tools = AdminApp.installable_tools_for(c.project)
             if not ep_name.lower() in [t['name'].lower() for t in installable_tools]:
                 flash('Installation limit exceeded.', 'error')
                 return
             mount_point = new['mount_point'] or ep_name
             M.AuditLog.log('install tool %s', mount_point)
             h.log_action(log, 'install tool').info(
                 'install tool %s', mount_point,
                 meta=dict(tool_type=ep_name, mount_point=mount_point, mount_label=new['mount_label']))
             c.project.install_app(
                 ep_name, mount_point, mount_label=new['mount_label'], ordinal=new['ordinal'])
     g.post_event('project_updated')
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:60,代码来源:admin_main.py


示例2: edit_screenshot

 def edit_screenshot(self, id=None, caption=None, **kw):
     require_access(c.project, 'update')
     if id is not None and id != '':
         M.ProjectFile.query.get(
             project_id=c.project._id, _id=ObjectId(id)).caption = caption
         g.post_event('project_updated')
     redirect('screenshots')
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:7,代码来源:admin_main.py


示例3: update

 def update(self, card=None, **kw):
     permissions = self._index_permissions()
     old_permissions = dict(permissions)
     for args in card:
         perm = args['id']
         new_group_ids = args.get('new', [])
         group_ids = args.get('value', [])
         if isinstance(new_group_ids, basestring):
             new_group_ids = [ new_group_ids ]
         if isinstance(group_ids, basestring):
             group_ids = [ group_ids ]
         # make sure the admin group has the admin permission
         if perm == 'admin':
             if c.project.is_root:
                 pid = c.project._id
             else:
                 pid = c.project.parent_id
             admin_group_id = str(M.ProjectRole.query.get(project_id=pid, name='Admin')._id)
             if admin_group_id not in group_ids + new_group_ids:
                 flash('You cannot remove the admin group from the admin permission.','warning')
                 group_ids.append(admin_group_id)
         permissions[perm] = []
         role_ids = map(ObjectId, group_ids + new_group_ids)
         permissions[perm] = role_ids
     c.project.acl = []
     for perm, role_ids in permissions.iteritems():
         role_names = lambda ids: ','.join(sorted(
                 pr.name for pr in M.ProjectRole.query.find(dict(_id={'$in':ids}))))
         old_role_ids = old_permissions.get(perm, [])
         if old_role_ids != role_ids:
             M.AuditLog.log('updated "%s" permissions: "%s" => "%s"',
                            perm,role_names(old_role_ids), role_names(role_ids))
         c.project.acl += [M.ACE.allow(rid, perm) for rid in role_ids]
     g.post_event('project_updated')
     redirect('.')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:35,代码来源:admin_main.py


示例4: delete_screenshot

 def delete_screenshot(self, id=None, **kw):
     require_access(c.project, 'update')
     if id is not None and id != '':
         M.AuditLog.log('remove screenshot')
         M.ProjectFile.query.remove(dict(project_id=c.project._id, _id=ObjectId(id)))
         g.post_event('project_updated')
     redirect('screenshots')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:7,代码来源:admin_main.py


示例5: import_tool

    def import_tool(self, project, user, project_name=None, mount_point=None,
                    mount_label=None, **kw):
        """ Import a Google Code repo into a new SVN, Git, or Hg Allura tool.

        """
        extractor = GoogleCodeProjectExtractor(project_name, 'source_browse')
        repo_type = extractor.get_repo_type()
        repo_url = get_repo_url(project_name, repo_type)
        app = project.install_app(
            REPO_ENTRY_POINTS[repo_type],
            mount_point=mount_point or 'code',
            mount_label=mount_label or 'Code',
            init_from_url=repo_url,
            import_id={
                'source': self.source,
                'project_name': project_name,
            }
        )
        M.AuditLog.log(
            'import tool %s from %s on %s' % (
                app.config.options.mount_point,
                project_name, self.source,
            ), project=project, user=user, url=app.url)
        g.post_event('project_updated')
        return app
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:25,代码来源:code.py


示例6: import_project_info

def import_project_info(project_name):
    extractor = GoogleCodeProjectExtractor(project_name, 'project_info')
    extractor.get_short_description(c.project)
    extractor.get_icon(c.project)
    extractor.get_license(c.project)
    ThreadLocalORMSession.flush_all()
    g.post_event('project_updated')
开发者ID:pombredanne,项目名称:incubator-allura,代码行数:7,代码来源:tasks.py


示例7: import_tool

    def import_tool(
            self, project, user, project_name=None, mount_point=None,
            mount_label=None, user_name=None, tool_option=None, **kw):
        """ Import a GitHub wiki into a new Wiki Allura tool.

        """
        project_name = "%s/%s" % (user_name, project_name)
        extractor = GitHubProjectExtractor(project_name, user=user)
        wiki_avail = extractor.has_wiki()
        if not wiki_avail:
            return

        self.github_wiki_url = extractor.get_page_url(
            'wiki_url').replace('.wiki', '/wiki')
        self.app = project.install_app(
            "Wiki",
            mount_point=mount_point or 'wiki',
            mount_label=mount_label or 'Wiki',
            import_id={
                'source': self.source,
                'project_name': project_name,
            }
        )
        with_history = tool_option == 'import_history'
        ThreadLocalORMSession.flush_all()
        self.github_markdown_converter = GitHubMarkdownConverter(
            user_name, project_name)
        try:
            M.session.artifact_orm_session._get().skip_mod_date = True
            with h.push_config(c, app=self.app):
                try:
                    wiki_url = extractor.get_page_url('wiki_url')
                    self.import_pages(wiki_url, history=with_history)
                except git.GitCommandError:
                    log.error(
                        'Unable to clone GitHub wiki: '
                        'wiki_url=%s; '
                        'wiki_avail=%s; '
                        'avail_url=%s',
                        wiki_url, wiki_avail,
                        extractor.get_page_url('project_info'),
                        exc_info=True)
                    raise
            ThreadLocalORMSession.flush_all()
            M.AuditLog.log(
                'import tool %s from %s on %s' % (
                    self.app.config.options.mount_point,
                    project_name,
                    self.source),
                project=project,
                user=user,
                url=self.app.url)
            g.post_event('project_updated')
            return self.app
        except Exception:
            h.make_app_admin_only(self.app)
            raise
        finally:
            M.session.artifact_orm_session._get().skip_mod_date = False
开发者ID:apache,项目名称:incubator-allura,代码行数:59,代码来源:wiki.py


示例8: create

 def create(self, name=None, **kw):
     if M.ProjectRole.by_name(name):
         flash('%s already exists' % name, 'error')
     else:
         M.ProjectRole(project_id=c.project._id, name=name)
     M.AuditLog.log('create group %s', name)
     g.post_event('project_updated')
     redirect('.')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:8,代码来源:admin_main.py


示例9: update_label

    def update_label(self, mount_label):
        """Handles POST to update the Application's ``mount_label``.

        """
        require_access(self.app, "configure")
        self.app.config.options["mount_label"] = mount_label
        g.post_event("project_menu_updated")
        redirect(request.referer)
开发者ID:joequant,项目名称:allura,代码行数:8,代码来源:app.py


示例10: import_project_info

def import_project_info(project_name):
    from forgeimporters.github.project import GitHubProjectImporter
    importer = GitHubProjectImporter(None)
    with ImportErrorHandler(importer, project_name, c.project) as handler:
        extractor = GitHubProjectExtractor(project_name, user=c.user)
        c.project.summary = extractor.get_summary()
        c.project.external_homepage = extractor.get_homepage()
        ThreadLocalORMSession.flush_all()
        g.post_event('project_updated')
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:9,代码来源:tasks.py


示例11: init_as_clone

 def init_as_clone(self, source_path, source_name, source_url):
     self.upstream_repo.name = source_name
     self.upstream_repo.url = source_url
     session(self).flush(self)
     source = source_path if source_path else source_url
     self._impl.clone_from(source)
     log.info('... %r cloned', self)
     g.post_event('repo_cloned', source_url, source_path)
     self.refresh(notify=False, new_clone=True)
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:9,代码来源:repository.py


示例12: __exit__

 def __exit__(self, exc_type, exc_val, exc_tb):
     self.importer.clear_pending(self.project)
     if exc_type:
         g.post_event('import_tool_task_failed',
             error=str(exc_val),
             traceback=traceback.format_exc(),
             importer_source=self.importer.source,
             importer_tool_label=self.importer.tool_label,
             project_name=self.project_name,
             )
开发者ID:pombredanne,项目名称:incubator-allura,代码行数:10,代码来源:base.py


示例13: delete_group

 def delete_group(self, group_name, **kw):
     role = M.ProjectRole.by_name(group_name)
     if not role:
         flash('Group "%s" does not exist.' % group_name, 'error')
     else:
         role.delete()
         M.AuditLog.log('delete group %s', group_name)
         flash('Group "%s" deleted successfully.' % group_name)
         g.post_event('project_updated')
     redirect('.')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:10,代码来源:admin_main.py


示例14: delete_trove

 def delete_trove(self, type, trove, **kw):
     require_access(c.project, 'update')
     trove_obj = M.TroveCategory.query.get(trove_cat_id=int(trove))
     current_troves = getattr(c.project,'trove_%s'%type)
     if trove_obj is not None and trove_obj._id in current_troves:
         M.AuditLog.log('remove trove %s: %s', type, trove_obj.fullpath)
         current_troves.remove(trove_obj._id)
         ThreadLocalORMSession.flush_all()  # just in case the event handling is super fast
         g.post_event('project_updated')
     redirect('trove')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:10,代码来源:admin_main.py


示例15: delete

 def delete(self):
     require_access(self.neighborhood, 'admin')
     if self.award:
         grants = M.AwardGrant.query.find(dict(award_id=self.award._id))
         for grant in grants:
             grant.delete()
             with h.push_context(grant.granted_to_project_id):
                 g.post_event('project_updated')
         M.AwardFile.query.remove(dict(award_id=self.award._id))
         self.award.delete()
     redirect(request.referer)
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:11,代码来源:project.py


示例16: change_perm

 def change_perm(self, role_id, permission, allow="true", **kw):
     if allow=="true":
         M.AuditLog.log('granted permission %s to group %s', permission, M.ProjectRole.query.get(_id=ObjectId(role_id)).name)
         c.project.acl.append(M.ACE.allow(ObjectId(role_id), permission))
     else:
         admin_group_id = str(M.ProjectRole.by_name('Admin')._id)
         if admin_group_id == role_id and permission == 'admin':
             return dict(error='You cannot remove the admin permission from the admin group.')
         M.AuditLog.log('revoked permission %s from group %s', permission, M.ProjectRole.query.get(_id=ObjectId(role_id)).name)
         c.project.acl.remove(M.ACE.allow(ObjectId(role_id), permission))
     g.post_event('project_updated')
     return self._map_group_permissions()
开发者ID:johnsca,项目名称:incubator-allura,代码行数:12,代码来源:admin_main.py


示例17: sort_screenshots

    def sort_screenshots(self, **kw):
        """Sort project screenshots.

        Called via ajax when screenshots are reordered via drag/drop on
        the Screenshots admin page.

        ``kw`` is a mapping of (screenshot._id, sort_order) pairs.

        """
        for s in c.project.get_screenshots():
            if str(s._id) in kw:
                s.sort = int(kw[str(s._id)])
        g.post_event('project_updated')
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:13,代码来源:admin_main.py


示例18: clone

def clone(cloned_from_path, cloned_from_name, cloned_from_url):
    from allura import model as M

    try:
        c.app.repo.init_as_clone(cloned_from_path, cloned_from_name, cloned_from_url)
        M.Notification.post_user(
            c.user,
            c.app.repo,
            "created",
            text="Repository %s/%s created" % (c.project.shortname, c.app.config.options.mount_point),
        )
    except Exception, e:
        g.post_event("repo_clone_task_failed", cloned_from_url, cloned_from_path, traceback.format_exc())
开发者ID:johnsca,项目名称:incubator-allura,代码行数:13,代码来源:repo_tasks.py


示例19: add_screenshot

 def add_screenshot(self, screenshot=None, caption=None, **kw):
     require_access(c.project, 'update')
     if len(c.project.get_screenshots()) >= 6:
         flash('You may not have more than 6 screenshots per project.','error')
     elif screenshot is not None and screenshot != '':
         M.AuditLog.log('add screenshot')
         M.ProjectFile.save_image(
             screenshot.filename, screenshot.file, content_type=screenshot.type,
             save_original=True,
             original_meta=dict(project_id=c.project._id,category='screenshot',caption=caption),
             square=True, thumbnail_size=(150,150),
             thumbnail_meta=dict(project_id=c.project._id,category='screenshot_thumb'))
         g.post_event('project_updated')
     redirect('screenshots')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:14,代码来源:admin_main.py


示例20: import_tool

 def import_tool(self, project, user, project_name, mount_point=None,
                 mount_label=None, **kw):
     import_id_converter = ImportIdConverter.get()
     project_name = '%s/%s' % (kw['user_name'], project_name)
     extractor = GitHubProjectExtractor(project_name, user=user)
     if not extractor.has_tracker():
         return
     app = project.install_app('tickets', mount_point, mount_label,
                               EnableVoting=False,
                               open_status_names='open',
                               closed_status_names='closed',
                               import_id={
                                   'source': self.source,
                                   'project_name': project_name,
                               }
                               )
     self.github_markdown_converter = GitHubMarkdownConverter(
         kw['user_name'], project_name)
     ThreadLocalORMSession.flush_all()
     try:
         M.session.artifact_orm_session._get().skip_mod_date = True
         with h.push_config(c, user=M.User.anonymous(), app=app):
             for ticket_num, issue in extractor.iter_issues():
                 self.max_ticket_num = max(ticket_num, self.max_ticket_num)
                 ticket = TM.Ticket(
                     app_config_id=app.config._id,
                     custom_fields=dict(),
                     ticket_num=ticket_num,
                     import_id=import_id_converter.expand(ticket_num, app)
                 )
                 self.process_fields(extractor, ticket, issue)
                 self.process_comments(extractor, ticket, issue)
                 self.process_events(extractor, ticket, issue)
                 self.process_milestones(ticket, issue)
                 session(ticket).flush(ticket)
                 session(ticket).expunge(ticket)
             app.globals.custom_fields = self.postprocess_milestones()
             app.globals.last_ticket_num = self.max_ticket_num
             ThreadLocalORMSession.flush_all()
         M.AuditLog.log(
             'import tool %s from %s on %s' % (
                 app.config.options.mount_point,
                 project_name, self.source),
             project=project, user=user, url=app.url)
         g.post_event('project_updated')
         app.globals.invalidate_bin_counts()
         return app
     finally:
         M.session.artifact_orm_session._get().skip_mod_date = False
开发者ID:abhinavthomas,项目名称:allura,代码行数:49,代码来源:tracker.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cache.get_cache函数代码示例发布时间:2022-05-25
下一篇:
Python app_globals.make_lock函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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