Re: Does cheetah look at superclasses of placeholder objects?
James Abbatiello <[email protected]> Wed, 9 Mar 2011 00:58:49 -0500
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
--===============4655518261084566662== Content-Type: multipart/alternative; boundary=000e0cd228543e6428049e066c38 --000e0cd228543e6428049e066c38 Content-Type: text/plain; charset=ISO-8859-1 Hi Gerry, I only put a few minutes of effort into this but I can't reproduce this. Can you provide a minimal complete testcase that demonstrates the problem? -- James Abbatiello On Mon, Mar 7, 2011 at 3:28 PM, Gerry Duprey <[email protected]> wrote: > Howdy, > > I've been using Cheetah for a few weeks and am pretty happy with it (I have > been > and still am a Velocity user too, so very familiar). However, I'm running > into > a problem trying to invoke a method off a placeholder that makes me wonder > if > Cheetah is able to understand the placeholder objects might have > superclasses > and is able find methods in them. > > NOTE: To be clear, I am NOT subclassing the cheetah Template class. This > is > regarding an object that is added to my path which has a super class. > > What is happening is that when I attempt to iterate over a list of objects, > the > individual objects appear to be complete (they are not None and a > $type($xxx) > returns the correct/expected type). But any attempt to invoke a method on > the > placeholder that would in fact be a method in the placeholder objects super > class fail with a > > ------------------- > File "/usr/lib/python2.6/socket.py", line 292, in write > data = str(data) # XXX Should really reject non-string non-buffers > File "/usr/local/lib/python2.6/dist-packages/Cheetah/Template.py", line > 997, > in __str__ > rc = getattr(self, mainMethName)() > File > > "_home_gerry_Dropbox_develop_shiftBrite_pyDriver_www_templates_editScript_tmpl.py", > line 160, in respond > TypeError: 'NoneType' object is not callable > ------------------ > > The fragment of the template file that is causing this is: > --------------------- > #for $anEffect in $handler.getEffectList(): > $anEffect.getName() > #end for > --------------------- > > I can confirm, via debugging and copious print statements, that the object > represented by $handler is returning a series of objects via the > getEffectList() > method. > > Each "effect" instance can be a different class instance, but all the class > instances have a common (and single) superclass that contains the getName() > method. For example, there could be a class of > "effects.effects.ColorWasher", > "effects.effects.ColorPulser" and "effects.effects.TwinkleColor". All > classes > have the same base class of "BaseEffect" (which defined getName() and is > not > overridden by the sub-classes). > > If I fire up the python shell and run all the same code by hand, the > getEffectList() call correctly returns a list of effects instances which > work > fine (I can call the getName() and other methods no problem). This code > has > been working for a long time, so I'm pretty confident of it. I install the > $handler value directly, so there are no intermediate classes that could > hide/mask things. > > The odd thing, to me, is that if I do > #for $anEffect in $handler.getEffectList(): > $type($anEffect) > #end for > > I get an expected list of different class names, so it must see part of > this, > but an attempt to invoke any method (even methods I know do NOT exist -- > just > testing), gives the NoneType. Doing a $dir($anEffect) shows all methods, > including the getName() method, fine, so it's there in some way. > > I have a ton of other placeholder activity including calls for other > classes/lists of instances in the same template that work fine. > > So, hoping I've provided enough to at least start the dialog, I'm wondering > if: > 1) Could there be issues because the method I'm trying to invoke belongs to > a > superclass of the instance that is being used? > > 2) Could there be an issue with packages/modules/importing that has to be > resolved (i.e. while the class is intact, Cheetah can't parse the info/find > things because the classes are from a different package/module)? > > 3) If none of the above, any suggestions on how to further track this down? > > I really appreciate it. I've spend nearly 2 days testing and trying > different > approaches and other than now being sure the underlying code (the handler, > effects list manage and effects) are working reliably. > > Much Thanks in advance! > > Gerry > -- > Gerry Duprey > Ann Arbor, MI 48103 > http://www.cdp1802.org > > > ------------------------------------------------------------------------------ > What You Don't Know About Data Connectivity CAN Hurt You > This paper provides an overview of data connectivity, details > its effect on application quality, and explores various alternative > solutions. http://p.sf.net/sfu/progress-d2d > _______________________________________________ > Cheetahtemplate-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > --000e0cd228543e6428049e066c38 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Gerry,<br><br>I only put a few minutes of effort into this but I can'= ;t reproduce this.=A0 Can you provide a minimal complete testcase that dem= onstrates the problem?<br><br>-- <br>James Abbatiello<br><br><br><div class= =3D"gmail_quote"> On Mon, Mar 7, 2011 at 3:28 PM, Gerry Duprey <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]">[email protected]</a>></span> wrote:<br><b= lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px = #ccc solid;padding-left:1ex;"> Howdy,<br> <br> I've been using Cheetah for a few weeks and am pretty happy with it (I = have been<br> and still am a Velocity user too, so very familiar). =A0However, I'm ru= nning into<br> a problem trying to invoke a method off a placeholder that makes me wonder = if<br> Cheetah is able to understand the placeholder objects might have superclass= es<br> and is able find methods in them.<br> <br> NOTE: To be clear, I am NOT subclassing the cheetah Template class. =A0This= is<br> regarding an object that is added to my path which has a super class.<br> <br> What is happening is that when I attempt to iterate over a list of objects,= the<br> individual objects appear to be complete (they are not None and a $type($xx= x)<br> returns the correct/expected type). =A0But any attempt to invoke a method o= n the<br> placeholder that would in fact be a method in the placeholder objects super= <br> class fail with a<br> <br> -------------------<br> =A0 File "/usr/lib/python2.6/socket.py", line 292, in write<br> =A0 =A0 data =3D str(data) # XXX Should really reject non-string non-buffe= rs<br> =A0 File "/usr/local/lib/python2.6/dist-packages/Cheetah/Template.py&= quot;, line 997,<br> in __str__<br> =A0 =A0 rc =3D getattr(self, mainMethName)()<br> =A0 File<br> "_home_gerry_Dropbox_develop_shiftBrite_pyDriver_www_templates_editScr= ipt_tmpl.py",<br> line 160, in respond<br> TypeError: 'NoneType' object is not callable<br> ------------------<br> <br> The fragment of the template file that is causing this is:<br> ---------------------<br> #for $anEffect in $handler.getEffectList():<br> =A0 $anEffect.getName()<br> #end for<br> ---------------------<br> <br> I can confirm, via debugging and copious print statements, that the object<= br> represented by $handler is returning a series of objects via the getEffectL= ist()<br> method.<br> <br> Each "effect" instance can be a different class instance, but all= the class<br> instances have a common (and single) superclass that contains the getName()= <br> method. =A0For example, there could be a class of "effects.effects.Col= orWasher",<br> "effects.effects.ColorPulser" and "effects.effects.TwinkleCo= lor". =A0All classes<br> have the same base class of "BaseEffect" (which defined getName()= and is not<br> overridden by the sub-classes).<br> <br> If I fire up the python shell and run all the same code by hand, the<br> getEffectList() call correctly returns a list of effects instances which wo= rk<br> fine (I can call the getName() and other methods no problem). =A0This code = has<br> been working for a long time, so I'm pretty confident of it. =A0I insta= ll the<br> $handler value directly, so there are no intermediate classes that could<br= > hide/mask things.<br> <br> The odd thing, to me, is that if I do<br> #for $anEffect in $handler.getEffectList():<br> =A0 $type($anEffect)<br> #end for<br> <br> I get an expected list of different class names, so it must see part of thi= s,<br> but an attempt to invoke any method (even methods I know do NOT exist -- ju= st<br> testing), gives the NoneType. =A0Doing a $dir($anEffect) shows all methods,= <br> including the getName() method, fine, so it's there in some way.<br> <br> I have a ton of other placeholder activity including calls for other<br> classes/lists of instances in the same template that work fine.<br> <br> So, hoping I've provided enough to at least start the dialog, I'm w= ondering if:<br> 1) Could there be issues because the method I'm trying to invoke belong= s to a<br> superclass of the instance that is being used?<br> <br> 2) Could there be an issue with packages/modules/importing that has to be<b= r> resolved (i.e. while the class is intact, Cheetah can't parse the info/= find<br> things because the classes are from a different package/module)?<br> <br> 3) If none of the above, any suggestions on how to further track this down?= <br> <br> I really appreciate it. =A0I've spend nearly 2 days testing and trying = different<br> approaches and other than now being sure the underlying code (the handler,<= br> effects list manage and effects) are working reliably.<br> <br> Much Thanks in advance!<br> <br> Gerry<br> --<br> Gerry Duprey<br> Ann Arbor, MI 48103<br> <a href=3D"http://www.cdp1802.org" target=3D"_blank">http://www.cdp1802.org= </a><br> <br> ---------------------------------------------------------------------------= ---<br> What You Don't Know About Data Connectivity CAN Hurt You<br> This paper provides an overview of data connectivity, details<br> its effect on application quality, and explores various alternative<br> solutions. <a href=3D"http://p.sf.net/sfu/progress-d2d" target=3D"_blank">h= ttp://p.sf.net/sfu/progress-d2d</a><br> _______________________________________________<br> Cheetahtemplate-discuss mailing list<br> <a href=3D"mailto:[email protected]">Cheetahtem= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-dis= cuss" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/cheeta= htemplate-discuss</a><br> </blockquote></div><br> --000e0cd228543e6428049e066c38-- --===============4655518261084566662== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d --===============4655518261084566662== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss --===============4655518261084566662==--