From: Kevin A. <al...@se...> - 2005-04-04 18:15:27
|
On Apr 4, 2005, at 9:52 AM, Kevin Altis wrote: > > I don't know why this never came up before, but I bet there is a > problem if you want to have a component named parent, data, or order, > so I probably need to test that, then change them to have leading > underscores or something like that in the future, which also means > updating the resourceEditor and perhaps some other tools. I'm not sure > if I'll get to that this week before I leave for the UK or not. > I retract this last part. Given that there are a number of methods and attributes that should be "protected" it makes more sense to change the places where you can set the component name to present an error dialog that disallows the "protected" names for methods and internal attributes. I think that would just be the strings in the list returned by dir() since the component names are really in the internal item 'data' and don't get exposed by dir. >>> dir(self.components) ['__cmp__', '__contains__', '__delitem__', '__doc__', '__getattr__', '__getitem__', '__init__', '__len__', '__module__', '__repr__', '__setattr__', '__setitem__', '_getAttributeNames', '_listeners', 'addChangeEventListener', 'clear', 'copy', 'data', 'fireChanged', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'order', 'parent', 'pop', 'popitem', 'setdefault', 'update', 'values'] So the code to protect invalid names just has to do if name in dir(self.components): # alert dialog, etc. here asking for a different name Anyone see a problem with this? The __setitem__ method could also protect itself and throw an exception if we get a component name that would cause a problem. BTW, these developer type issues will very soon start appearing only on the pythoncard-devel mailing list for those of you that want to be involved in this kind of stuff and want to sign-up. http://lists.sourceforge.net/lists/listinfo/pythoncard-devel I just submitted a request to gmane to add gmane.comp.python.pythoncard.devel as well. ka |