dabo Commit
Revision 4238
Date: 2008-07-06 12:34:37 -0700 (Sun, 06 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4238
Changed:
U trunk/dabo/dObject.py
U trunk/dabo/lib/DesignerXmlConverter.py
U trunk/dabo/lib/propertyHelperMixin.py
Log:
Extended the handling of attProperties to all classes, not just those that
inherit from dPemMixin. This was the cause of the problems reported by Nate
Lowrie regarding grids created in the ClassDesigner, since dColumn is
subclassed directly from dObject, and setting the properties of dColumn objects
from attProperties was not being handled.
Diff:
Modified: trunk/dabo/dObject.py
===================================================================
--- trunk/dabo/dObject.py 2008-07-05 00:19:43 UTC (rev 4237)
+++ trunk/dabo/dObject.py 2008-07-06 19:34:37 UTC (rev 4238)
@@ -33,7 +33,7 @@
# the call to setProperties() at the end!
_call_beforeInit, _call_afterInit, _call_initProperties = True, True,
True
- def __init__(self, properties=None, *args, **kwargs):
+ def __init__(self, properties=None, attProperties=None, *args,
**kwargs):
if not hasattr(self, "_properties"):
self._properties = {}
if self._call_beforeInit:
@@ -45,6 +45,24 @@
# see if there are properties sent to the constructor which
will augment
# or override the properties set in beforeInit().
+ # Some classes that are not inherited from the ui-layer PEM
mixin classes
+ # can have attProperties passed. Since these are all passed as
strings, we
+ # need to convert them to their proper type and add them to the
properties
+ # dict.
+ if properties is None:
+ properties = {}
+ if attProperties:
+ for prop, val in attProperties.items():
+ if prop in ("designerClass", ):
+ continue
+ if prop in properties:
+ # The properties value has precedence,
so ignore.
+ continue
+ typ = type(getattr(self, prop))
+ if not issubclass(typ, basestring):
+ val = typ(val)
+ properties[prop] = val
+
# The keyword properties can come from either, both, or none of:
# + the properties dict
# + the kwargs dict
@@ -54,9 +72,6 @@
for k,v in properties.items():
self._properties[k] = v
properties = self._extractKeywordProperties(kwargs,
self._properties)
-# if kwargs:
-# # Some kwargs haven't been handled.
-# raise TypeError, _("__init__() got an unexpected
keyword argument '%s'") % kwargs.keys()[0]
if kwargs:
# Some kwargs haven't been handled.
bad = ", ".join(["'%s'" % kk for kk in kwargs.keys()])
Modified: trunk/dabo/lib/DesignerXmlConverter.py
===================================================================
--- trunk/dabo/lib/DesignerXmlConverter.py 2008-07-05 00:19:43 UTC (rev
4237)
+++ trunk/dabo/lib/DesignerXmlConverter.py 2008-07-06 19:34:37 UTC (rev
4238)
@@ -756,7 +756,6 @@
"""
self._grdColText = """ col = dabo.ui.dColumn(obj,
attProperties=%(kidCleanAtts)s)
obj.addColumn(col)
- col.setPropertiesFromAtts(%(kidCleanAtts)s)
"""
self._pgfPageText = """ pg =
%(moduleString)s%(nm)s(%(prntName)s%(attPropString)s)
%(prntName)s.appendPage(pg)
Modified: trunk/dabo/lib/propertyHelperMixin.py
===================================================================
--- trunk/dabo/lib/propertyHelperMixin.py 2008-07-05 00:19:43 UTC (rev
4237)
+++ trunk/dabo/lib/propertyHelperMixin.py 2008-07-06 19:34:37 UTC (rev
4238)
@@ -230,21 +230,6 @@
else:
raise AttributeError, "'%s' is not a
property." % prop
setattr(self, prop, val)
-# if isinstance(eval("self.%s" % prop), basestring):
-# # If this is property holds strings, we need to
quote the value.
-# try:
-# exec("self.%s = '%s'" % (prop, val) )
-# except :
-# raise ValueError, "Could not set
property '%s' to value: %s" % (prop, val)
-# else:
-# try:
-# exec("self.%s = %s" % (prop, val) )
-# except:
-# # Still could be a string, if the
original value was None
-# try:
-# exec("self.%s = '%s'" % (prop,
val) )
-# except:
-# raise ValueError, "Could not
set property '%s' to value: %s" % (prop, val)
def _setKwEventBindings(self, kwEvtDict):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]