appy.gen: bugfix with the master/slave mechanism while launching Zope in debug mode; added boolean attribute Date.reverseYears allowing to display years in reverse order in the widgets for choosing the year; bugfix in Javascript code for hiding slave widgets with Google Chrome.

This commit is contained in:
Gaetan Delannay 2011-03-25 18:03:45 +01:00
parent a608a9b43f
commit 36237c3ee5
6 changed files with 35 additions and 40 deletions

View file

@ -467,6 +467,10 @@ class Type:
attributes that are based on the name of the Appy p_klass, and the
application name (p_appName).'''
self.name = name
# Recompute the ID (and derived attributes) that may have changed if
# we are in debug mode (because we recreate new Type instances).
self.id = id(self)
if self.slaves: self.master_css = 'appyMaster master_%s' % self.id
# Determine ids of i18n labels for this field
if not klass: prefix = appName
else: prefix = getClassName(klass, appName)
@ -1381,9 +1385,9 @@ class Date(Type):
default=None, optional=False, editDefault=False,
format=WITH_HOUR, calendar=True,
startYear=time.localtime()[0]-10,
endYear=time.localtime()[0]+10, show=True, page='main',
group=None, layouts=None, move=0, indexed=False,
searchable=False, specificReadPermission=False,
endYear=time.localtime()[0]+10, reverseYears=False,
show=True, page='main', group=None, layouts=None, move=0,
indexed=False, searchable=False, specificReadPermission=False,
specificWritePermission=False, width=None, height=None,
colspan=1, master=None, masterValue=None, focus=False,
historized=False, mapping=None):
@ -1391,6 +1395,9 @@ class Date(Type):
self.calendar = calendar
self.startYear = startYear
self.endYear = endYear
# If reverseYears is True, in the selection box, available years, from
# self.startYear to self.endYear will be listed in reverse order.
self.reverseYears = reverseYears
Type.__init__(self, validator, multiplicity, index, default, optional,
editDefault, show, page, group, layouts, move, indexed,
searchable, specificReadPermission,
@ -1406,6 +1413,12 @@ class Date(Type):
return ('jscalendar/calendar_stripped.js',
'jscalendar/calendar-en.js')
def getSelectableYears(self):
'''Gets the list of years one may select for this field.'''
res = range(self.startYear, self.endYear + 1)
if self.reverseYears: res.reverse()
return res
def validateValue(self, obj, value):
DateTime = obj.getProductConfig().DateTime
try: