Changeset 4238

Show
Ignore:
Timestamp:
07/06/08 12:34:37 (5 months ago)
Author:
ed
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dObject.py

    r4179 r4238  
    3434    _call_beforeInit, _call_afterInit, _call_initProperties = True, True, True 
    3535 
    36     def __init__(self, properties=None, *args, **kwargs): 
     36    def __init__(self, properties=None, attProperties=None, *args, **kwargs): 
    3737        if not hasattr(self, "_properties"): 
    3838            self._properties = {} 
     
    4646        # or override the properties set in beforeInit(). 
    4747         
     48        # Some classes that are not inherited from the ui-layer PEM mixin classes 
     49        # can have attProperties passed. Since these are all passed as strings, we 
     50        # need to convert them to their proper type and add them to the properties 
     51        # dict. 
     52        if properties is None: 
     53            properties = {} 
     54        if attProperties: 
     55            for prop, val in attProperties.items(): 
     56                if prop in ("designerClass", ): 
     57                    continue 
     58                if prop in properties: 
     59                    # The properties value has precedence, so ignore. 
     60                    continue 
     61                typ = type(getattr(self, prop)) 
     62                if not issubclass(typ, basestring): 
     63                    val = typ(val) 
     64                properties[prop] = val 
     65 
    4866        # The keyword properties can come from either, both, or none of: 
    4967        #    + the properties dict 
     
    5573                self._properties[k] = v 
    5674        properties = self._extractKeywordProperties(kwargs, self._properties) 
    57 #       if kwargs: 
    58 #           # Some kwargs haven't been handled. 
    59 #           raise TypeError, _("__init__() got an unexpected keyword argument '%s'") % kwargs.keys()[0] 
    6075        if kwargs: 
    6176            # Some kwargs haven't been handled. 
  • trunk/dabo/lib/DesignerXmlConverter.py

    r4183 r4238  
    757757        self._grdColText = """      col = dabo.ui.dColumn(obj, attProperties=%(kidCleanAtts)s) 
    758758        obj.addColumn(col) 
    759         col.setPropertiesFromAtts(%(kidCleanAtts)s) 
    760759""" 
    761760        self._pgfPageText = """     pg = %(moduleString)s%(nm)s(%(prntName)s%(attPropString)s) 
  • trunk/dabo/lib/propertyHelperMixin.py

    r4190 r4238  
    231231                    raise AttributeError, "'%s' is not a property." % prop 
    232232            setattr(self, prop, val) 
    233 #           if isinstance(eval("self.%s" % prop), basestring): 
    234 #               # If this is property holds strings, we need to quote the value. 
    235 #               try: 
    236 #                   exec("self.%s = '%s'" % (prop, val) ) 
    237 #               except : 
    238 #                   raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
    239 #           else: 
    240 #               try: 
    241 #                   exec("self.%s = %s" % (prop, val) ) 
    242 #               except: 
    243 #                   # Still could be a string, if the original value was None 
    244 #                   try: 
    245 #                       exec("self.%s = '%s'" % (prop, val) ) 
    246 #                   except: 
    247 #                       raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
    248233         
    249234