Adding resource in z3c.pt
Hi all, Can anybody tell me how can i add resource by using z3c.pt. i know how to add it by using zope.pagetemplate, i tried it and it was working well. The following is the code i am working with and it was not working with z3c.pt *configure.zcml:- . . *<adapter factory=".resizing_font.form_template" for=".resizing_font.ResizingFont" name="tatr_css_js.form" /> * *<browser:resourceDirectory name="tatr_js" directory="tatr_resource_js" /> * . . . resizing_font.pt :- *<html>* * <head> <script type="text/javascript" src="jquery-1.2.6.js" tal:attributes="src context/++resource++tatr_js/jquery-1.2.6.js"> </script> </head> <body> This is a test :) </body> </html>* resizing_font.py :- *from z3c.pt.pagetemplate import ViewPageTemplateFile* *class ResizingFont(FormBase): template = NamedTemplate('tatr_css_js.form') form_fields=[] def __init__(self,context,request): self.request=request self.context=context form_template = NamedTemplateImplementation( ViewPageTemplateFile('resizing_font.pt')) *While running with this code i am getting the error *2008-10-14T06:14:36 ERROR SiteError http://192.168.0.43:8080/resizing_font.html Traceback (most recent call last): File "/home/z3.4/lib/python/zope/publisher/publish.py", line 133, in publish result = publication.callObject(request, obj) File "/home/z3.4/lib/python/zope/app/publication/zopepublication.py", line 167, in callObject return mapply(ob, request.getPositionalArguments(), request) File "/home/z3.4/lib/python/zope/publisher/publish.py", line 108, in mapply return debug_call(obj, args) - __traceback_info__: <security proxied zope.app.publisher.browser.viewmeta.ResizingFont instance at 0x98deeac> File "/home/z3.4/lib/python/zope/publisher/publish.py", line 114, in debug_call return obj(*args) File "/home/z3.4/lib/python/zope/formlib/form.py", line 774, in __call__ return self.render() File "/home/z3.4/lib/python/zope/formlib/form.py", line 768, in render self.form_result = self.template() File "/home/z3.4/lib/python/z3c/pt/pagetemplate.py", line 40, in render return template.render(**parameters) File "/home/z3.4/lib/python/chameleon/zpt/template.py", line 51, in render return super(PageTemplateFile, self).render(**kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 156, in render return super(TemplateFile, self).render(**kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 62, in render template = self.cook_check(parameters=kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 152, in cook_check return Template.cook_check(self, **kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 57, in cook_check template = self.cook(parameters=parameters, **kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 138, in cook template = self.compiler(**kwargs) File "/home/z3.4/lib/python/chameleon/core/translation.py", line 597, in __call__ self.root.start(stream) File "/home/z3.4/lib/python/chameleon/core/translation.py", line 438, in start self.node.visit() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 107, in visit self.body() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 92, in body element.node.visit() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 107, in visit self.body() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 92, in body element.node.visit() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 107, in visit self.body() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 92, in body element.node.visit() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 106, in visit self.begin() File "/home/z3.4/lib/python/chameleon/core/translation.py", line 72, in begin self.stream.begin(self.serialize()) File "/home/z3.4/lib/python/chameleon/core/translation.py", line 174, in serialize dynamic_attrs = self.dynamic_attributes or () File "/home/z3.4/lib/python/chameleon/zpt/language.py", line 74, in dynamic_attributes if self.element.tal_attributes is not None: File "/home/z3.4/lib/python/chameleon/core/utils.py", line 52, in get return f(value) File "/home/z3.4/lib/python/chameleon/zpt/expressions.py", line 236, in definitions raise e SyntaxError: Not a valid path-expression. 192.168.0.43 - - [14/Oct/2008:06:14:36 +0000] "GET /resizing_font.html HTTP/1.1" 500 84 "http://192.168.0.43:8080/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080702 Iceweasel/2.0.0.16(Debian-2.0.0.16-0etch1)" Thanks in advance :) * *
Previously Binseer N wrote:
Hi all, Can anybody tell me how can i add resource by using z3c.pt. i know how to add it by using zope.pagetemplate, i tried it and it was working well. The following is the code i am working with and it was not working with z3c.pt
*configure.zcml:-
. . *<adapter factory=".resizing_font.form_template" for=".resizing_font.ResizingFont" name="tatr_css_js.form" /> *
*<browser:resourceDirectory name="tatr_js" directory="tatr_resource_js" /> *
. . .
resizing_font.pt :-
*<html>* * <head> <script type="text/javascript" src="jquery-1.2.6.js" tal:attributes="src context/++resource++tatr_js/jquery-1.2.6.js"> </script> </head> <body> This is a test :) </body>
</html>*
Try adding a trailing ; after your TALES expression. Wichert. -- Wichert Akkerman <wichert@wiggy.net> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
2008/10/14 Wichert Akkerman <wichert@wiggy.net>
Previously Binseer N wrote:
Hi all, Can anybody tell me how can i add resource by using z3c.pt. i know how to add it by using zope.pagetemplate, i tried it and it was working well. The following is the code i am working with and it was not working with z3c.pt
*configure.zcml:-
. . *<adapter factory=".resizing_font.form_template" for=".resizing_font.ResizingFont" name="tatr_css_js.form" /> *
*<browser:resourceDirectory name="tatr_js" directory="tatr_resource_js" /> *
. . .
resizing_font.pt :-
*<html>* * <head> <script type="text/javascript" src="jquery-1.2.6.js" tal:attributes="src context/++resource++tatr_js/jquery-1.2.6.js"> </script> </head> <body> This is a test :) </body>
</html>*
Try adding a trailing ; after your TALES expression.
Wichert.
-- Wichert Akkerman <wichert@wiggy.net> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
Thank you for the reply Wichert. Do you mean i have to add ";" after the TAL expression . I tried so but the result is same . Initially i tried with the following code , but it fired the same error ie <script type="text/javascript" src="jquery-1.2.6.js"> tal:attributes="src context/++resource++tatr_js/jquery-1.2.6.js;"> then i tried with the following <script type="text/javascript" src="jquery-1.2.6.js" tal:attributes="src context++resource++tatr_jsjquery-1.2.6.js";> </script> it fired the error 2008-10-14T11:45:52 ERROR SiteError http://192.168.0.43:8080/resizing_font.html Traceback (most recent call last): File "/home/z3.4/lib/python/zope/publisher/publish.py", line 133, in publish result = publication.callObject(request, obj) File "/home/z3.4/lib/python/zope/app/publication/zopepublication.py", line 167, in callObject return mapply(ob, request.getPositionalArguments(), request) File "/home/z3.4/lib/python/zope/publisher/publish.py", line 108, in mapply return debug_call(obj, args) - __traceback_info__: <security proxied zope.app.publisher.browser.viewmeta.ResizingFont instance at 0x9913d6c> File "/home/z3.4/lib/python/zope/publisher/publish.py", line 114, in debug_call return obj(*args) File "/home/z3.4/lib/python/zope/formlib/form.py", line 774, in __call__ return self.render() File "/home/z3.4/lib/python/zope/formlib/form.py", line 768, in render self.form_result = self.template() File "/home/z3.4/lib/python/z3c/pt/pagetemplate.py", line 40, in render return template.render(**parameters) File "/home/z3.4/lib/python/chameleon/zpt/template.py", line 51, in render return super(PageTemplateFile, self).render(**kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 156, in render return super(TemplateFile, self).render(**kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 62, in render template = self.cook_check(parameters=kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 152, in cook_check return Template.cook_check(self, **kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 57, in cook_check template = self.cook(parameters=parameters, **kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 138, in cook template = self.compiler(**kwargs) File "/home/z3.4/lib/python/chameleon/core/template.py", line 46, in compiler encoding=self.encoding) File "/home/z3.4/lib/python/chameleon/core/translation.py", line 517, in __init__ self.root, parsed_doctype = parser.parse(body) File "/home/z3.4/lib/python/chameleon/zpt/language.py", line 250, in parse root, doctype = super(Parser, self).parse(body) File "/home/z3.4/lib/python/chameleon/core/etree.py", line 39, in parse return parse(body, self.element_mapping) File "/home/z3.4/lib/python/chameleon/core/etree.py", line 202, in parse tree = lxml.etree.parse(StringIO(body), parser) File "lxml.etree.pyx", line 2576, in lxml.etree.parse (src/lxml/lxml.etree.c:22796) File "parser.pxi", line 1483, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:60359) File "parser.pxi", line 1511, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:60613) File "parser.pxi", line 1390, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:59530) File "parser.pxi", line 932, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:56815) File "parser.pxi", line 538, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:53512) File "parser.pxi", line 624, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:54372) File "parser.pxi", line 564, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:53770) XMLSyntaxError: attributes construct error, line 12, column 16
2008/10/14 Binseer N <binseer@musmo.com>:
Hi all, Can anybody tell me how can i add resource by using z3c.pt. i know how to add it by using zope.pagetemplate, i tried it and it was working well. The following is the code i am working with and it was not working with z3c.pt
There is a bug in z3c.pt that disallows '+' in a path-expression. I'll fix that. \malthe
participants (3)
-
Binseer N -
Malthe Borch -
Wichert Akkerman