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


Python i18n._函数代码示例

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


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

示例1: update

    def update(self, id):
        _form = DefaultsForm()()

        try:
            form_result = _form.to_python(dict(request.POST))
            for k, v in form_result.iteritems():
                setting = Setting.create_or_update(k, v)
            Session().commit()
            h.flash(_('Default settings updated successfully'),
                    category='success')

        except formencode.Invalid as errors:
            defaults = errors.value

            return htmlfill.render(
                render('admin/defaults/defaults.html'),
                defaults=defaults,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8",
                force_defaults=False)
        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('Error occurred during update of defaults'),
                    category='error')

        raise HTTPFound(location=url('defaults'))
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:27,代码来源:defaults.py

示例2: create

    def create(self):
        self.__load_defaults()

        # permissions for can create group based on parent_id are checked
        # here in the Form
        repo_group_form = RepoGroupForm(repo_groups=c.repo_groups)
        try:
            form_result = repo_group_form.to_python(dict(request.POST))
            gr = RepoGroupModel().create(
                group_name=form_result['group_name'],
                group_description=form_result['group_description'],
                parent=form_result['parent_group_id'],
                owner=request.authuser.user_id, # TODO: make editable
                copy_permissions=form_result['group_copy_permissions']
            )
            Session().commit()
            #TODO: in future action_logger(, '', '', '')
        except formencode.Invalid as errors:
            return htmlfill.render(
                render('admin/repo_groups/repo_group_add.html'),
                defaults=errors.value,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8",
                force_defaults=False)
        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('Error occurred during creation of repository group %s') \
                    % request.POST.get('group_name'), category='error')
            parent_group_id = form_result['parent_group_id']
            #TODO: maybe we should get back to the main view, not the admin one
            raise HTTPFound(location=url('repos_groups', parent_group=parent_group_id))
        h.flash(_('Created repository group %s') % gr.group_name,
                category='success')
        raise HTTPFound(location=url('repos_group_home', group_name=gr.group_name))
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:35,代码来源:repo_groups.py

示例3: register

    def register(self, **kw):
        """
        User register
        """
        log.debug("Recibiendo de registro %s", kw)
        if request.identity:
            redirect('/')

        """ Adding new user """
        user = model.User()
        user.email_address = kw.get('email', None)
        user.password = kw.get('password', None)
        user.user_name = kw.get('username', None)
        model.DBSession.add(user)

        # Persisting
        from sqlalchemy.exc import IntegrityError
        try:
            model.DBSession.flush()
            forceUser(user.user_name)
            flash(_(u'Bienvenido %s, su cuenta ha sido creada con éxito' % user.user_name), 'alert alert-success')
            redirect('/')
        except IntegrityError as e:
            log.debug('Error:', e)
            model.DBSession.rollback()
            if e.orig[0] == 1062: 
                # User register already exits
                flash(_('Parece que ya tienes cuenta'))
                redirect('/login')
            else:
                raise  
开发者ID:peguerosdc,项目名称:pegasus,代码行数:31,代码来源:root.py

示例4: put

    def put(self, folder_id, label, can_contain_folders=False, can_contain_threads=False, can_contain_files=False, can_contain_pages=False):
        # TODO - SECURE THIS
        workspace = tmpl_context.workspace

        api = ContentApi(tmpl_context.current_user)
        next_url = ''

        try:
            folder = api.get_one(int(folder_id), ContentType.Folder, workspace)
            subcontent = dict(
                folder = True if can_contain_folders=='on' else False,
                thread = True if can_contain_threads=='on' else False,
                file = True if can_contain_files=='on' else False,
                page = True if can_contain_pages=='on' else False
            )
            if label != folder.label:
                # TODO - D.A. - 2015-05-25 - Allow to set folder description
                api.update_content(folder, label, folder.description)
            api.set_allowed_content(folder, subcontent)
            api.save(folder)

            tg.flash(_('Folder updated'), CST.STATUS_OK)

            next_url = self.url(folder.content_id)

        except Exception as e:
            tg.flash(_('Folder not updated: {}').format(str(e)), CST.STATUS_ERROR)
            next_url = self.url(int(folder_id))

        tg.redirect(next_url)
开发者ID:DarkDare,项目名称:tracim,代码行数:30,代码来源:content.py

示例5: repo_check

    def repo_check(self, repo_name):
        c.repo = repo_name
        task_id = request.GET.get('task_id')

        if task_id and task_id not in ['None']:
            from kallithea import CELERY_ON
            from kallithea.lib import celerypylons
            if CELERY_ON:
                task = celerypylons.result.AsyncResult(task_id)
                if task.failed():
                    raise HTTPInternalServerError(task.traceback)

        repo = Repository.get_by_repo_name(repo_name)
        if repo and repo.repo_state == Repository.STATE_CREATED:
            if repo.clone_uri:
                h.flash(_('Created repository %s from %s')
                        % (repo.repo_name, repo.clone_uri_hidden), category='success')
            else:
                repo_url = h.link_to(repo.repo_name,
                                     h.url('summary_home',
                                           repo_name=repo.repo_name))
                fork = repo.fork
                if fork is not None:
                    fork_name = fork.repo_name
                    h.flash(h.literal(_('Forked repository %s as %s')
                            % (fork_name, repo_url)), category='success')
                else:
                    h.flash(h.literal(_('Created repository %s') % repo_url),
                            category='success')
            return {'result': True}
        return {'result': False}
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:31,代码来源:repos.py

示例6: _ignorews_url

def _ignorews_url(GET, fileid=None):
    fileid = str(fileid) if fileid else None
    params = defaultdict(list)
    _update_with_GET(params, GET)
    lbl = _('Show whitespace')
    ig_ws = get_ignore_ws(fileid, GET)
    ln_ctx = get_line_ctx(fileid, GET)
    # global option
    if fileid is None:
        if ig_ws is None:
            params['ignorews'] += [1]
            lbl = _('Ignore whitespace')
        ctx_key = 'context'
        ctx_val = ln_ctx
    # per file options
    else:
        if ig_ws is None:
            params[fileid] += ['WS:1']
            lbl = _('Ignore whitespace')

        ctx_key = fileid
        ctx_val = 'C:%s' % ln_ctx
    # if we have passed in ln_ctx pass it along to our params
    if ln_ctx:
        params[ctx_key] += [ctx_val]

    params['anchor'] = fileid
    icon = h.literal('<i class="icon-strike"></i>')
    return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:29,代码来源:changeset.py

示例7: _c

        def _c():
            log.debug('generating switcher repo/groups list')
            all_repos = Repository.query(sorted=True).all()
            repo_iter = self.scm_model.get_repos(all_repos)
            all_groups = RepoGroup.query(sorted=True).all()
            repo_groups_iter = self.scm_model.get_repo_groups(all_groups)

            res = [{
                    'text': _('Groups'),
                    'children': [
                       {'id': obj.group_name,
                        'text': obj.group_name,
                        'type': 'group',
                        'obj': {}}
                       for obj in repo_groups_iter
                    ],
                   },
                   {
                    'text': _('Repositories'),
                    'children': [
                       {'id': obj.repo_name,
                        'text': obj.repo_name,
                        'type': 'repo',
                        'obj': obj.get_dict()}
                       for obj in repo_iter
                    ],
                   }]

            data = {
                'more': False,
                'results': res,
            }
            return data
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:33,代码来源:home.py

示例8: put

    def put(self, user_id, name, email, timezone, next_url=None):
        user_id = tmpl_context.current_user.user_id
        current_user = tmpl_context.current_user
        user_api = UserApi(current_user)
        assert user_id==current_user.user_id
        if next_url:
            next = tg.url(next_url)
        else:
            next = self.url()

        try:
            email_user = user_api.get_one_by_email(email)
            if email_user != current_user:
                tg.flash(_('Email already in use'), CST.STATUS_ERROR)
                tg.redirect(next)
        except NoResultFound:
            pass

        # Only keep allowed field update
        updated_fields = self._clean_update_fields({
            'name': name,
            'email': email,
            'timezone': timezone,
        })

        api = UserApi(tmpl_context.current_user)
        api.update(current_user, do_save=True, **updated_fields)
        tg.flash(_('profile updated.'))
        tg.redirect(next)
开发者ID:lebouquetin,项目名称:tracim,代码行数:29,代码来源:user.py

示例9: lnk

 def lnk(rev, repo_name):
     lazy_cs = False
     title_ = None
     url_ = '#'
     if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
         if rev.op and rev.ref_name:
             if rev.op == 'delete_branch':
                 lbl = _('Deleted branch: %s') % rev.ref_name
             elif rev.op == 'tag':
                 lbl = _('Created tag: %s') % rev.ref_name
             else:
                 lbl = 'Unknown operation %s' % rev.op
         else:
             lazy_cs = True
             lbl = rev.short_id[:8]
             url_ = url('changeset_home', repo_name=repo_name,
                        revision=rev.raw_id)
     else:
         # changeset cannot be found - it might have been stripped or removed
         lbl = rev[:12]
         title_ = _('Changeset %s not found') % lbl
     if parse_cs:
         return link_to(lbl, url_, title=title_, **{'data-toggle': 'tooltip'})
     return link_to(lbl, url_, class_='lazy-cs' if lazy_cs else '',
                    **{'data-raw_id':rev.raw_id, 'data-repo_name':repo_name})
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:25,代码来源:helpers.py

示例10: repo_refs_data

 def repo_refs_data(self, repo_name):
     repo = Repository.get_by_repo_name(repo_name).scm_instance
     res = []
     _branches = repo.branches.items()
     if _branches:
         res.append({
             'text': _('Branch'),
             'children': [{'id': rev, 'text': name, 'type': 'branch'} for name, rev in _branches]
         })
     _closed_branches = repo.closed_branches.items()
     if _closed_branches:
         res.append({
             'text': _('Closed Branches'),
             'children': [{'id': rev, 'text': name, 'type': 'closed-branch'} for name, rev in _closed_branches]
         })
     _tags = repo.tags.items()
     if _tags:
         res.append({
             'text': _('Tag'),
             'children': [{'id': rev, 'text': name, 'type': 'tag'} for name, rev in _tags]
         })
     _bookmarks = repo.bookmarks.items()
     if _bookmarks:
         res.append({
             'text': _('Bookmark'),
             'children': [{'id': rev, 'text': name, 'type': 'book'} for name, rev in _bookmarks]
         })
     data = {
         'more': False,
         'results': res
     }
     return data
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:32,代码来源:home.py

示例11: create

 def create(self):
     c.default_extern_type = User.DEFAULT_AUTH_TYPE
     c.default_extern_name = ''
     user_model = UserModel()
     user_form = UserForm()()
     try:
         form_result = user_form.to_python(dict(request.POST))
         user = user_model.create(form_result)
         action_logger(request.authuser, 'admin_created_user:%s' % user.username,
                       None, request.ip_addr)
         h.flash(_('Created user %s') % user.username,
                 category='success')
         Session().commit()
     except formencode.Invalid as errors:
         return htmlfill.render(
             render('admin/users/user_add.html'),
             defaults=errors.value,
             errors=errors.error_dict or {},
             prefix_error=False,
             encoding="UTF-8",
             force_defaults=False)
     except UserCreationError as e:
         h.flash(e, 'error')
     except Exception:
         log.error(traceback.format_exc())
         h.flash(_('Error occurred during creation of user %s') \
                 % request.POST.get('username'), category='error')
     raise HTTPFound(location=url('edit_user', id=user.user_id))
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:28,代码来源:users.py

示例12: delete

 def delete(self, category_id, **kw):
     try:
         app_globals.shop.category.delete(category_id)
         flash(_('Category deleted'))
     except CategoryAssignedToProductException:
         flash(_('Is impossible to delete a category assigned to product'), 'error')
     return redirect(plug_url('stroller2', '/manage/category/index'))
开发者ID:gasbasd,项目名称:tgapp-stroller2,代码行数:7,代码来源:category.py

示例13: delete

    def delete(self, user, cur_user=None):
        if cur_user is None:
            cur_user = getattr(get_current_authuser(), 'username', None)
        user = User.guess_instance(user)

        if user.is_default_user:
            raise DefaultUserException(
                _("You can't remove this user since it is"
                  " crucial for the entire application"))
        if user.repositories:
            repos = [x.repo_name for x in user.repositories]
            raise UserOwnsReposException(
                _('User "%s" still owns %s repositories and cannot be '
                  'removed. Switch owners or remove those repositories: %s')
                % (user.username, len(repos), ', '.join(repos)))
        if user.repo_groups:
            repogroups = [x.group_name for x in user.repo_groups]
            raise UserOwnsReposException(_(
                'User "%s" still owns %s repository groups and cannot be '
                'removed. Switch owners or remove those repository groups: %s')
                % (user.username, len(repogroups), ', '.join(repogroups)))
        if user.user_groups:
            usergroups = [x.users_group_name for x in user.user_groups]
            raise UserOwnsReposException(
                _('User "%s" still owns %s user groups and cannot be '
                  'removed. Switch owners or remove those user groups: %s')
                % (user.username, len(usergroups), ', '.join(usergroups)))
        Session().delete(user)

        from kallithea.lib.hooks import log_delete_user
        log_delete_user(user.get_dict(), cur_user)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:31,代码来源:user.py

示例14: __get_cs

    def __get_cs(self, rev, silent_empty=False):
        """
        Safe way to get changeset if error occur it redirects to tip with
        proper message

        :param rev: revision to fetch
        :silent_empty: return None if repository is empty
        """

        try:
            return c.db_repo_scm_instance.get_changeset(rev)
        except EmptyRepositoryError as e:
            if silent_empty:
                return None
            url_ = url('files_add_home',
                       repo_name=c.repo_name,
                       revision=0, f_path='', anchor='edit')
            add_new = h.link_to(_('Click here to add new file'), url_, class_="alert-link")
            h.flash(h.literal(_('There are no files yet. %s') % add_new),
                    category='warning')
            raise HTTPNotFound()
        except (ChangesetDoesNotExistError, LookupError):
            msg = _('Such revision does not exist for this repository')
            h.flash(msg, category='error')
            raise HTTPNotFound()
        except RepositoryError as e:
            h.flash(safe_str(e), category='error')
            raise HTTPNotFound()
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:28,代码来源:files.py

示例15: my_account_password

    def my_account_password(self):
        c.active = 'password'
        self.__load_data()

        managed_fields = auth_modules.get_managed_fields(c.user)
        c.can_change_password = 'password' not in managed_fields

        if request.POST and c.can_change_password:
            _form = PasswordChangeForm(request.authuser.username)()
            try:
                form_result = _form.to_python(request.POST)
                UserModel().update(request.authuser.user_id, form_result)
                Session().commit()
                h.flash(_("Successfully updated password"), category='success')
            except formencode.Invalid as errors:
                return htmlfill.render(
                    render('admin/my_account/my_account.html'),
                    defaults=errors.value,
                    errors=errors.error_dict or {},
                    prefix_error=False,
                    encoding="UTF-8",
                    force_defaults=False)
            except Exception:
                log.error(traceback.format_exc())
                h.flash(_('Error occurred during update of user password'),
                        category='error')
        return render('admin/my_account/my_account.html')
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:27,代码来源:my_account.py


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