当前位置: 首页>>代码示例>>Python>>正文


Python app_globals.post_event函数代码示例

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


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


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