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

Python i18n._函数代码示例

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

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



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

示例1: UpdateSort

 def UpdateSort(self, objs, user):
     """    update pool_sort values according to list """
     if not objs:
         return False, _(u"List is empty")
     if isinstance(objs, basestring):
         objs = ConvertToNumberList(objs)
     ids = []
     for oi in objs:
         # check if listed objects are objects or ids
         if not IObject.providedBy(oi):
             ids.append(int(oi))
     if ids:
         # load remaining objects by id
         objs2 = self.GetObjsBatch(ids)
     pos = 10
     processed = []
     for obj in objs:
         if not IObject.providedBy(obj):
             for o in objs2:
                 if o.id == int(obj):
                     obj = o
                     break
         if not IObject.providedBy(obj):
             continue
         if obj.id in processed:
             continue
         processed.append(obj.id)
         obj.meta.set("pool_sort", pos)
         obj.CommitInternal(user)
         pos += 10
     return True, _(u"OK")
开发者ID:nive-cms,项目名称:nive,代码行数:31,代码来源:sort.py


示例2: Paste

 def Paste(self, ids, pos, user):
     """
     Paste the copied object with id to this object
     """
     root = self.GetRoot()
     new = []
     msgs = []
     result = True
     for id in ids:
         id = int(id)
         if self.GetID() == id:
             continue
         obj = root.LookupObj(id, preload="skip")
         if not obj:
             msgs.append(_(u"Object not found"))
             result = False
             continue
         newobj = self.Duplicate(obj, user) 
         if not newobj:
             raise TypeError, "Duplicate failed"
         if ISort.providedBy(self):
             self.InsertAfter(newobj.id, pos, user=user)
         new.append(newobj)
     if not self.app.configuration.autocommit:
         for o in new:
             o.Commit(user)
     if result:
         msgs.append(_(u"OK. Copied and pasted."))
     return result, msgs
开发者ID:nive-cms,项目名称:nive,代码行数:29,代码来源:cutcopy.py


示例3: Update

 def Update(self, action, **kw):
     """
     Process request data and update object.
     
     returns bool, html
     """
     redirectSuccess = kw.get("redirectSuccess")
     msgs = []
     conf=self.context
     result,data,errors = self.Validate(self.request)
     if result:
         # lookup persistent manager for configuration
         storage = self.app.Factory(IModuleConf, "persistence")
         if storage:
             storage(app=self.app, configuration=conf).Save(data)
             msgs.append(_(u"OK. Data saved."))
         else:
             msgs.append(_(u"No persistent storage for configurations activated. Nothing saved."))
             result = False
         errors=None
         if self.view and redirectSuccess:
             redirectSuccess = self.view.ResolveUrl(redirectSuccess, obj)
             if self.use_ajax:
                 self.view.Relocate(redirectSuccess, messages=msgs, raiseException=True)
             else:
                 self.view.Redirect(redirectSuccess, messages=msgs, raiseException=True)
     return result, self.Render(data, msgs=msgs, errors=errors)    
开发者ID:adroullier,项目名称:nive,代码行数:27,代码来源:view.py


示例4: _Run

    def _Run(self, **values):

        result = 1
        codepage="utf-8"
    
        app = self.app
        datapool = app.db
        conf = app.dbConfiguration
        conn = datapool.connection
        system = values.get("excludeSystem")
        self.filename = app.configuration.id + ".json"

        if not conn:
            self.stream.write(_(u"Database connection error (${name})\n", mapping={u"name": app.dbConfiguration.context}))
            return 0
        
        if not conn.IsConnected():
            self.stream.write(_(u"Database connection error (${name})\n", mapping={u"name": app.dbConfiguration.context}))
            return 0
        
        def mapfields(fields):
            a=[]
            for f in fields:
                a.append(f.id)
            return a
        
        export = [(MetaTbl,mapfields(app.GetAllMetaFlds(ignoreSystem=False)))]
        for t in app.GetAllObjectConfs():
            export.append((t.dbparam, ["id"]+mapfields(t.data)))
        for t in Structure.items():
            export.append((t[0], mapfields(t[1]["fields"])))

        data = {}
        for table in export:
            #tablename
            tablename=table[0]
            if system and tablename in system:
                continue 
            #fields
            fields=table[1]
            columns = (",").join(fields)
            sql="select %s from %s" % (columns, tablename)
            c = conn.cursor()
            c.execute(sql)
            tvalues = []
            for rec in c.fetchall():
                recvalue = {}
                pos = 0
                for col in rec:
                    recvalue[fields[pos]] = col
                    pos+=1
                tvalues.append(recvalue)
            data[tablename] = tvalues
        
        self.stream.write(JsonDataEncoder().encode(data))        
        
        return 1
开发者ID:comlorda,项目名称:nive,代码行数:57,代码来源:dbJsonDump.py


示例5: delfile

 def delfile(self):
     file = self.GetFormValue(u"fid")
     try:
         r=self.context.DeleteFile(file, self.User())
         if not r:
             m=_(u"Delete failed")
         else:
             m=_(u"OK")
     except Exception, e:
         m=str(e)
开发者ID:nive-cms,项目名称:nive,代码行数:10,代码来源:view.py


示例6: _Run

    def _Run(self, **values):

        result = 1
        codepage="utf-8"
    
        app = self.app
        datapool = app.db
        conf = app.dbConfiguration
        conn = datapool.connection
        system = values.get("excludeSystem")
        self.filename = app.configuration.id + ".sql"

        if not conn:
            self.stream.write(_(u"Database connection error (${name})\n", mapping={u"name": app.dbConfiguration.context}))
            return 0
        
        if not conn.IsConnected():
            self.stream.write(_(u"Database connection error (${name})\n", mapping={u"name": app.dbConfiguration.context}))
            return 0
        
        def mapfields(fields):
            a=[]
            for f in fields:
                a.append(f.id)
            return a
        
        export = [(MetaTbl,mapfields(app.GetAllMetaFlds(ignoreSystem=False)))]
        for t in app.GetAllObjectConfs():
            export.append((t.dbparam, ["id"]+mapfields(t.data)))
        for t in Structure.items():
            export.append((t[0], mapfields(t[1]["fields"])))

        for table in export:
            #tablename
            tablename=table[0]
            if system and tablename in system:
                continue 
            #fields
            fields=table[1]
            columns = (",").join(fields)
            sql="select %s from %s" % (columns, tablename)
            c = conn.cursor()
            c.execute(sql)
            for rec in c.fetchall():
                data = []
                for col in rec:
                    data.append(conn.FmtParam(col))
                data = (",").join(data)
                if not isinstance(data, unicode):
                    data = unicode(data, codepage)
                value = u"INSERT INTO %s (%s) VALUES (%s);\n"%(tablename, columns, data)
                value = value.encode(codepage)
                self.stream.write(value)        
        
        return 1
开发者ID:nive,项目名称:nive,代码行数:55,代码来源:dbSqlDump.py


示例7: Move

    def Move(self, ids, pos, user):
        """
        Move the object with id to this object
        
        Events
        
        - beforeAdd(data=obj.meta, type=type)
        - afterDelete(id=obj.id)
        - moved()
        - afterAdd(obj=obj)
        """
        root = self.root()
        oldParent=None

        moved = []
        msgs = []
        result = True
        for id in ids:
            id = int(id)
            if self.GetID() == id:
                continue
            obj = root.LookupObj(id, preload="skip")
            if not obj:
                msgs.append(_(u"Object not found"))
                result = False
                continue

            type=obj.GetTypeID()
            # allow subobject
            if not self.IsTypeAllowed(type, user):
                raise TypeError, "Object cannot be added here"

            self.Signal("beforeAdd", data=obj.meta, type=type)
            if not oldParent or oldParent.id != obj.GetParent().id:
                oldParent = obj.GetParent()
            obj.__parent__ = self
            obj.meta["pool_unitref"] = self.GetID()
            oldParent.Signal("afterDelete", id=obj.id)
            obj.Signal("moved")
            #obj.Close()
            moved.append(obj)

        for o in moved:
            o.Commit(user)
            if ISort.providedBy(self):
                self.InsertAfter(o.id, pos, user=user)
            self.Signal("afterAdd", obj=o)
        if result:
            msgs.append(_(u"OK. Cut and pasted."))
        return result, msgs
开发者ID:nive-cms,项目名称:nive,代码行数:50,代码来源:cutcopy.py


示例8: _Run

    def _Run(self, **values):

        result = 1
        importWf = 1
        importSecurity = 0
        showSystem = values.get("showSystem")
        modify = values.get("modify")
        request = values["original"]
        ignoreTables = self.app.configuration.get("skipUpdateTables", ())

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()
        # localizer.translate(term)

        text = _(
            u""" <div class="well">
This tool compares the physically existing database structure (tables, columns) with the current configuration settings.
The database structure is shown on the left, configuration settings on the right. <br><br>
Existing database columns will only be altered if manually selected in the 'Modify' column. Modifying a table may destroy the data
stored (e.g if converted from string to integer), so don't forget to create backups of the database before modifying anything.<br>
By default this tool will only create new tables and columns and never delete any column.
 </div>       """
        )
        self.stream.write(localizer.translate(_(text)))

        self.stream.write(
            u"""<form action="" method="post">
                     <input type="hidden" name="tag" value="dbStructureUpdater">
                     <input type="hidden" name="modify" value="1">"""
        )
        app = self.app
        try:
            conf = app.dbConfiguration
            connection = app.NewConnection()
            if not connection:
                self.stream.write(
                    localizer.translate(
                        _(u"""<div class="alert alert-error">No database connection configured</div>""")
                    )
                )
                return 0
        except OperationalError, e:
            self.stream.write(
                localizer.translate(_(u"""<div class="alert alert-error">No database connection configured</div>"""))
            )
            return 0
开发者ID:nive,项目名称:nive,代码行数:48,代码来源:dbStructureUpdater.py


示例9: RenderField

 def RenderField(self, fld, data=None, context=None):
     """
     Render the data field for html display. Rendering depends on the datatype defined
     in the field configuration.
     
     If data is None the current context is used.
     
     returns string
     """
     if context is None:
         context = self.context
     if isinstance(fld, basestring):
         fld = context.GetFieldConf(fld)
     if not fld:
         return _(u"<em>Unknown field</em>")
     if data is None:
         data = context.data.get(fld['id'], context.meta.get(fld['id']))
     if fld['datatype']=='file':
         url = self.FileUrl(fld['id'])
         if not url:
             return u""
         url2 = url.lower()
         if url2.find(u".jpg")!=-1 or url2.find(u".jpeg")!=-1 or url2.find(u".png")!=-1 or url2.find(u".gif")!=-1:
             return u"""<img src="%s">""" % (url)
         return u"""<a href="%s">download</a>""" % (url)
     return FieldRenderer(context).Render(fld, data, context=context)
开发者ID:nive,项目名称:nive,代码行数:26,代码来源:views.py


示例10: editroot

 def editroot(self):
     root = self.context.app.root(name="")
     if not IPersistentRoot.providedBy(root):
         return {u"content": _(u"The default root does not support persistent data storage."), u"result": False, u"head": u""}
     fields = (
         FieldConf(id=u"pool_filename",   datatype="string", size=30,   required=1, name=_(u"Root url name"),
                   settings={"validator": RootnameValidator}, default=root.configuration.id),
         FieldConf(id=u"title",           datatype="string", size=255,  required=0, name=_(u"Root title"), default=root.configuration.name),
         FieldConf(id=u"description",     datatype="text",   size=5000, required=0, name=_(u"Root description")),
         FieldConf(id="pool_groups",      datatype="checkbox", size=250, default="", name=_(u"Permission"),
                   description=_(u"Only displayed to users in the selected group"))
     )
     form = RootForm(view=self, context=root, app=self.context)
     form.fields = fields
     form.Setup()
     # process and render the form.
     result, data, action = form.Process()
     return {u"content": data, u"result": result, u"head": form.HTMLHead()}
开发者ID:comlorda,项目名称:nive,代码行数:18,代码来源:view.py


示例11: design

 def design(self):
     fields = (
         FieldConf(id=u"columns", datatype="lines",  size=100,  required=0, name=_(u"Column names"), description=_(u"Column names used in the main template. For multiple columns enter one per line.")),
     )
     form = ConfigurationForm(view=self, context=self.context.configuration, app=self.context)
     form.fields = fields
     form.Setup() 
     # process and render the form.
     result, data, action = form.Process()
     return {u"content": data, u"result": result, u"head": form.HTMLHead()}
开发者ID:nive-cms,项目名称:nive,代码行数:10,代码来源:admin.py


示例12: elementListWidget

    def elementListWidget(self, obj=None, elements=None, addResponse=True):
        """
        Widget with existing elements list and edit options
        call with obj = current object / page
        """
        #i18n?
        if not obj:
            obj=self.context
        html = u"""<div>
  <h4 onclick="$.fn.editblocks().toggleBlock('#elements%(id)s',event)">%(title)s</h4>
  %(blocks)s
</div>
        """
        
        elHtml = u"""<div class="element">
  <div class="el_title">%(title)s</div>
  <div class="el_options">%(options)s</div>
  <br style="clear:both"/>
</div>"""
        
        if not elements:
            elements = obj.GetPageElements()
            
        localizer = translator(self.request)
        
        blocks = StringIO()
        static = self.StaticUrl("nive.cms.cmsview:static/images/types/")
        for el in elements:
        
            t = el.GetTitle()
            if not t:
                t = u"<em>%s</em>" % (localizer(el.GetTypeName(), self.request))

            if el.GetTypeID()=="box":
                title = u"<img src='%s%s.png' align='top'/> %s: %s" % (static, el.GetTypeID(), localizer(u"Box"), t)
                blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=el, showCCP=True)})
                for elb in el.GetPageElements():
                    t = elb.GetTitle()
                    if not t:
                        t = u"<em>%s</em>" % (localizer(elb.GetTypeName()))
                    title = u"&gt; <img src='%s%s.png' align='top'/> %s" % (static, elb.GetTypeID(), t)
                    blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=elb, showCCP=True)})
        
            else:
                title = u"<img src='%s%s.png' align='top'/> %s" % (static, el.GetTypeID(), t)
                blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=el, showCCP=True)})
        if not len(elements):
            blocks.write(localizer(_(u"<p><i>empty</i></p>")))
        data = html % {u"blocks": blocks.getvalue(), u"id": str(obj.GetID()), u"title": localizer(_(u"Page elements"))}
        if addResponse:
            r = Response(content_type="text/html", conditional_response=True)
            r.unicode_body = data
            return r
        return data
开发者ID:nive-cms,项目名称:nive,代码行数:54,代码来源:view.py


示例13: selectPageElement

 def selectPageElement(self):
     user = self.User()
     lt = self.context.GetAllowedTypes(user)
     tmpl = u"""<a href="add?pool_type=%s" rel="niveOverlay" class="nivecms addlink">%s</a> """
     html = StringIO()
     html.write(u"""<div class="addElements">""")
     #opt
     for t in lt:
         html.write(tmpl % (t[u"id"], _(t[u"name"])))
     html.write(u"</div>")
     return html.getvalue()
开发者ID:nive-cms,项目名称:nive,代码行数:11,代码来源:view.py


示例14: action

 def action(self):
     transition = self.GetFormValue(u"t")
     url = self.GetFormValue("redirect_url")
     if not url:
         url = self.PageUrl()
         
     user = self.User()
     self.context.WfAction("", user, transition=transition)
     self.context.CommitInternal(user)
     msg = _(u"OK")
     self.Redirect(url, messages=[msg])
开发者ID:nive-cms,项目名称:nive,代码行数:11,代码来源:view.py


示例15: copy

 def copy(self):
     """
     """
     ids = self.GetFormValue(u"ids")
     if not ids:
         ids = [self.context.id]
     cp = self.SetCopyInfo(u"copy", ids, self.context)
     url = self.GetFormValue(u"url")
     if not url:
         url = self.PageUrl(self.context)
     msgs = _(u"OK. Copied.")
     return self.Redirect(url, [msgs])
开发者ID:nive-cms,项目名称:nive,代码行数:12,代码来源:cutcopy.py


示例16: RootnameValidator

def RootnameValidator(node, value):
    """
    Makes sure the new name does not exist.
    """
    # lookup name in database
    app = node.widget.form.context.app
    for root in app.GetAllRootConfs():
        if root.id == value:
            # check if its the context
            if app.root(root.id)!=node.widget.form.context:
                err = _(u"'${name}' already in use. Please choose a different name.", mapping={'name':value})
                raise Invalid(node, err)
开发者ID:comlorda,项目名称:nive,代码行数:12,代码来源:view.py


示例17: __init__

 def __init__(self, configuration = None):
     """
     Events:
     - init(configuration)
     """
     self.components = []
     self.groups = [Conf(id=u"authenticated", name=_(u"Authenticated"), visible=True)]
     self.__acl__ = [(Allow, "group:admin", ALL_PERMISSIONS)]
     
     self.configuration = configuration or PortalConf()
     
     self.Signal("init", configuration=self.configuration)
开发者ID:adroullier,项目名称:nive,代码行数:12,代码来源:portal.py


示例18: delete

 def delete(self):
     id = self.GetFormValue(u"id")
     result = {u"msgs": [], u"objToDelete": None, u"content":u"", u"cmsview": self, u"result": False}
     if not id:
         result[u"msgs"] = [_(u"Nothing to delete")]
         return result
     delete = self.GetFormValue(u"delete")
     obj = self.context.obj(id)
     if not obj:
         result[u"msgs"] = [_(u"Object not found")]
         return result
     if obj.IsContainer() and delete != u"1":
         result[u"objToDelete"] = obj
         return result
     result[u"result"] = self.context.Delete(id, user=self.User(), obj=obj)
     if result[u"result"]:
         result[u"msgs"] = [_(u"OK. Deleted.")]
     self.Relocate("""<script type="text/javascript">window.parent.close("%s");</script>""" % (self.PageUrl()), 
                   [_(u"OK. Deleted.")], 
                   raiseException=True)
     return result
开发者ID:nive-cms,项目名称:nive,代码行数:21,代码来源:view.py


示例19: _Run

    def _Run(self, **values):

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()

        app = self.app
        datapool = app.db
        conn = datapool.connection
        c = conn.cursor()

        self.stream.write(u"<table>\n")

        sql = "select count(*) from pool_meta"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Elements in total</th><td>${value}</td></tr>\n", mapping={u"value": rec[0][0]})))

        sql = "select count(*) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Physical files</th><td>${value}</td></tr>\n", mapping={u"value": rec[0][0]})))

        sql = "select sum(size) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Physical files size</th><td>${value}</td></tr>\n", mapping={u"value": FormatBytesForDisplay(rec[0][0])})))

        for t in app.GetAllObjectConfs():
            sql = "select count(*) from pool_meta where pool_type='%s'" % t.id
            c.execute(sql)
            rec = c.fetchall()
            self.stream.write(localizer.translate(_(u"<tr><th>${name}</th><td>${value}</td></tr>\n", mapping={u"name": t.name, u"value": rec[0][0]})))
        
        self.stream.write(u"</table>\n")

        c.close()
        return 1
开发者ID:adroullier,项目名称:nive,代码行数:39,代码来源:cmsstatistics.py


示例20: editdatabase

 def editdatabase(self):
     dbtypes=[{"id":"MySql","name":"MySql"},{"id":"Sqlite3","name":"Sqlite3"}]
     fields = (
         FieldConf(id=u"context",  datatype="list",   size=20,   required=1, name=_(u"Database type to be used"), listItems=dbtypes, 
                   description=_(u"Supports 'Sqlite3' and 'MySql' by default. MySql requires python-mysqldb installed.")),
         FieldConf(id=u"fileRoot", datatype="string", size=500,  required=0, name=_(u"Relative or absolute root directory for files")),
         FieldConf(id=u"dbName",   datatype="string", size=500,  required=1, name=_(u"Database file path or name"),
                   description=_(u"Sqlite3=database file path, MySql=database name")),
         FieldConf(id=u"host",     datatype="string", size=100,  required=0, name=_(u"Database server host")),
         FieldConf(id=u"port",     datatype="number", size=8,    required=0, name=_(u"Database server port")),
         FieldConf(id=u"user",     datatype="string", size=100,  required=0, name=_(u"Database server user")),
         FieldConf(id=u"password", datatype="password", size=100,required=0, name=_(u"Database server password")),
     )
     form = ConfigurationForm(view=self, context=self.context.dbConfiguration, app=self.context)
     form.fields = fields
     form.Setup()
     # process and render the form.
     result, data, action = form.Process()
     return {u"content": data, u"result": result, u"head": form.HTMLHead()}
开发者ID:adroullier,项目名称:nive,代码行数:19,代码来源:view.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python backends.MachineDefinition类代码示例发布时间:2022-05-27
下一篇:
Python module.module函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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