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


Python chrome.add_warning函数代码示例

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


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

示例1: _reject_oauth

 def _reject_oauth(self, req, exc, reason=None):
     self.log.warn("An OAuth authorization attempt was rejected due to an "
                   "exception: %s\n%s", exc, traceback.format_exc())
     if reason is None:
         reason = _("Invalid request. Please try to login again.")
     add_warning(req, reason)
     self._redirect_back(req)
开发者ID:trac-hacks,项目名称:trac-github,代码行数:7,代码来源:__init__.py

示例2: commit

    def commit(self, req):
        """Perform the operation for all processed rows. Return a list of new 
        or changed tickets"""
        tickets = []

        if not self.do_preview:
            for fields in self.rows:
                ticket = self._get_ticket_from_id_in_csv(req, fields)
                if ticket == None:
                    continue
                ticket_type = self._get_type_for_ticket(fields)
                if not self._may_create_ticket(req.perm, ticket_type):
                    add_warning(req, _("No permission to create a %s.") % ticket_type)
                    continue

                if not self.force:
                    csv_summary = fields[Key.SUMMARY]
                    db_summary = ticket[Key.SUMMARY]
                    if csv_summary != db_summary:
                        msg = _("Ticket %d has a different summary: '%s' (CSV) - '%s' (DB)")
                        add_warning(req, msg % (ticket.id, repr(csv_summary), repr(db_summary)))
                        continue
                tickets.append(ticket)
                ticket.delete()
        return tickets
开发者ID:nagyist,项目名称:agilo,代码行数:25,代码来源:delete_performer.py

示例3: render_preference_panel

    def render_preference_panel(self, req, panel):
        """ Renders preference panel and handles information change on POST
        """
        if req.authname == 'anonymous':
            raise TracError("User is not authenticated", "No access")

        data = {}
        key_store = CQDESshKeyStore.instance()
        user = get_userstore().getUser(req.authname)

        if req.method == 'POST':
            ssh_key = req.args.get('ssh_key')
            delete_key = req.args.get('deletelist')

            if ssh_key:
                user = self._do_save(req, user)
            elif delete_key:
                user = self._do_deletes(req, user)
            else:
                add_warning(req, _('Please provide data'))

        keys = key_store.get_ssh_keys_by_user_id(user.id)
        data['keys'] = keys if keys else None

        # This is to prevent adding of more than one ssh password.
        # Remove this if we support more in the future.
        if keys:
            data['hide_add_dialog'] = False

        data['domain'] = conf.domain_name
        data['user'] = user

        return 'multiproject_user_prefs_ssh_keys.html', data
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:33,代码来源:preferences.py

示例4: pre_process_request

    def pre_process_request(self, req, handler):
        if isinstance(handler, RegistrationModule):
            if not (self.private_key or self.private_key):
                self.log.warning('public_key and private_key under [recaptcha] are '
                                 'not configured. Not showing the reCAPTCHA form!')
                return handler
            self.check_config()
            if req.method == 'POST' and req.args.get('action') == 'create':
                response = captcha.submit(
                    req.args.get('recaptcha_challenge_field'),
                    req.args.get('recaptcha_response_field'),
                    self.private_key, req.remote_addr,
                )
                if not response.is_valid:
                    add_warning(req, 'reCAPTCHA incorrect. Please try again.')
                    req.environ['REQUEST_METHOD'] = 'GET'
                    req.args.pop('password', None)
                    req.args.pop('password_confirm', None)

        # Admin Configuration
        if req.path_info.startswith('/admin/accounts/config') and \
            req.method == 'POST':
            self.config.set('recaptcha', 'lang', req.args.get('recaptcha_lang'))
            self.config.set('recaptcha', 'public_key',
                            req.args.get('recaptcha_public_key'))
            self.config.set('recaptcha', 'private_key',
                            req.args.get('recaptcha_private_key'))
            self.config.set('recaptcha', 'theme',
                            req.args.get('recaptcha_theme'))
            self.config.save()
        return handler
开发者ID:scanterog,项目名称:trac-recaptcharegister,代码行数:31,代码来源:web_ui.py

示例5: setkeys

 def setkeys(self, req, keys):
     if req.authname == 'anonymous':
         raise TracError('cannot set ssh keys for anonymous users')
     keys = set(keys)
     if len(keys) > 0x100:
         add_warning(req, 'We only support using your first 256 ssh keys.')
     return self._setkeys(req.authname, keys)
开发者ID:sagemath,项目名称:sage_trac_plugin,代码行数:7,代码来源:sshkeys.py

示例6: _process_changes

    def _process_changes(self, req, protos, scm_type):
        scm_protos = dav_protos = set([])

        allowed_scm_schemes = protos.allowed_protocols(scm_type)
        allowed_dav_schemes = protos.allowed_protocols('dav')

        if 'scm_proto' in req.args:
            scm_protos = set(self._to_list(req.args['scm_proto']))
        if 'dav_proto' in req.args:
            dav_protos = set(self._to_list(req.args['dav_proto']))

        if not self._validate(scm_protos, dav_protos):
            msg = 'Changes not stored, make sure that at least one protocol for each ' \
                  'section is selected. If you want to disable any section, configure ' \
                  'the appropriate permissions in the "Groups" page'
            add_warning(req, msg)
            return

        try:
            # Change scm protocols
            protos.disallow_protocols(allowed_scm_schemes - scm_protos, scm_type)
            protos.allow_protocols(scm_protos - allowed_scm_schemes, scm_type)

            # Change dav protocols
            protos.disallow_protocols(allowed_dav_schemes - dav_protos, 'dav')
            protos.allow_protocols(dav_protos - allowed_dav_schemes, 'dav')
        except:
            raise TracError("Server error. Try again later.")

        add_notice(req, "Changes saved")
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:30,代码来源:protocols.py

示例7: render_admin_panel

    def render_admin_panel(self, req, cat, page, version):
        self.log.debug("cat: %s page: %s", cat, page)
        req.perm.require('TRAC_ADMIN')

        options = (
            'api_base_url',
            'api_token',
            'room_id',
            'only_owner_changed',
            'notify_symbol',
            'api_token_field_name')

        self.log.debug("method: %s", req.method)
        if req.method == 'POST':
            for option in options:
                self.config.set(SECTION_NAME, option, req.args.get(option))

            try:
                self.config.save()
                self.log.debug('config saved.')
                add_notice(req, 'Your changes have been saved.')
            except Exception, e:
                self.log.error("Error writing to trac.ini: %s", exception_to_unicode(e))
                add_warning(req, 'Error writing to trac.ini.')

            req.redirect(req.href.admin(cat, page))
开发者ID:nyamairi,项目名称:TracToChatwork,代码行数:26,代码来源:admin_panel.py

示例8: _add_organization

    def _add_organization(self, req, group_store):
        req.perm.require("PERMISSION_GRANT")

        group_name = req.args.get("group")
        organization = req.args.get("organization")

        try:
            group_store.add_organization_to_group(organization, group_name)
            add_notice(
                req,
                _(
                    "Organization %(organization)s added to group %(group)s",
                    group=group_name,
                    organization=organization,
                ),
            )
        except ValueError:
            add_warning(
                req,
                _(
                    "Organization %(organization)s already exists in group %(group)s",
                    group=group_name,
                    organization=organization,
                ),
            )
开发者ID:juhamust,项目名称:multiproject,代码行数:25,代码来源:permissions.py

示例9: _add_ldap_group

    def _add_ldap_group(self, req, group_store):
        req.perm.require("PERMISSION_GRANT")

        group_name = req.args.get("group")
        ldap_group_name = req.args.get("ldap_group", "").strip()
        ldap_group_name = ldap_group_name.upper()

        if re.search(r"[^\_A-Z0-9]", ldap_group_name):  # allowed characters
            add_warning(req, "LDAP group name can contain only alphanumeric characters and underline.")
            return

        if not ldap_group_name:
            add_warning(
                req,
                _(
                    "You are trying to add an LDAP group to a user group, "
                    "but you have not specified all the required parameters."
                ),
            )
            return

        group_store.add_ldapgroup_to_group(ldap_group_name, group_name)
        add_notice(
            req, _("LDAP group %(who)s has been added to group %(where)s.", who=ldap_group_name, where=group_name)
        )
开发者ID:juhamust,项目名称:multiproject,代码行数:25,代码来源:permissions.py

示例10: post_new_artifact

def post_new_artifact(request, dbp, obj, resource):
    require_permission(request.req, resource, dbp.env, operation="CREATE")

    assert(obj is Instance or isinstance(obj, Entity)) # otherwise, we're trying to instantiate something that is not an artifact

    spec_name = request.req.args['spec']
    if spec_name:
        try:
            dbp.load_spec(spec_name)
            spec = dbp.pool.get_item(spec_name)
        except ValueError:
            add_warning(request.req, "Spec '%s' not found, assumed an empty spec instead." % spec_name)
            spec = Instance
    else:
        spec = Instance

    values, str_attr = _group_artifact_values(request.req)
    brand_new_inst = spec(str_attr=str_attr, values=values)

    dbp.pool.add(brand_new_inst)
    dbp.save(get_reporter_id(request.req), 'comment', request.req.remote_addr)

    if request.get_format() == 'page':
        add_notice(request.req, 'Your changes have been saved.')
        url = request.req.href.customartifacts('artifact/%d' % (brand_new_inst.get_id(),), action='view', format=request.get_format())
        request.req.redirect(url)
    else:
        import json
        url = request.req.href.customartifacts('artifact/%d' % (brand_new_inst.get_id(),), action='view')
        msg = json.dumps([{'result': 'success', 'resource_id': brand_new_inst.get_id(), 'resource_url': url}])
        request.req.send_response(200)
        request.req.send_header('Content-Type', 'application/json')
        request.req.send_header('Content-Length', len(msg))
        request.req.end_headers()
        request.req.write(msg)
开发者ID:filipefigcorreia,项目名称:TracAdaptiveSoftwareArtifacts,代码行数:35,代码来源:views.py

示例11: post_process_request

 def post_process_request(self, req, template, data, content_type):
     if (template, data) != (None, None) or \
             sys.exc_info() != (None, None, None):
         try:
             theme = self.system.theme
         except ThemeNotFound, e:
             add_warning(req, "Unknown theme %s configured. Please check "
                     "your trac.ini. You may need to enable "
                     "the theme\'s plugin." % e.theme_name)
         else:
             if theme and 'css' in theme:
                 add_stylesheet(req, 'theme/'+theme['css'])
             if theme and 'template' in theme:
                 req.chrome['theme'] = os.path.basename(theme['template'])
             if theme and theme.get('disable_trac_css'):
                 links = req.chrome.get('links')
                 if links and 'stylesheet' in links:
                     for i, link in enumerate(links['stylesheet']):
                         if link.get('href','') \
                                 .endswith('common/css/trac.css'):
                             del links['stylesheet'][i]
                             break
             if theme:
                 # Template overrides (since 2.2.0)
                 overrides = self._get_template_overrides(theme)
                 template, modifier = overrides.get(template, 
                                                    (template, None))
                 if modifier is not None:
                     modifier(req, template, data, content_type)
         if self.custom_css:
             add_stylesheet(req, '/themeengine/theme.css')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py

示例12: _do_rename

    def _do_rename(self, req, page):
        if page.readonly:
            req.perm(page.resource).require('WIKI_ADMIN')
        else:
            req.perm(page.resource).require('WIKI_RENAME')
        if 'cancel' in req.args:
            req.redirect(get_resource_url(self.env, page.resource, req.href))
        old_name, old_version = page.name, page.version
        new_name = req.args.get('new_name', '').rstrip('/')
        redirect = req.args.get('redirect')
        # verify input parameters
        warn = None
        if not new_name:
            warn = _('A new name is mandatory for a rename.')
        elif new_name == old_name:
            warn = _('The new name must be different from the old name.')
        elif WikiPage(self.env, new_name).exists:
            warn = _('The page %(name)s already exists.', name=new_name)
        if warn:
            add_warning(req, warn)
            return self._render_confirm_rename(req, page, new_name)

        @self.env.with_transaction()
        def do_rename(db):
            page.rename(new_name)
            if redirect:
                redirection = WikiPage(self.env, old_name, db=db)
                redirection.text = _('See [wiki:"%(name)s"].', name=new_name)
                author = get_reporter_id(req)
                comment = u'[wiki:"%[email protected]%d" %s] \u2192 [wiki:"%s"].' % (
                          new_name, old_version, old_name, new_name)
                redirection.save(author, comment, req.remote_addr)
        
        req.redirect(req.href.wiki(redirect and old_name or new_name))
开发者ID:zjj,项目名称:trac_hack,代码行数:34,代码来源:web_ui.py

示例13: _do_change_password

    def _do_change_password(self, req):
        username = req.authname

        old_password = req.args.get('old_password')
        if not self.acctmgr.check_password(username, old_password):
            if old_password:
                add_warning(req, _("Old password is incorrect."))
            else:
                add_warning(req, _("Old password cannot be empty."))
            return
        password = req.args.get('password')
        if not password:
            add_warning(req, _("Password cannot be empty."))
        elif password != req.args.get('password_confirm'):
            add_warning(req, _("The passwords must match."))
        elif password == old_password:
            add_warning(req, _("Password must not match old password."))
        else:
            _set_password(self.env, req, username, password, old_password)
            if req.session.get('password') is not None:
                # Fetch all session_attributes in case new user password is in
                # SessionStore, preventing overwrite by session.save().
                req.session.get_session(req.authname, authenticated=True)
            add_notice(req, _("Password updated successfully."))
            return True
开发者ID:SpamExperts,项目名称:AccountManagerPlugin,代码行数:25,代码来源:web_ui.py

示例14: process_request

 def process_request(self, req): 
     if req.path_info == '/traccron/runtask':
         self._runtask(req)
     else:
         self.env.log.warn("Trac Cron Plugin was unable to handle %s" % req.path_info)
         add_warning(req, "The request was not handled by trac cron plugin")
         req.redirect(req.href.admin('traccron','cron_admin'))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:core.py

示例15: post_process_request

    def post_process_request(self, req, template, data, content_type):
        if template is None or not req.session.authenticated:
            # Don't start the email verification procedure on anonymous users.
            return template, data, content_type

        email = req.session.get('email')
        # Only send verification if the user entered an email address.
        if self.verify_email and self.email_enabled is True and email and \
                email != req.session.get('email_verification_sent_to') and \
                'ACCTMGR_ADMIN' not in req.perm:
            req.session['email_verification_token'] = self._gen_token()
            req.session['email_verification_sent_to'] = email
            try:
                AccountManager(self.env)._notify(
                    'email_verification_requested',
                    req.authname,
                    req.session['email_verification_token']
                )
            except NotificationError, e:
                chrome.add_warning(req, _(
                    "Error raised while sending a change notification."
                ) + _("You should report that issue to a Trac admin."))
                self.log.error('Unable to send registration notification: %s',
                               exception_to_unicode(e, traceback=True))
            else:
                # TRANSLATOR: An email has been sent to <%(email)s>
                # with a token to ... (the link label for following message)
                link = tag.a(_("verify your new email address"),
                             href=req.href.verify_email())
                # TRANSLATOR: ... verify your new email address
                chrome.add_notice(req, tag_(
                    "An email has been sent to <%(email)s> with a token to "
                    "%(link)s.", email=tag(email), link=link))
开发者ID:t-kenji,项目名称:trac-account-manager-plugin,代码行数:33,代码来源:register.py


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