[ZPT] repeat variable access

richard@bizarsoftware.com.au richard@bizarsoftware.com.au
Wed, 18 Apr 2001 16:45:41 +1000


I've tried the latest CVS and the 1.1.1 release, and I still get access
errors trying to use the repeat variable.

With the source:

<div tal:repeat="txt python:'one', 'two'"
     tal:content="repeat/txt/index">1</div>

I get:


Traceback (innermost last):
    File /home/zope/Zope/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
    File /home/zope/Zope/lib/python/ZPublisher/Publish.py, line 187, in
publish
    File /home/zope/Zope/lib/python/ZPublisher/Publish.py, line 171, in
publish
    File /home/zope/Zope/lib/python/ZPublisher/mapply.py, line 160, in
mapply
      (Object: index_html)
    File /home/zope/Zope/lib/python/ZPublisher/Publish.py, line 112, in
call_object
      (Object: index_html)
    File /home/zope/instance/Products/BizarShop/Shop/Shop.py, line 660, in
index_html
      (Object: CustomItem)
    File
/home/zope/instance/Products/BizarShop/Utility/PageTemplateFile.py, line
34, in __call__
      (Object: PageTemplate)
    File /home/zope/instance/Products/PageTemplates/PageTemplate.py, line
156, in pt_render
      (Object: PageTemplate)
      (Info: {'container': <Template instance at 8e57028>,
   'here': <Shop instance at 8d353c8>,
   'nothing': None,
   'options': {'args': (<Shop instance at 8d353c8>,),
               'error_message': None,
               'ok_message': None},
   'request': <ZPublisher.HTTPRequest.HTTPRequest instance at 8c03b28>,
   'root': <RequestContainer instance at 8642298>,
   'template': <PageTemplateFile instance at 8e59900>})
    File /home/zope/Zope/lib/python/TAL/TALInterpreter.py, line 197, in
__call__
    File /home/zope/Zope/lib/python/TAL/TALInterpreter.py, line 224, in
interpret
    File /home/zope/Zope/lib/python/TAL/TALInterpreter.py, line 365, in
do_loop
    File /home/zope/Zope/lib/python/TAL/TALInterpreter.py, line 224, in
interpret
    File /home/zope/Zope/lib/python/TAL/TALInterpreter.py, line 314, in
do_insertText
    File /home/zope/instance/Products/PageTemplates/TALES.py, line 267, in
evaluateText
    File /home/zope/instance/Products/PageTemplates/TALES.py, line 257, in
evaluate
    File /home/zope/instance/Products/PageTemplates/Expressions.py, line
174, in __call__
    File /home/zope/instance/Products/PageTemplates/Expressions.py, line
388, in restrictedTraverse
      (Info: [])
    File /home/zope/Zope/lib/python/AccessControl/SecurityManager.py, line
149, in validate
    File /home/zope/instance/Products/ZDebug/DebugSecurityPolicy.py, line
193, in validate
  Unauthorized: Access denied for 0 because its container,
<Products.PageTemplates.TALES.Iterator instance at 8d494e0>, has no
security assertions.


PageTemplateFile.py is:

import os, re, string

import Globals
from Acquisition import Implicit
from Persistence import Persistent
from Products.PageTemplates.PageTemplate import PageTemplate

class PageTemplateFile(PageTemplate, Implicit, Persistent):
    ''' woot, page templates
    '''
    _v_last_read=0
    __allow_access_to_unprotected_subobjects__ = 1

    def __init__(self, filename):
        self.filename = filename
        self._cook_check()

    def _cook_check(self):
        mtime = os.stat(self.filename)[8]
        if mtime != self._v_last_read:
            self.pt_edit(open(self.filename).read(), 'text/html')
            self._v_last_read = mtime

    def __call__(self, obj, REQUEST, **kwargs):
        ''' woot, page templates
        '''
        self._cook()
        if Globals.DevelopmentMode:
            self._cook_check()
        if not kwargs.has_key('args'):
            kwargs['args'] = (obj, )
        template = self.__of__(obj)
        return template.pt_render(extra_context={'options': kwargs,
            'request': REQUEST})


Ideas?


      Richard

-- 
Richard Jones
richard@bizarsoftware.com.au
Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)