Commit 6c0eae95 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_forge: Migrate Glossary Extension to ZODB Property Sheets and Portal Types as classes.

Using the legacy API was broken and this is also to prepare
DocumentationHelper and ClassTool removal.
parent 817fe756
...@@ -3,34 +3,35 @@ def setPortalTypeDescription(self, portal_type, description): ...@@ -3,34 +3,35 @@ def setPortalTypeDescription(self, portal_type, description):
'description', description) 'description', description)
def getPropertySheetList(self, portal_type): def getPropertySheetList(self, portal_type):
from Products.ERP5Type.DocumentationHelper.PortalTypeDocumentationHelper \ import erp5.portal_type
import PortalTypeDocumentationHelper
portal = self.getPortalObject()
portal_type_uri = '%s/portal_types/%s' % (portal.getUrl(),
portal_type)
return PortalTypeDocumentationHelper(portal_type_uri).__of__(
portal).getPropertySheetList()
return (getattr(self.getPortalObject().portal_types, portal_type).getTypePropertySheetList() +
list(getattr(erp5.portal_type, portal_type).property_sheets))
def getPropertySheetAttributeList(self, name): def getPropertySheetAttributeList(self, name):
from Products.ERP5Type import PropertySheet portal = self.getPortalObject()
class_ = PropertySheet.__dict__.get(name, None) try:
property_sheet_obj = portal.portal_property_sheets[name]
except KeyError:
return []
result = [] result = []
for i in getattr(class_, '_properties', ()): # We don't want Acquired Property nor Category TALES Expression
if 'acquired_property_id' in i: for property_obj in property_sheet_obj.contentValues(portal_type=('Category Property',
continue 'Standard Property')):
# we want to get only normal property. reference = property_obj.getReference('')
result.append((i['id'], i.get('description', ''))) description = ''
for i in getattr(class_, '_categories', ()): if property_obj.getPortalType() == 'Category Property':
try: try:
result.append((i, self.getPortalObject().portal_categories[i].getDescription())) description = portal.portal_categories[reference].getDescription('')
except KeyError: except KeyError:
result.append((i, ''))
except TypeError:
# if category is Expression(...), TypeError raises
pass pass
return result else:
description = property_obj.getDescription('')
result.append((reference, description))
return result
def getActionTitleListFromAllActionProvider(portal): def getActionTitleListFromAllActionProvider(portal):
result = [] result = []
......
2014-02-19 Arnaud Fontaine
* Migrate Glossary Extension to ZODB Property Sheets and Portal Types as classes.
2013-09-03 arnaud.fontaine 2013-09-03 arnaud.fontaine
* ZODB Components: Workflow History must always be kept, so avoid an extra step for developers. * ZODB Components: Workflow History must always be kept, so avoid an extra step for developers.
......
678 679
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment