> Widget's, for example, are one thing you'd like to reuse in many requests,
> hence better not instantiate them unnecesarily.
Sure. What I'm objecting to is that they are instantiated (if you're
using the WidgetsDeclaration syntax) when the class is defined. I'm
fairly new to Python, so maybe it's un-Pythonic to say it, but I don't
think importing a file should execute code, in general. (Yes, I know
that 'class' is an executable statement in Python; but you know what I
mean.) When I write:
myForm = widgets.TableForm(fields=MyFields(), submit_text="Submit")
I expect 'fields' to be instantiated at the point of invocation, but in
fact, it was instantiated when the class definition for 'MyFields' was
parsed:
class MyFields(widgets.WidgetsDeclaration):
field1 = widgets.TextField()
field2 = widgets.SingleSelect()
...
This seems a bizarre trick to me; it would make more sense if the field
assignments were done within an __init__() method, and MyFields were
treated as a Singleton at runtime. The "tweaks" you refer to could be
accomplished with parameters to the constructor.
Maybe I'm just not well-versed in Python philosophy...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---