diff --git a/doc/version.txt b/doc/version.txt index 8240014..236d7fd 100644 --- a/doc/version.txt +++ b/doc/version.txt @@ -1,3 +1,6 @@ +0.5.5 (2010-04-21) +- Lots of minor improvements and implementation of first elements for a Plone3 generator. + 0.5.4 (2010-03-24) - Improved gen search screens and many more minor bugfixes and features. diff --git a/gen/plone25/installer.py b/gen/plone25/installer.py index 1245e83..1fa95b2 100644 --- a/gen/plone25/installer.py +++ b/gen/plone25/installer.py @@ -237,6 +237,7 @@ class PloneInstaller: # Creates the new-way templates for Pod fields if they do not exist. for contentType, attrNames in self.attributes.iteritems(): appyClass = self.tool.getAppyClass(contentType) + if not appyClass: continue # May be an abstract class for attrName in attrNames: appyType = getattr(appyClass, attrName) if appyType.type == 'Pod': diff --git a/gen/plone25/mixins/FlavourMixin.py b/gen/plone25/mixins/FlavourMixin.py index 1db86ff..52e1bfa 100644 --- a/gen/plone25/mixins/FlavourMixin.py +++ b/gen/plone25/mixins/FlavourMixin.py @@ -261,7 +261,7 @@ class FlavourMixin(AbstractMixin): being effectively used in the search screen.''' res = [] appyClass = self.getAppyClass(contentType) - for attrName in getattr(self, 'searchFieldsFor%s' % contentType): + for attrName in getattr(self, 'searchFieldsFor%s' % contentType, ()): attr = getattr(appyClass, attrName) dAttr = self._appy_getTypeAsDict(attrName, attr, appyClass) res.append((attrName, dAttr)) diff --git a/gen/plone25/mixins/ToolMixin.py b/gen/plone25/mixins/ToolMixin.py index bdb6883..f013462 100644 --- a/gen/plone25/mixins/ToolMixin.py +++ b/gen/plone25/mixins/ToolMixin.py @@ -333,13 +333,14 @@ class ToolMixin(AbstractMixin): '''Gets the Appy Python class that is related to p_contentType.''' # Retrieve first the Archetypes class corresponding to p_ContentType portalType = self.portal_types.get(contentType) + if not portalType: return None atClassName = portalType.getProperty('content_meta_type') appName = self.getProductConfig().PROJECTNAME exec 'from Products.%s.%s import %s as atClass' % \ (appName, atClassName, atClassName) # Get then the Appy Python class return atClass.wrapperClass.__bases__[-1] - + def getCreateMeans(self, contentTypeOrAppyClass): '''Gets the different ways objects of p_contentTypeOrAppyClass (which can be a Plone content type or a Appy class) can be created diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index 0d7b1be..b044502 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -261,7 +261,10 @@ class AbstractMixin: return t('%s_%s_list_%s' % (self.meta_type, name, v)) if not isinstance(v, basestring): # Archetypes "Description" fields may hold a BaseUnit instance. - v = unicode(v) + try: + v = unicode(v) + except UnicodeDecodeError: + v = str(v) return v elif vType == 'Boolean': if v: return self.translate('yes', domain='plone') diff --git a/gen/plone3/__init__.py b/gen/plone3/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gen/plone3/installer.py b/gen/plone3/installer.py new file mode 100644 index 0000000..3f76b7f --- /dev/null +++ b/gen/plone3/installer.py @@ -0,0 +1,38 @@ +'''This package contains stuff used at run-time for installing a generated + Plone product.''' + +# ------------------------------------------------------------------------------ +from appy.gen.plone25.installer import PloneInstaller as Plone25Installer + +class ZCTextIndexInfo: + '''Silly class used for storing information about a ZCTextIndex.''' + lexicon_id = "plone_lexicon" + index_type = 'Okapi BM25 Rank' + +class PloneInstaller(Plone25Installer): + '''This Plone installer runs every time the generated Plone product is + installed or uninstalled (in the Plone configuration interface).''' + @staticmethod + def updateIndexes(ploneSite, indexInfo, logger): + '''This method creates or updates, in a p_ploneSite, definitions of + indexes in its portal_catalog, based on index-related information + given in p_indexInfo. p_indexInfo is a dictionary of the form + {s_indexName:s_indexType}. Here are some examples of index types: + "FieldIndex", "ZCTextIndex", "DateIndex".''' + catalog = ploneSite.portal_catalog + indexNames = catalog.indexes() + for indexName, indexType in indexInfo.iteritems(): + if indexName not in indexNames: + # We need to create this index + if indexType != 'ZCTextIndex': + catalog.addIndex(indexName, indexType) + else: + catalog.addIndex(indexName,indexType,extra=ZCTextIndexInfo) + logger.info('Creating index "%s" of type "%s"...' % \ + (indexName, indexType)) + # Indexing database content based on this index. + catalog.reindexIndex(indexName, ploneSite.REQUEST) + logger.info('Done.') + # TODO: if the index already exists but has not the same type, we + # re-create it with the same type and we reindex it. +# ------------------------------------------------------------------------------