diff --git a/gen/__init__.py b/gen/__init__.py index 54c3105..4a174c7 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -137,8 +137,8 @@ class Group: self.css_class = css_class self.master = None self.masterValue = None - if self.master: - self._addMaster(self, master, masterValue) + if master: + self._addMaster(master, masterValue) def _addMaster(self, master, masterValue): '''Specifies this group being a slave of another field: we will add css @@ -545,9 +545,12 @@ class Type: # Get the global default layouts layouts = copy.deepcopy(defaultFieldLayouts) else: - if isinstance(layouts, basestring) or isinstance(layouts, Table): + if isinstance(layouts, basestring): # The user specified a single layoutString (the "edit" one) layouts = {'edit': layouts} + elif isinstance(layouts, Table): + # Idem, but with a Table instance + layouts = {'edit': Table(other=layouts)} else: layouts = copy.deepcopy(layouts) # Here, we make a copy of the layouts, because every layout can @@ -1260,7 +1263,7 @@ class Ref(Type): group=None, layouts=None, showHeaders=False, shownInfo=(), select=None, maxPerPage=30, move=0, indexed=False, searchable=False, specificReadPermission=False, - specificWritePermission=False, width=None, height=None, + specificWritePermission=False, width=None, height=5, colspan=1, master=None, masterValue=None, focus=False, historized=False): self.klass = klass diff --git a/gen/layout.py b/gen/layout.py index f4d1eef..21738fe 100644 --- a/gen/layout.py +++ b/gen/layout.py @@ -136,7 +136,7 @@ class Table(LayoutElement): self.layoutString = Table.deriveLayout(other.layoutString, derivedType) else: - self.layoutString = layoutString + self.layoutString = other.layoutString source = 'other.' else: source = '' diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index f865f90..b7b7a5c 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -17,6 +17,14 @@ class BaseMixin: a subclass of it.''' _appy_meta_type = 'Class' + def get_o(self): + '''In some cases, we wand the Zope object, we don't know if the current + object is a Zope or Appy object. By defining this property, + "someObject.o" produces always the Zope object, be someObject an Appy + or Zope object.''' + return self + o = property(get_o) + def createOrUpdate(self, created, values): '''This method creates (if p_created is True) or updates an object. p_values are manipulated versions of those from the HTTP request. @@ -283,8 +291,7 @@ class BaseMixin: ((prev == '') and (curr == None)): del previousData[field] if (appyType.type == 'Ref') and (field in previousData): - titles = [r.title for r in previousData[field]] - previousData[field] = ','.join(titles) + previousData[field] = [r.title for r in previousData[field]] if previousData: self.addDataChange(previousData) @@ -510,10 +517,15 @@ class BaseMixin: return phaseInfo # If I am here, it means that the page as defined in the request, # or 'main' by default, is not existing nor visible in any phase. - # In this case I set the page as being the first visible page in - # the first visible phase. - rq.set('page', res[0]['pages'][0]) - return res[0] + # In this case I find the first visible page among all phases. + viewAttr = 'showOn%s' % layoutType.capitalize() + for phase in res: + for page in phase['pages']: + if phase['pagesInfo'][page][viewAttr]: + rq.set('page', page) + pageFound = True + break + return phase else: return res diff --git a/gen/plone25/model.py b/gen/plone25/model.py index 77e4a0a..8b59967 100644 --- a/gen/plone25/model.py +++ b/gen/plone25/model.py @@ -149,7 +149,7 @@ class Tool(ModelClass): res.optional = False res.show = True res.group = copy.copy(appyType.group) - res.phase = 'main' + res.page = copy.copy(appyType.page) # Set default layouts for all Tool fields res.layouts = res.formatLayouts(None) res.specificReadPermission = False @@ -177,7 +177,7 @@ class Tool(ModelClass): fieldType.validator = [] klass._appy_addField(fieldName, fieldType, fieldDescr.classDescr) fieldType.validator.append(fieldDescr.fieldName) - fieldType.page = 'data' + fieldType.page.name = 'data' fieldType.group = Group(fieldDescr.classDescr.klass.__name__) @classmethod @@ -186,7 +186,7 @@ class Tool(ModelClass): fieldName = 'defaultValueFor%s_%s' % (className, fieldDescr.fieldName) fieldType = klass._appy_copyField(fieldDescr.appyType) klass._appy_addField(fieldName, fieldType, fieldDescr.classDescr) - fieldType.page = 'data' + fieldType.page.name = 'data' fieldType.group = Group(fieldDescr.classDescr.klass.__name__) @classmethod diff --git a/gen/plone25/skin/widgets/ref.pt b/gen/plone25/skin/widgets/ref.pt index e19c40d..88b7f34 100644 --- a/gen/plone25/skin/widgets/ref.pt +++ b/gen/plone25/skin/widgets/ref.pt @@ -258,7 +258,7 @@ refUids python: [o.UID() for o in contextObj.getAppyRefs(name)['objects']]; isBeingCreated python: contextObj.isTemporary() or ('/portal_factory/' in contextObj.absolute_url())"> -