[ZCM] [ZC] 2232/ 7 Comment "DTML uncallable from ZPT in 2.10"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Wed, 11 Jul 2007 16:44:23 -0400
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2232 Update (Comment) "DTML uncallable from ZPT in 2.10"
 Status Resolved, Zope/bug+solution medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2232

==============================================================
= Comment - Entry #7 by dma0380 on Jul 11, 2007 4:44 pm

Thanks for the quick reply jens. According to the bug collector, you replied before I even asked the question. :)

As an update, you're right. For some reason, after installing 2.10.4 , pointing my instance at the new version and restarting, it still reflects that it's using 2.10.0. It'll be interesting to figure that one out. :)

Thanks again.
________________________________________
= Comment - Entry #6 by jens on Jul 9, 2007 10:37 pm

Something may be wrong with your installation or the way you upgraded. This error is fixed on the 2.10 branch, I even tried to reproduce it right now and everything works as expected. You may want to try on a new installation.

________________________________________
= Comment - Entry #5 by dma0380 on Jul 9, 2007 10:44 pm

I am still receiving the same error under the same conditions. I updated to 2.10.4 with no change in behavior.

Thanks in Advance,
Dave
________________________________________
= Comment - Entry #4 by philikon on Nov 12, 2006 10:46 am

Danke, Jens!
________________________________________
= Resolve - Entry #3 by jens on Nov 12, 2006 10:45 am

 Status: Accepted => Resolved

Fixed on the 2.10 branch:

http://svn.zope.org/Zope/?rev=71109&view=rev

... and the trunk:

http://svn.zope.org/Zope/?rev=71110&view=rev

________________________________________
= Assign - Entry #2 by philikon on Nov 6, 2006 1:39 pm

 Status: Pending => Accepted

 Supporters added: philikon

I'll take this one.
________________________________________
= Request - Entry #1 by miwa on Nov 6, 2006 1:36 pm

If you call a DTML method from ZPT in zope 2.10 you get an error which you did not get in earlier versions:

Time  	2006/11/06 18:41:11.342 GMT
User Name (User Id) 	admin (admin)
Request URL 	http://10.0.0.103:9080/test1
Exception Type 	NameError
Exception Value 	global name 'call_with_ns' is not defined

Traceback (innermost last):

    * Module ZPublisher.Publish, line 115, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 41, in call_object
    * Module Shared.DC.Scripts.Bindings, line 313, in __call__
    * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
    * Module Products.PageTemplates.ZopePageTemplate, line 276, in _exec
    * Module Products.PageTemplates.PageTemplate, line 89, in pt_render
    * Module zope.pagetemplate.pagetemplate, line 117, in pt_render
    * Module zope.tal.talinterpreter, line 271, in __call__
    * Module zope.tal.talinterpreter, line 346, in interpret
    * Module zope.tal.talinterpreter, line 534, in do_optTag_tal
    * Module zope.tal.talinterpreter, line 516, in no_tag
    * Module zope.tal.talinterpreter, line 346, in interpret
    * Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
    * Module zope.tales.tales, line 696, in evaluate
      URL: /test1
      Line 7, Column 4
      Expression: <PathExpr standard:'here/test2'>
      Names:

{'container': <Application at >,
 'context': <Application at >,
 'default': <object object at 0xb7da5528>,
 'here': <Application at >,
 'loop': {},
 'nothing': None,
 'options': {'args': ()},
 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xb54f134c>,
 'request': <HTTPRequest, URL=http://10.0.0.103:9080/test1>,
 'root': <Application at >,
 'template': <ZopePageTemplate at /test1>,
 'traverse_subpath': [],
 'user': <User 'admin'>}

    * Module zope.tales.expressions, line 217, in __call__
    * Module Products.PageTemplates.Expressions, line 130, in _eval
    * Module Products.PageTemplates.Expressions, line 92, in render

NameError: global name 'call_with_ns' is not defined


Test setup:
===========

1.  Add a DTML document or method to the root of the site called test2.  Put the text in it "This is the title from DTML"

2.  Add a Page Template to the root of the site called test1.  Put the following line in it "<div tal:replace="structure here/test2">replaced text</div>".

3.  Attempt to render the page - the error above will be generated

Fix:
====

To fix the bug, change line 92 of Products.PageTemplate.Expressions from

        if callable(base):
            try:
                if getattr(base, 'isDocTemp', 0):
-->                 ob = call_with_ns(ob, ns, 2)
                else:
                    ob = ob()

to

        if callable(base):
            try:
                if getattr(base, 'isDocTemp', 0):
-->                 ob = ZRPythonExpr.call_with_ns(ob, ns, 2)
                else:
                    ob = ob()

I would supply the unit test but I have zero understanding of what is actually happening here, or the existing tests.
==============================================================