More input and output formats for OO conversion in converter.py and bugfix in skyn edit.
This commit is contained in:
parent
fff2b6a329
commit
e89eda4838
7 changed files with 190 additions and 113 deletions
|
@ -355,7 +355,7 @@ class Ref(Type):
|
|||
|
||||
class Computed(Type):
|
||||
def __init__(self, validator=None, multiplicity=(0,1), index=None,
|
||||
default=None, optional=False, editDefault=False, show=True,
|
||||
default=None, optional=False, editDefault=False, show='view',
|
||||
page='main', group=None, move=0, indexed=False,
|
||||
searchable=False, specificReadPermission=False,
|
||||
specificWritePermission=False, width=None, height=None,
|
||||
|
|
|
@ -33,9 +33,13 @@ class AbstractMixin:
|
|||
# creates the final object from the temp object.
|
||||
previousData = None
|
||||
if not created: previousData = self.rememberPreviousData()
|
||||
# We do not process form data (=real update on the object) if the tool
|
||||
# itself is being created.
|
||||
if obj._appy_meta_type != 'tool': obj.processForm()
|
||||
# Perform the change on the object, unless self is a tool being created.
|
||||
if (obj._appy_meta_type == 'tool') and created:
|
||||
# We do not process form data (=real update on the object) if the
|
||||
# tool itself is being created.
|
||||
pass
|
||||
else:
|
||||
obj.processForm()
|
||||
if previousData:
|
||||
# Keep in history potential changes on historized fields
|
||||
self.historizeData(previousData)
|
||||
|
@ -389,7 +393,7 @@ class AbstractMixin:
|
|||
fieldDescr = fieldDescr.__dict__
|
||||
appyType = fieldDescr['appyType']
|
||||
if isEdit and (appyType['type']=='Ref') and appyType['add']:return False
|
||||
if isEdit and (appyType['type'] in ('Action', 'Computed')): return False
|
||||
if isEdit and (appyType['type'] == 'Action'): return False
|
||||
if (fieldDescr['widgetType'] == 'backField') and \
|
||||
not self.getBRefs(fieldDescr['fieldRel']): return False
|
||||
# Do not show field if it is optional and not selected in flavour
|
||||
|
|
|
@ -3,23 +3,19 @@
|
|||
errors request/errors | python:{};
|
||||
Iterator python:modules['Products.Archetypes'].IndexIterator;
|
||||
schematas contextObj/Schemata;
|
||||
fieldsets python:[key for key in schematas.keys() if (key != 'metadata') and (schematas[key].editableFields(here, visible_only=True))];
|
||||
fieldsets python:[key for key in schematas.keys() if (key != 'metadata') and (schematas[key].editableFields(contextObj, visible_only=True))];
|
||||
default_fieldset python:(not schematas or schematas.has_key('default')) and 'default' or fieldsets[0];
|
||||
fieldset request/fieldset|options/fieldset|default_fieldset;
|
||||
fields python:schematas[fieldset].editableFields(here);
|
||||
dummy python:here.at_isEditable(fields);
|
||||
portal_type python:here.getPortalTypeName().lower().replace(' ', '_');
|
||||
type_name here/getPortalTypeName|here/archetype_name;
|
||||
lockable python:hasattr(here, 'wl_isLocked');
|
||||
isLocked python:lockable and here.wl_isLocked();
|
||||
tabindex tabindex|python:Iterator(pos=7000);
|
||||
fields python:schematas[fieldset].editableFields(contextObj);
|
||||
lockable python:hasattr(contextObj, 'wl_isLocked');
|
||||
isLocked python:lockable and contextObj.wl_isLocked();
|
||||
isEdit python:True;
|
||||
tool contextObj/getTool;
|
||||
flavour python: tool.getFlavour(contextObj);
|
||||
appFolder tool/getAppFolder;
|
||||
appName appFolder/id;
|
||||
css python:here.getUniqueWidgetAttr(fields, 'helper_css');
|
||||
js python:here.getUniqueWidgetAttr(fields, 'helper_js');
|
||||
css python:contextObj.getUniqueWidgetAttr(fields, 'helper_css');
|
||||
js python:contextObj.getUniqueWidgetAttr(fields, 'helper_js');
|
||||
phaseInfo python: contextObj.getAppyPhases(fieldset=fieldset, forPlone=True);
|
||||
phase request/phase|phaseInfo/name;
|
||||
pageName python: contextObj.getAppyPage(isEdit, phaseInfo);">
|
||||
|
@ -91,24 +87,20 @@
|
|||
<tal:previousButton condition="python: pageIndex > 0">
|
||||
<input class="context" type="submit" name="buttonPrevious"
|
||||
i18n:attributes="value label_previous;" i18n:domain="plone"
|
||||
tal:attributes="tabindex tabindex/next;
|
||||
disabled python:test(isLocked, 'disabled', None);"/>
|
||||
tal:attributes="disabled python:test(isLocked, 'disabled', None);"/>
|
||||
<input type="hidden" name="previousPage" tal:attributes="value python: pages[pageIndex-1]"/>
|
||||
</tal:previousButton>
|
||||
<tal:nextButton condition="python: pageIndex < numberOfPages - 1">
|
||||
<input class="context" type="submit" name="buttonNext" value="Next"
|
||||
i18n:attributes="value label_next;" i18n:domain="plone"
|
||||
tal:attributes="tabindex tabindex/next;
|
||||
disabled python:test(isLocked, 'disabled', None);"/>
|
||||
tal:attributes="disabled python:test(isLocked, 'disabled', None);"/>
|
||||
<input type="hidden" name="nextPage" tal:attributes="value python: pages[pageIndex+1]"/>
|
||||
</tal:nextButton>
|
||||
<input class="context" type="submit" name="buttonOk"
|
||||
i18n:attributes="value label_save;" i18n:domain="plone"
|
||||
tal:attributes="tabindex tabindex/next;
|
||||
disabled python:test(isLocked, 'disabled', None);"/>
|
||||
tal:attributes="disabled python:test(isLocked, 'disabled', None);"/>
|
||||
<input class="standalone" type="submit" name="buttonCancel"
|
||||
i18n:attributes="value label_cancel;" i18n:domain="plone"
|
||||
tal:attributes="tabindex tabindex/next"/>
|
||||
i18n:attributes="value label_cancel;" i18n:domain="plone"/>
|
||||
</metal:block>
|
||||
</form>
|
||||
<div metal:use-macro="here/skyn/macros/macros/showPageFooter"/>
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
<metal:editRef use-macro="here/skyn/ref/macros/editReference" />
|
||||
</tal:ref>
|
||||
</tal:editRef>
|
||||
<tal:computedField condition="python: (not isEdit) and (appyType['type'] == 'Computed')">
|
||||
<tal:computedField condition="python: appyType['type'] == 'Computed'">
|
||||
<metal:cf use-macro="here/skyn/macros/macros/showComputedField" />
|
||||
</tal:computedField>
|
||||
<tal:actionField condition="python: appyType['type'] == 'Action'">
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
developer the real classes used by the underlying web framework.'''
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
import time, os.path, mimetypes, unicodedata, random
|
||||
import os, os.path, time, mimetypes, unicodedata, random
|
||||
import appy.pod
|
||||
from appy.gen import Search
|
||||
from appy.gen.utils import sequenceTypes
|
||||
from appy.shared.utils import getOsTempFolder
|
||||
|
@ -236,15 +237,23 @@ class AbstractWrapper:
|
|||
wfTool.doActionFor(self.o, transitionName, comment=comment)
|
||||
del self.o._v_appy_do
|
||||
|
||||
def log(self, message, logLevel='info'):
|
||||
def log(self, message, type='info'):
|
||||
'''Logs a message in the log file. p_logLevel may be "info", "warning"
|
||||
or "error".'''
|
||||
logger = self.o.getProductConfig().logger
|
||||
if logLevel == 'warning': logMethod = logger.warn
|
||||
elif logLevel == 'error': logMethod = logger.error
|
||||
if type == 'warning': logMethod = logger.warn
|
||||
elif type == 'error': logMethod = logger.error
|
||||
else: logMethod = logger.info
|
||||
logMethod(message)
|
||||
|
||||
def say(self, message, type='info'):
|
||||
'''Prints a message in the user interface. p_logLevel may be "info",
|
||||
"warning" or "error".'''
|
||||
mType = type
|
||||
if mType == 'warning': mType = 'warn'
|
||||
elif mType == 'error': mType = 'stop'
|
||||
self.o.plone_utils.addPortalMessage(message, type=mType)
|
||||
|
||||
def normalize(self, s):
|
||||
'''Returns a version of string p_s whose special chars have been
|
||||
replaced with normal chars.'''
|
||||
|
@ -338,11 +347,16 @@ class FileWrapper:
|
|||
raise 'Impossible to set attribute %s. "Settable" attributes ' \
|
||||
'are "name", "content" and "mimeType".' % name
|
||||
|
||||
def dump(self, filePath=None):
|
||||
def dump(self, filePath=None, format=None, tool=None):
|
||||
'''Writes the file on disk. If p_filePath is specified, it is the
|
||||
path name where the file will be dumped; folders mentioned in it
|
||||
must exist. If not, the file will be dumped in the OS temp folder.
|
||||
The absolute path name of the dumped file is returned.'''
|
||||
The absolute path name of the dumped file is returned.
|
||||
If an error occurs, the method returns None. If p_format is
|
||||
specified, OpenOffice will be called for converting the dumped file
|
||||
to the desired format. In this case, p_tool, a Appy tool, must be
|
||||
provided. Indeed, any Appy tool contains parameters for contacting
|
||||
OpenOffice in server mode.'''
|
||||
if not filePath:
|
||||
filePath = '%s/file%f.%s' % (getOsTempFolder(), time.time(),
|
||||
self.name)
|
||||
|
@ -358,5 +372,20 @@ class FileWrapper:
|
|||
# Only one chunk
|
||||
f.write(self.content)
|
||||
f.close()
|
||||
if format:
|
||||
if not tool: return
|
||||
# Convert the dumped file using OpenOffice
|
||||
convScript = '%s/converter.py' % os.path.dirname(appy.pod.__file__)
|
||||
cmd = '%s %s "%s" %s -p%d' % (tool.unoEnabledPython, convScript,
|
||||
filePath, format, tool.openOfficePort)
|
||||
res = os.system(cmd)
|
||||
os.remove(filePath)
|
||||
if res != 0: return
|
||||
# Return the name of the converted file.
|
||||
baseName, ext = os.path.splitext(filePath)
|
||||
if (ext == '.%s' % format):
|
||||
filePath = '%s.res.%s' % (baseName, format)
|
||||
else:
|
||||
filePath = '%s.%s' % (baseName, format)
|
||||
return filePath
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue