Improvement in xhtml->odt conversion (pod) + new search param for appy root classes and param 'indexed' for fields.

This commit is contained in:
Gaetan Delannay 2009-10-30 21:31:39 +01:00
parent cbd6fbbec5
commit 2b907fee32
11 changed files with 1742 additions and 1643 deletions

View file

@ -11,7 +11,7 @@ from utils import stringify
import appy.gen
import appy.gen.descriptors
from appy.gen.po import PoMessage
from appy.gen import Date, String, State, Transition, Type
from appy.gen import Date, String, State, Transition, Type, Search
from appy.gen.utils import GroupDescr, PageDescr, produceNiceMessage
TABS = 4 # Number of blanks in a Python indentation.
@ -433,10 +433,10 @@ class ArchetypesClassDescriptor(ClassDescriptor):
self.name = self.getClassName(klass)
self.generateSchema()
@staticmethod
def getClassName(klass):
'''Generates the name of the corresponding Archetypes class.'''
return klass.__module__.replace('.', '_') + '_' + klass.__name__
getClassName = staticmethod(getClassName)
def isAbstract(self):
'''Is self.klass abstract?'''
@ -475,6 +475,21 @@ class ArchetypesClassDescriptor(ClassDescriptor):
res = self.isFolder(theClass.__bases__[0])
return res
@staticmethod
def getSearches(klass):
'''Returns the list of searches that are defined on this class.'''
res = []
if klass.__dict__.has_key('search'):
searches = klass.__dict__['search']
if isinstance(searches, basestring): res.append(Search(searches))
elif isinstance(searches, Search): res.append(searches)
else:
# It must be a list of searches.
for search in searches:
if isinstance(search, basestring):res.append(Search(search))
else: res.append(search)
return res
def addGenerateDocMethod(self):
m = self.methods
spaces = TABS

View file

@ -675,6 +675,16 @@ class Generator(AbstractGenerator):
poMsgDescr = PoMessage('%s_%d_edit_descr' % (classDescr.name, i),
'', ' ')
self.labels.append(poMsgDescr)
# Remember i18n labels for searches
for search in classDescr.getSearches(classDescr.klass):
searchLabelId = '%s_search_%s' % (classDescr.name, search.name)
searchDescrId = '%s_descr' % searchLabelId
for label in (searchLabelId, searchDescrId):
default = ' '
if label == searchLabelId: default = search.name
poMsg = PoMessage(label, '', default)
poMsg.produceNiceDefault()
self.labels.append(poMsg)
# Generate the resulting Archetypes class and schema.
self.copyFile('ArchetypesTemplate.py', repls, destName=fileName)

View file

@ -319,11 +319,10 @@ class AbstractMixin:
if isinstance(fieldDescr, FieldDescr):
fieldDescr = fieldDescr.__dict__
appyType = fieldDescr['appyType']
if isEdit and (appyType['type']=='Ref') and appyType['add']:
return False
if isEdit and (appyType['type']=='Ref') and appyType['add']:return False
if isEdit and appyType['type']=='Action': return False
if (fieldDescr['widgetType'] == 'backField') and \
not self.getBRefs(fieldDescr['fieldRel']):
return False
not self.getBRefs(fieldDescr['fieldRel']): return False
# Do not show field if it is optional and not selected in flavour
if appyType['optional']:
tool = self.getTool()

View file

@ -26,9 +26,10 @@
function toggleViewableElements() {
var rows = cssQuery('#importedElem');
var newDisplay = 'table-row';
if (isIe) newDisplay = 'block';
if (importedElemsShown) newDisplay = 'none';
for (var i=0; i<rows.length; i++) {
rows[i].style.display = newDisplay;
rows[i].style.display = newDisplay;
}
importedElemsShown = !importedElemsShown;
}

View file

@ -103,7 +103,8 @@
</div>
<div metal:define-macro="showActionField">
<form name="executeAppyAction" action="skyn/do" method="POST">
<form name="executeAppyAction"
tal:attributes="action python: contextObj.absolute_url()+'/skyn/do'">
<input type="hidden" name="action" value="ExecuteAppyAction"/>
<input type="hidden" name="objectUid" tal:attributes="value contextObj/UID"/>
<input type="hidden" name="fieldName" tal:attributes="value field/getName"/>
@ -175,7 +176,7 @@
<tal:computedField condition="python: (not isEdit) and (appyType['type'] == 'Computed')">
<metal:cf use-macro="here/skyn/macros/macros/showComputedField" />
</tal:computedField>
<tal:actionField condition="python: (not isEdit) and (appyType['type'] == 'Action')">
<tal:actionField condition="python: appyType['type'] == 'Action'">
<metal:af use-macro="here/skyn/macros/macros/showActionField" />
</tal:actionField>
<tal:masterString condition="python: isEdit and (appyType['type'] in ('String', 'Boolean')) and (appyType['slaves'])">
@ -311,6 +312,7 @@
<tal:comment replace="nothing">"Static" javascripts</tal:comment>
<script language="javascript">
<!--
var isIe = (navigator.appName == "Microsoft Internet Explorer");
// AJAX machinery
var xhrObjects = new Array(); // An array of XMLHttpRequest objects
function XhrObject() { // Wraps a XmlHttpRequest object