appy.bin: job.py: allow to specify several commands to execute (to separate with semicolons); appy.gen: translate: added the possibility to escape XML special chars in translations; appy.pod: bugfix in buffers.write: if content is already utf-8-encoded it does not crash anymore.
This commit is contained in:
parent
344229e3a9
commit
e38b78d10c
15
bin/job.py
15
bin/job.py
|
@ -18,7 +18,12 @@
|
|||
Zope object if previous param starts with "path=".
|
||||
|
||||
<args> (optional) are the arguments to give to this method (only strings
|
||||
are supported). Several arguments must be separated by '*'.'''
|
||||
are supported). Several arguments must be separated by '*'.
|
||||
|
||||
Note that you can also specify several commands, separated with
|
||||
semicolons (";"). This scripts performes a single commit after all commands
|
||||
have been executed.
|
||||
'''
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
import sys, transaction
|
||||
|
@ -28,12 +33,16 @@ if len(sys.argv) != 2:
|
|||
print 'job.py was called with wrong args.'
|
||||
print __doc__
|
||||
else:
|
||||
command = sys.argv[1]
|
||||
commands = sys.argv[1].split(';')
|
||||
# Check that every command has the right number of sub-elelements.
|
||||
for command in commands:
|
||||
parts = command.split(':')
|
||||
if len(parts) not in (4,5):
|
||||
print 'job.py was called with wrong args.'
|
||||
print __doc__
|
||||
else:
|
||||
|
||||
for command in commands:
|
||||
parts = command.split(':')
|
||||
# Unwrap parameters
|
||||
if len(parts) == 4:
|
||||
zopeUser, plonePath, appName, toolMethod = parts
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
- mixins/ToolMixin is mixed in with the generated application Tool class.'''
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
import os, os.path, sys, types, mimetypes, urllib
|
||||
import os, os.path, sys, types, mimetypes, urllib, cgi
|
||||
import appy.gen
|
||||
from appy.gen import Type, String, Selection, Role, No
|
||||
from appy.gen.utils import *
|
||||
|
@ -1173,8 +1173,9 @@ class BaseMixin:
|
|||
|
||||
def formatText(self, text, format='html'):
|
||||
'''Produces a representation of p_text into the desired p_format, which
|
||||
is 'html' by default.'''
|
||||
if format in ('html', 'xhtml'):
|
||||
is "html" by default.'''
|
||||
if 'html' in format:
|
||||
if format == 'html_from_text': text = cgi.escape(text)
|
||||
res = text.replace('\r\n', '<br/>').replace('\n', '<br/>')
|
||||
elif format == 'js':
|
||||
res = text.replace('\r\n', '').replace('\n', '')
|
||||
|
|
|
@ -250,9 +250,11 @@ class AbstractWrapper:
|
|||
'''Deletes myself.'''
|
||||
self.o.delete()
|
||||
|
||||
def translate(self, label, mapping={}, domain=None, language=None):
|
||||
def translate(self, label, mapping={}, domain=None, language=None,
|
||||
format='html'):
|
||||
'''Check documentation of self.o.translate.'''
|
||||
return self.o.translate(label, mapping, domain, language=language)
|
||||
return self.o.translate(label, mapping, domain, language=language,
|
||||
format=format)
|
||||
|
||||
def do(self, transition, comment='', doAction=False, doNotify=False,
|
||||
doHistory=True):
|
||||
|
|
|
@ -177,7 +177,10 @@ class FileBuffer(Buffer):
|
|||
def getLength(self): return 0
|
||||
|
||||
def write(self, something):
|
||||
try:
|
||||
self.content.write(something.encode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
self.content.write(something)
|
||||
|
||||
def addExpression(self, expression):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue