Re: @staticmethod verses multiple #extends inheritance
[email protected] Fri, 13 Nov 2009 14:18:51 -0800
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 10 Nov 2009, Dirk van Oosterbosch, IR labs wrote: > > Hi, > > I've been using Cheetah for a few years, but I've haven't been > following the list or the developments closely. > And I remember that multiple inheritance wasn't possible with previous > versions of Cheetah. > > Now I'm reading that since v2.2.2 multiple inheritance is possible. > Great! :-) > I read about the #@staticmethod decorator, and this recipe http://packages.python.org/Cheetah/recipes/staticmethod.html > > What would be better to use if I would like to mix #def's of different > template clases? > What's the difference between > #from foo import foo > and > #extends myclass, foo > ? > > > Currently I'm using an Cheetah / pure python inheritance hierarchy to > use different framework functionality and libraries throughout my > different pages. Something like: > BaseSkeleton.tmpl > -> ExtraComponents.tmpl > -> PythonFramework.py > -> page.tmpl > -> typeA.tmpl > -> typeB.tmpl > -> typeC.tmpl > -> subtypeC2.tmpl > > Now I would like to use #def methods from typeA.tmpl in subtypeC2.tmpl. > And maybe also the other way around: use #def methods from > subtypeC2.tmpl in typeA.tmpl > > Would I be using the now possible multiple inheritance? Or the > #@staticmethod decorator? Depending on the method(s) and where they're used elsewhere, it could go either way IMO. If you're just using a small number of methods from typaA in subtypeC2 then I'd just annotate them with a #@staticmethod decorator, otherwise I'd try multiple inheritance. The same rules apply for Cheetah multiple inheritance as in Python, so you want to make sure that typaA isn't squashing a method in typeC and vice versa > And thanks for keeping Cheetah alive and kicking! No prob ;) Cheers, -R. Tyler Ballance -------------------------------------- GitHub: http://github.com/rtyler Twitter: http://twitter.com/agentdero Blog: http://unethicalblogger.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc
(application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAkr920sACgkQFCbH3D9R4W//CQCfZSqWmeZ6QUipUZJxvoEEHgUq MrEAnAozPO/gL83l8+8f32We8OlqDkcv =gEnt -----END PGP SIGNATURE-----