示例#1
0
def runModule():
	print(_('Hello world'))

	numb1 = 1
	numb2 = 2
	#Former format string: 'This is a formatted string: %2d %d' % (numb1, numb2)
	#For translated strings: use keys or at least indexes for translaters to change position of replaced strings!
	print(_('This is a formatted string: {n1:2d} {n2:d}').format(n1=numb1, n2=numb2))
	print(_('This is a formatted string: {0:2d} {1:d}').format(numb1, numb2))
	print(_('This is a formatted string: %(n1)2d %(n2)d') % {'n1':numb1, 'n2':numb2})
	
	side.runSide()  
示例#2
0
 def handleApply(self, action):
     sm = getSecurityManager()
     portal = api.portal.get()
     data, errors = self.extractData()
     if errors:
         self.status = _("Please correct errors")
         return
     try:
         inner_contenttype = self.filter_inner_contenttype(data)
         try:
             # go Admin, even in anymomous mode !
             tmp_user = UnrestrictedUser(
                 sm.getUser().getId(), '', ['Manager'], '')
             tmp_user = tmp_user.__of__(portal.acl_users)
             newSecurityManager(None, tmp_user)
             # Call the function
             # for edit form, use : self.applyChanges(data)
             obj = self.createAndAdd(data)
             # context is the mainobj repo
             obj = obj.__of__(self.context)
             self.applyInner_contenttype(obj, inner_contenttype)
             contextURL = self.context.absolute_url()
             self.request.response.redirect(contextURL)
         except Exception:
             # If special exception handlers are needed, run them here
             raise
     finally:
         # Restore the old security manager
         setSecurityManager(sm)
示例#3
0
from zope import schema
from zope.interface import alsoProvides, Interface, implements

from zope.lifecycleevent import ObjectCreatedEvent
from zope.lifecycleevent.interfaces import IObjectCreatedEvent

from zope.schema import ValidationError
from zope.schema.vocabulary import SimpleVocabulary

from sample.utils import dummyfactory
from sample import MessageFactory as _


logger = logging.getLogger('sample')

mainobjMainLaboratory = _(u'mainobj main research unit')
reviewerwaitforcorrections = _(u'Reviewer wait for corrections')


class UnrestrictedUser(BaseUnrestrictedUser):
    """Unrestricted user that still has an id.
    """
    def getId(self):
        """Return the ID of the user.
        """
        return "Anonymousmainobj"


class Iinner_contenttype(form.Schema):
    """
    Description of the inner content type"