[Grok-dev] How do I reference a common template in the statics folder?

Sebastian Ware sebastian at urbantalk.se
Thu Jul 5 10:52:00 EDT 2007


Haha... sorry, I was being a bit brief... my bad :)

5 jul 2007 kl. 16.27 skrev Uli Fouquet:

> Hi Sebastian,
>
> Am Donnerstag, den 05.07.2007, 15:19 +0200 schrieb Sebastian Ware:
>> I have tried some variations on the theme...
>
> What variations?

combination of filenames, directories, classes, macros and @@...

>
>>  and all I get is the
>> (rather general) error:
>>
>>    TypeError: unsubscriptable object
>>
>> I must say, error messages from Zope aren't all that explicit...
>
>  :-) What is the 'unsubscriptable object'?

    - /Users/jhsware/GrokProjects/ProtonCMS/src/protoncms/ 
protonworkflow_templates/workflow.pt
    - Line 1, Column 0
    - Expression: <PathExpr standard:u'context/@@master/admin'>
    - Names:
       {'args': (),
        'context': <protoncms.protonworkflow.ProtonWorkflow object at  
0x3194fb0>,
        'default': <object object at 0x38d570>,
        'loop': {},
        'nothing': None,
        'options': {},
        'repeat': {},
        'request': <zope.publisher.browser.BrowserRequest instance  
URL=http://localhost:8080/sbeb/default/workflow>,
        'static': <grok.components.DirectoryResource object at  
0x305e0d0>,
        'template': <workflow template in /Users/jhsware/GrokProjects/ 
ProtonCMS/src/protoncms/protonworkflow_templates/workflow.pt>,
        'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object  
at 0x30fc030>,
        'view': <protoncms.protonworkflow.Workflow object at 0x245ad70>}
   File "/local/zope3.3/lib/python/zope/tales/expressions.py", line  
217, in __call__
     return self._eval(econtext)
   File "/local/zope3.3/lib/python/zope/tales/expressions.py", line  
194, in _eval
     ob = self._subexprs[-1](econtext)
   File "/local/zope3.3/lib/python/zope/tales/expressions.py", line  
124, in _eval
     ob = self._traverser(ob, element, econtext)
   File "/local/zope3.3/lib/python/zope/app/pagetemplate/engine.py",  
line 68, in __call__
     request=request)
   File "/local/zope3.3/lib/python/zope/traversing/adapters.py", line  
164, in traversePathElement
     return traversable.traverse(nm, further_path)
    - __traceback_info__: (<protoncms.macros.Master object at  
0x31fdf10>, 'admin')
   File "/local/zope3.3/lib/python/zope/traversing/adapters.py", line  
49, in traverse
     return subject[name]
    - __traceback_info__: (<protoncms.macros.Master object at  
0x31fdf10>, 'admin', [])
   File "/Users/jhsware/GrokProjects/ProtonCMS/eggs/ 
grok-0.9dev_r77371-py2.4.egg/grok/components.py", line 137, in  
__getitem__
     return self.template.macros[key]
TypeError: unsubscriptable object


>
>> 5 jul 2007 kl. 15.02 skrev Luciano Ramalho:
>>
>>> On 7/5/07, Sebastian Ware <sebastian at urbantalk.se> wrote:
>>>> TraversalError: (<protoncms.protonworkflow.ProtonWorkflow object at
>>>> 0x3194d70>, 'macros')
>>>> ##my_render_template.pt
>>>> [...] metal:use-macro="context/@@macros/admin" [...]
>>>
>>> I haven't tried it, but maybe your're missing the master reference
>>> in that path?
>>>
>>>> [...] metal:use-macro="context/@@master/macros/admin" [...]
>
> Nearly, but:
>
> 	metal:use-macro="context/@@master/admin"
>
> should work. The pattern here is: 'context/@@<view-name>/<macro- 
> name>',
> without 'macros'.
>
> You might have a look at Philipps' nugenudge (I learned it from  
> there):
>
> 	http://codespeak.net/svn/z3/NudgeNudge/trunk/src/nudgenudge
>
> Should we include a little section about macros into the tutorial?  
> Or a
> mini-howto?  Obviously many people use them but seem to run into  
> trouble
> referencing them right, while it's easy, once you got it. On the other
> hand macros are not part of Grok and described well at other places.
>

Mini tutorial, yes please!!! :)

I have spent two hours trying to figure it out until I dared ask... :p

Sebastian

> Cheers,
>
> -- 
> Uli
>
>



More information about the Grok-dev mailing list