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


Python policy._函数代码示例

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


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

示例1: getContentItemsCount

def getContentItemsCount(context,path=None):
    lstinfo = []

    totalwikipages = getTotalCountForQuery(context,path,{'portal_type':'Document'})
    lstinfo.append({'id':'Wiki Pages','dispid':context.translate(_(u'lbl_stats_wiki_pages',u'Wiki Pages')),'count':totalwikipages})

    totalblogentries = getTotalCountForQuery(context,path,{'portal_type':'Blog Entry'})
    lstinfo.append({'id':'Blog Entries','dispid':context.translate(_(u'lbl_stats_blog_entries',u'Blog Entries')),'count':totalblogentries})

    totalfiles = getTotalCountForQuery(context,path,{'portal_type':'File'})
    lstinfo.append({'id':'Files','dispid':context.translate(_(u'lbl_stats_files',u'Files')),'count':totalfiles})

    totalimages = getTotalCountForQuery(context,path,{'portal_type':'Image'})
    lstinfo.append({'id':'Images','dispid':context.translate(_(u'lbl_stats_status_images',u'Images')),'count':totalimages})

    totallinks = getTotalCountForQuery(context,path,{'portal_type':'Link'})
    lstinfo.append({'id':'WebLinks','dispid':context.translate(_(u'lbl_stats_status_weblinks',u'WebLinks')),'count':totallinks})

    totalstatusmessages = getTotalCountForQuery(context,path,{'portal_type':'StatuslogItem'})
    lstinfo.append({'id':'Status Messages','dispid':context.translate(_(u'lbl_stats_status_msgs',u'Status Messages')),'count':totalstatusmessages})

    totalvideos = getTotalCountForQuery(context,path,{'portal_type':'Video'})
    lstinfo.append({'id':'Videos','dispid':context.translate(_(u'lbl_stats_videos',u'Videos')),'count':totalvideos})

    totalevents = getTotalCountForQuery(context,path,{'portal_type':'Event'})
    lstinfo.append({'id':'Events','dispid':context.translate(_(u'lbl_stats_events',u'Events')),'count':totalevents})
    
    totaldiscussions = getTotalCountForQuery(context,path,{'portal_type':'Discussion'})
    lstinfo.append({'id':'Discussions','dispid':context.translate(_(u'lbl_stats_discussions',u'Discussions')),'count':totaldiscussions})
    
    totalaudios = getTotalCountForQuery(context,path,{'portal_type':'Audio'})
    lstinfo.append({'id':'Audios','dispid':context.translate(_(u'lbl_stats_audios',u'Audios')),'count':totalaudios}) 

    return lstinfo
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:34,代码来源:statistics.py

示例2: ratecontent

 def ratecontent(self):        
     ratevalue = None
     uid = None
     if self.request.form.has_key('ratevalue'):
         ratevalue = self.request.form['ratevalue']
     if self.request.form.has_key('itemUID'):
         uid = self.request.form['itemUID']
         
     if ratevalue is None:
         raise RatingError,'No rating value.'
     elif uid is None:
         raise RatingError,'No rating item.'
     else:
         pr = getToolByName(self.context, 'portal_ratings', None)
         cat = getToolByName(self.context, 'uid_catalog')
         pr.addRating(int(ratevalue), uid)
         
         query = {'UID':uid}
         resbrains = cat.searchResults(query)
         if len(resbrains) == 1:
             obj = resbrains[0].getObject()
             obj.reindexObject()
         
         myval = int(pr.getUserRating(uid))
         newval = int(pr.getRatingMean(uid))
         ratecount = pr.getRatingCount(uid)
         value_totalscore = pr.getCyninRating(uid)
         value_scorecountlist = pr.getCyninRatingCount(uid)
         value_pscore = value_scorecountlist['positivescore']
         value_pcount = value_scorecountlist['positive']
         value_nscore = value_scorecountlist['negativescore']
         value_ncount = value_scorecountlist['negative']
         
         if myval == 1:
             newtitle=_(u'hated_it',u"Hate it (-2)")
         elif myval == 2:
             newtitle=_(u'didnt_like_it',u"Dislike it (-1)")
         elif myval == 3:
             newtitle=''
         elif myval == 4:
             newtitle=_(u'liked_it',u"Like it (+1)")
         elif myval == 5:
             newtitle=_(u'loved_it',u"Love it (+2)")
         
         trans_title = self.context.translate(newtitle)
         
         if value_totalscore > 0:
             plus_sign = "+"
         else:
             plus_sign = ""
         totalscore = plus_sign + str(value_totalscore)
         
         output = trans_title + ',' + totalscore + ',' + str(value_pcount) + ',' + str(value_ncount)
         return output
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:54,代码来源:custommethods.py

示例3: CyninEdition

def CyninEdition(context):
    portal_quickinstaller = getToolByName(context, 'portal_quickinstaller')
    ubifyEdition = ""
    objProduct = portal_quickinstaller._getOb('ubify.enterprise',None)
    objondemandproduct = portal_quickinstaller._getOb('ubify.ondemand',None)
    if objProduct <> None:
        return _('cynin_enterprise_edition','enterprise edition'),'ee'
    elif objondemandproduct <> None:
        return _('cynin_ondemand_edition','on demand edition'),'od'
    else:
        return _('cynin_community_edition','free open source edition'),'ce'
开发者ID:eaudeweb,项目名称:ubify.cyninv2theme,代码行数:11,代码来源:__init__.py

示例4: getTitleForRating

def getTitleForRating(num):
    if num == 1:
        newtitle=_(u"hated_it",u'Hated it')
    elif num == 2:
        newtitle=_(u"didnt_like_it",u"Didn't like it")
    elif num == 3:
        newtitle=_(u"average",u"Average")
    elif num == 4:
        newtitle=_(u"liked_it",u'Liked it')
    elif num == 5:
        newtitle=_(u"loved_it",u'Loved it')
    return newtitle
开发者ID:eaudeweb,项目名称:ubify.cyninv2theme,代码行数:12,代码来源:__init__.py

示例5: getSchemaSectionName

def getSchemaSectionName(schema):
    returnvalue = 'default'
    if schema.lower() == "categorization":
        returnvalue = _(u"categorization",u"Categorization")
    elif schema.lower() == "dates":
        returnvalue = _(u"schedule",u"Schedule")
    elif schema.lower() == "ownership":
        returnvalue = _(u"ownership",u"Ownership")
    elif schema.lower() == "settings":
        returnvalue = _(u"additional_settings",u"Additional Settings")
    elif schema.lower() == "default":
        returnvalue = _(u"content",u"Content")
    return returnvalue
开发者ID:eaudeweb,项目名称:ubify.cyninv2theme,代码行数:13,代码来源:__init__.py

示例6: getUsersCountForSpace

def getUsersCountForSpace(context,roles_to_search):
    results = []
    
    listReaders = context.users_with_local_role('Reader')
    listReaders = checkIfGroupGetUsers(listReaders,context)
    
    listContributors = context.users_with_local_role('Contributor')
    listContributors = checkIfGroupGetUsers(listContributors,context)
    
    listReviewers = context.users_with_local_role('Reviewer')
    listReviewers = checkIfGroupGetUsers(listReviewers,context)

    listEditors = context.users_with_local_role('Editor')
    listEditors = checkIfGroupGetUsers(listEditors,context)

    
    for role_to_search in roles_to_search:
        objresults = []
        if role_to_search == 'Readers':
            for user in listReaders:
                if user not in listContributors and user not in listReviewers and user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Contributors':
            for user in listContributors:
                if user not in listReviewers and user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Reviewers':
            for user in listReviewers:
                if user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Editors':
            objresults = listEditors
        else:   #Special case when all members will be listed priority given to managers
            listmembers = []
            listtemp = []
            
            for userEditor in listEditors:
                listtemp.append(userEditor)
                listtemp.sort()
            for userReviewer in listReviewers:
                if userReviewer not in listmembers and userReviewer not in listtemp:
                    listmembers.append(userReviewer)
            for userContributor in listContributors:
                if userContributor not in listmembers and userContributor not in listtemp:
                    listmembers.append(userContributor)
            for userReader in listReaders:
                if userReader not in listmembers and userReader not in listtemp:
                    listmembers.append(userReader)
                    
            listmembers.sort()
            listtemp.extend(listmembers)
            objresults.extend(listtemp)
    
        results.append({'id':role_to_search,'dispid':context.translate(_(role_to_search,role_to_search)),'count':len(objresults)})
    
    return results
    
    
    
开发者ID:cynapse,项目名称:cynin,代码行数:56,代码来源:statistics.py

示例7: refreshMyAreaBlock

 def refreshMyAreaBlock(self,messageuid,count):
     portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     
     if portal_state.anonymous():
         return
     user_token = portal_state.member().getId()
     if user_token is None:
         return
     
     status_messages = self.context.portal_catalog.searchResults(Creator = user_token,portal_type=('StatuslogItem',),sort_on = 'created',sort_order='reverse',sort_limit=1);
     
     if len(status_messages) > 0:
         pdt = getToolByName(self.context, 'portal_discussion', None)
         newuid = status_messages[0].UID
         full_message = status_messages[0].getObject()
         newcount = 0
         message = status_messages[0].Title
         
         if full_message.isDiscussable():
             newcount = pdt.getDiscussionFor(full_message).replyCount(full_message)
         
         if newuid != messageuid or int(count) != newcount:                
             zopecommands = self.getCommandSet('zope')
             ksscore = self.getCommandSet('core')
             
             message = force_unicode(message,'utf')
             commenttext = ''
             
             if newcount < 1 or newcount > 1:
                 commenttext = _(u'text_comments',u"comments")
             elif newcount == 1:
                 commenttext = _(u'text_1_comment',u"comment")
             
             commenttext = self.context.translate(commenttext)
             commenttext = force_unicode(commenttext,'utf')
             
             selector = ksscore.getHtmlIdSelector('currentmessagediv')
             ksscore.replaceInnerHTML(selector,message)
             
             countselector = ksscore.getHtmlIdSelector('comcynapsecyninstatuscomments')
             ksscore.replaceInnerHTML(countselector,'<a href="%s">%s %s</a>' % (full_message.absolute_url(),newcount,commenttext,))
             
             kssattrselector = ksscore.getHtmlIdSelector('comcynapsecyninmyareablock')
             ksscore.setKssAttribute(kssattrselector,'messageid',str(newuid))
             ksscore.setKssAttribute(kssattrselector,'count',str(newcount))
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:45,代码来源:kssmethods.py

示例8: getTotalUsersCount

def getTotalUsersCount(context):
    userscount = 0
    usersdata = []    
    if context.portal_type in ('ContentSpace'):
        usersdata = getUsersCountForSpace(context,('Users','Editors','Contributors','Readers',))        
    else:
        search_view = context.restrictedTraverse('@@pas_search')
        userscount = len(search_view.searchUsersByRequest(context.REQUEST, sort_by='fullname'))
        usersdata.append({'id':'Users','dispid':context.translate(_(u'lbl_stats_users',u'Users')),'count':userscount})
    return usersdata
开发者ID:cynapse,项目名称:cynin,代码行数:10,代码来源:statistics.py

示例9: getSiteStatistics

def getSiteStatistics(context,path=None,ignoreviews=True,ignoretags=True):
    lstinfo = []
    
    lstinfo.extend(getTotalUsersCount(context))
    
    totalspaces = getTotalCountForQuery(context,path,{'portal_type':'ContentSpace'})
    lstinfo.append({'id':'Spaces','dispid':context.translate(_(u'lbl_stats_spaces',u'Spaces')),'count':totalspaces})

    if not ignoreviews:
        totalviews = getTotalCountForQuery(context,path,{'portal_type':'Topic'}) + getTotalCountForQuery(context,path,{'portal_type':'SmartView'})
        lstinfo.append({'id':'Collections','dispid':context.translate(_(u'lbl_stats_collections',u'Collections')),'count':totalviews})

    if not ignoretags:
        totaltags = getTotalCountForIndexType(context,path,'Subject')
        lstinfo.append({'id':'Tags','dispid':context.translate(_(u'lbl_stats_tags',u'Tags')),'count':totaltags})

    totalitems = getTotalCountForQuery(context,path,{'portal_type':spacesdefaultaddablenonfolderishtypes + ('StatuslogItem',)})
    lstinfo.append({'id':'Items','dispid':context.translate(_(u'lbl_stats_items',u'Items')),'count':totalitems})

    totalcomments = getTotalCountForQuery(context,path,{'portal_type':'Discussion Item'})
    lstinfo.append({'id':'Comments','dispid':context.translate(_(u'lbl_stats_comments',u'Comments')),'count':totalcomments})

    return lstinfo
开发者ID:cynapse,项目名称:cynin,代码行数:23,代码来源:statistics.py

示例10: creatediscussion

 def creatediscussion(self):
     strDiscussion = ''
     strTags = ''
     discussiontitle = ''
     tagstitle = ''
     obj = None
     location = self.context
     is_discussiontitle_reqd = False
     strDiscussionTitle = ''
     
     portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     cat = getToolByName(self.context, 'uid_catalog')
     portal = portal_state.portal()
     if self.request.has_key('com.cynapse.cynin.discussionmessageinput'):
         strDiscussion = self.request['com.cynapse.cynin.discussionmessageinput']
     if self.request.has_key('comcynapsediscussiontag'):
         strTags = self.request['comcynapsediscussiontag']
     if self.request.has_key('comcynapsediscussiontitle'):
         discussiontitle = self.request['comcynapsediscussiontitle']
     if self.request.has_key('comcynapsetagstitle'):
         tagstitle = self.request['comcynapsetagstitle']
     if self.request.has_key('comcynapseadddiscussioncontextuid'):
         locationuid = self.request['comcynapseadddiscussioncontextuid']
     else:
         locationuid = ''
         
     if self.request.has_key('com.cynapse.cynin.discussiontitle'):
         is_discussiontitle_reqd = True
         strDiscussionTitle = self.request['com.cynapse.cynin.discussiontitle']        
     
     query = {'UID':locationuid}
     resbrains = cat.searchResults(query)
     if len(resbrains) == 1:
         location = resbrains[0].getObject()
     
     if strDiscussion == '' or strDiscussion.lower() == discussiontitle.lower():            
         raise EmptydiscussionError, 'Unable to add discussion with blank text.'
     elif is_discussiontitle_reqd and (strDiscussionTitle == ''):
         raise EmptydiscussionError, 'Unable to add discussion with blank title.'
     else:
         from ubify.cyninv2theme import addDiscussion
         strActualTags = ''
         if strTags.lower() != tagstitle.lower():
             strActualTags = strTags
         obj = addDiscussion(portal,strDiscussion,strActualTags,location,strDiscussionTitle)
         if obj <> None:
             here_text = _(u'lbl_here',u'here')
             strlink = "<a href='%s'>%s</a>" % (obj.absolute_url(),self.context.translate(here_text),)
             return strlink
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:49,代码来源:custommethods.py

示例11: update

 def update(self):
     portal_state = getMultiAdapter((self.context, self.request),name=u'plone_portal_state')
     context_state = getMultiAdapter((self.context, self.request),name=u'plone_context_state')
     tools = getMultiAdapter((self.context, self.request), name=u'plone_tools')
     typetool= getToolByName(self.context, 'portal_types')
     portal_title = portal_state.portal_title()
     object_title = context_state.object_title()
     object_typename = self.context.portal_type
     object_typeobj = typetool[object_typename]
     self.typeiconname = object_typeobj.content_icon
     if object_typeobj.title == '' and self.context.portal_type.lower() == 'plone site':
         self.typetitle = plone_site_type_title
     else:
         self.typetitle = _(object_typeobj.title,object_typeobj.title)
     self.app_name = object_title
     if self.context.portal_type.lower() == 'plone site':
         self.tdescription = 'cyn.in site|A cyn.in site allows instant collaboration among peers and provides a central social computer and network.'
     else:
         self.tdescription = self.typetitle + '|' + object_typeobj.description
     self.isaddscreen = False
     if hasattr(context_state.parent(),'portal_type') and context_state.parent().portal_type == 'TempFolder':
         self.isaddscreen = True
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:22,代码来源:typetitle.py

示例12: renameScrawl

def renameScrawl(portal_types):
    blog_fti = getattr(portal_types, 'Blog Entry')
    blog_fti.title = 'Blog Post'
    blog_fti.description = _(u"Formatted temporal content",u"Formatted temporal content")
    blog_fti.icon_expr = 'string:$portal_url/blog.png'
    blog_fti.global_allow = True
开发者ID:liberiun,项目名称:cynin-intranet,代码行数:6,代码来源:setuphandlers.py

示例13: _

import BTrees
import datetime
import calendar
from zope.component import queryMultiAdapter
from zope.contentprovider.interfaces import IContentProvider
from p4a.calendar import interfaces

from zope.i18n.locales import locales
from zope.i18n.interfaces import  IUserPreferredLanguages

from ubify.policy import CyninMessageFactory as _


DAYS = [
        _(u'Monday'),
        _(u'Tuesday'),
        _(u'Wednesday'),
        _(u'Thursday'),
        _(u'Friday'),
        _(u'Saturday'),
        _(u'Sunday'),
        ]

MONTHS = [
          _(u'N/A'),
          _(u'January'),
          _(u'February'),
          _(u'March'),
          _(u'April'),
          _(u'May'),
          _(u'June'),
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:31,代码来源:month.py

示例14: getAppTitleForContext

def getAppTitleForContext(context):
    tempid = _(u"activity_stream",u"Activity Stream")
    ptype = context.portal_type
    if ptype == 'Document':
        tempid = _(u"wiki",u"Wiki")
    elif ptype == 'File':
        tempid = _(u"files",u"Files")
    elif ptype == 'Image':
        tempid = _(u"images",u"Images")
    elif ptype == 'Link':
        tempid = _(u"links",u"Links")
    elif ptype == 'Blog Entry':
        tempid = _(u"blogs",u"Blogs")
    elif ptype == 'Event':
        tempid = _(u"calendar",u"Calendar")
    elif ptype == 'StatuslogItem':
        tempid = _(u"statuslog",u"Status Log")
    elif ptype == 'Video':
        tempid = _(u"videos",u"Videos")
    elif ptype == 'Discussion':
        tempid = _(u"Discussions",u"Discussions")
    elif ptype == 'Audio':
        tempid = _(u"Audios",u"Audios")

    return tempid
开发者ID:eaudeweb,项目名称:ubify.cyninv2theme,代码行数:25,代码来源:__init__.py

示例15: title

 def title(self):
     return _(u"Recent files")
开发者ID:Cenditel,项目名称:cenditel.comunidades.cynin,代码行数:2,代码来源:filesportlet.py


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