On Apr 10, 2006, at 3:57 PM, Sean Jamieson wrote:
> > While I was reading this topic, something just tickled my brain. I > remember that Kevin had mentioned somewhere (screencast probably) > about > the posibility of widgets being defined as classes (ref. SQLObject), > rather than with an instantiated object, and a dictionary of fields. > > I've been reading about metaclasses recently, and I think it would be > quite possible to create a meta class, that processes a class > definition, and produces something that returns the exact same > structure as currently used in widgets. > > What do you think, insane or interesting? Insane :) Metaclasses are very porwerful and solve some problems very elegantly, but, like any other powerfull tool, should only be used when absolutely needed (although it's fun to use them for uneeded problems to get a grip of them, and have fun, of course). I remember one case when I coded an internal app for the company I work at to handle nightly backups (via rdiff-backup) of many servers. Plugins were made to support different schemas (postgres, mysql, tracs, svn repositories, etc...) and the idea was that these plugins could be easily written by the python newbie coworkers. I decided to take a shot on metaclasses so they didn't need to call super cooperatively when extending methods. As you can guess, I ended up reimplementing python's MRO in an unmaintainable mess and helped them neither as when they wanted to write real python code they weren't used the "super" idiom. But it's true that I learned a lot on the way... The widget API right now is using metaclasses internally for various stuff, but we really tried hard not to get overexcited with it (thanks Michele for stopping my feet at #419 ;) as it would only over- complicate things for no good reason. Regards, Alberto --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

