new.py now can create instances for Plone 2.5.5, Plone 3.0 to Plone 3.3.5. specificWritePermission and specificReadPermission can hold named (string) permissions instead of simple boolean values (which is still allowed). frontPage can call a custom macro. When launching generate.py with -c option, labels prefixed with custom_ are kept.

This commit is contained in:
Gaetan Delannay 2010-08-12 11:56:42 +02:00
parent bfd2357f69
commit dbcadc506d
17 changed files with 188 additions and 126 deletions

View file

@ -74,8 +74,16 @@ class ToolMixin(AbstractMixin):
'''Returns the list of root classes for this application.'''
return self.getProductConfig().rootClasses
def showPortlet(self):
return not self.portal_membership.isAnonymousUser()
def showPortlet(self, context):
if self.portal_membership.isAnonymousUser(): return False
if context.id == 'skyn': context = context.getParentNode()
res = True
if not self.getRootClasses():
res = False
# If there is no root class, show the portlet only if we are within
# the configuration.
if (self.id in context.absolute_url()): res = True
return res
def getObject(self, uid, appy=False):
'''Allows to retrieve an object from its p_uid.'''
@ -630,7 +638,7 @@ class ToolMixin(AbstractMixin):
contentType, flavourNumber = d1.split(':')
flavourNumber = int(flavourNumber)
searchName = keySuffix = d2
batchSize = self.getNumberOfResultsPerPage()
batchSize = self.appy().numberOfResultsPerPage
if not searchName: keySuffix = contentType
s = self.REQUEST.SESSION
searchKey = 'search_%s_%s' % (flavourNumber, keySuffix)

View file

@ -285,23 +285,23 @@ class AbstractMixin:
'''Returns the method named p_methodName.'''
return getattr(self, methodName, None)
def getFormattedValue(self, name, useParamValue=False, value=None,
forMasterId=False):
def getFieldValue(self, name, useParamValue=False, value=None,
formatted=True):
'''Returns the value of field named p_name for this object (p_self).
If p_useParamValue is True, the method uses p_value instead of the
real field value (useful for rendering a value from the object
history, for example).
If p_forMasterId is True, it returns the value as will be needed to
produce an identifier used within HTML pages for master/slave
relationships.'''
If p_formatted is False, it will return the true database
(or default) value. Else, it will produce a nice, string and
potentially translated value.'''
appyType = self.getAppyType(name)
# Which value will we use ?
if not useParamValue:
value = appyType.getValue(self)
# Return the value as is if it is None or forMasterId
if forMasterId: return value
if not formatted: return value
# Return the formatted value else
return appyType.getFormattedValue(self, value)
@ -741,7 +741,7 @@ class AbstractMixin:
res = brains
return res
def fieldValueSelected(self, fieldName, vocabValue):
def fieldValueSelected(self, fieldName, vocabValue, dbValue):
'''When displaying a selection box (ie a String with a validator being a
list), must the _vocabValue appear as selected?'''
rq = self.REQUEST
@ -749,14 +749,14 @@ class AbstractMixin:
if rq.has_key(fieldName):
compValue = rq.get(fieldName)
else:
compValue = self.getAppyType(fieldName).getValue(self)
compValue = dbValue
# Compare the value
if type(compValue) in sequenceTypes:
if vocabValue in compValue: return True
else:
if vocabValue == compValue: return True
def checkboxChecked(self, fieldName):
def checkboxChecked(self, fieldName, dbValue):
'''When displaying a checkbox, must it be checked or not?'''
rq = self.REQUEST
# Get the value we must compare (from request or from database)
@ -764,11 +764,11 @@ class AbstractMixin:
compValue = rq.get(fieldName)
compValue = compValue in ('True', 1, '1')
else:
compValue = self.getAppyType(fieldName).getValue(self)
compValue = dbValue
# Compare the value
return compValue
def dateValueSelected(self, fieldName, fieldPart, dateValue):
def dateValueSelected(self, fieldName, fieldPart, dateValue, dbValue):
'''When displaying a date field, must the particular p_dateValue be
selected in the field corresponding to the date part?'''
# Get the value we must compare (from request or from database)
@ -779,7 +779,7 @@ class AbstractMixin:
if compValue.isdigit():
compValue = int(compValue)
else:
compValue = self.getAppyType(fieldName).getValue(self)
compValue = dbValue
if compValue:
compValue = getattr(compValue, fieldPart)()
# Compare the value