Re: [Zope] Mark Pilgrim's Feed Parser in Zope
Dieter, Appreciate your help. I found a way to test if the ExternalMethod really returned a dict here: http://infrae.com/mailman_/pipermail/silva-dev/2004q2/001091.html And you were right! This is not seen as as a valid dictionary (nor is it seen as a string): stuff = container.externalmethod(feedurl=feedurl) test = same_type(stuff, {}) print test return printed returns 0 However, interestingly enough, if I copy and paste the all the text that is returned by the external method into the script, I am able to confirm that it is a dictionary: stuff= {'lastbuilddate': u'Mon, 24 Jul 2006 12:06:18 EDT', u'subtitle': 'U.S.', u'generator': 'NPR/RSS Generator 2.0 etc...'} test = same_type(stuff, {}) print test return printed returns 1 Also, I tried to render the copied text from the external method using the page template, and received a different error message: TypeError: string indices must be integers (see the attached traceback). I don't know if this last test will be useful, but I thought I'd give it a try. Do you know if there is a way of changing the data type of an object? Do you know if there is a listing of data types that I could test for? Thanks kindly, John T. Traceback (innermost last): Module ZPublisher.Publish, line 113, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PageTemplates.ZopePageTemplate, line 256, in _exec Module Products.PageTemplates.PageTemplate, line 102, in pt_render - ZopePageTemplate at /mypath/pagetemplate Module TAL.TALInterpreter, line 206, in __call__ Module TAL.TALInterpreter, line 250, in interpret Module TAL.TALInterpreter, line 649, in do_loop_tal Module Products.PageTemplates.TALES, line 206, in setRepeat Module Products.PageTemplates.TALES, line 221, in evaluate - URL: /mypath/pagetemplate - Line 2, Column 2 - Expression: PythonExpr news['entries'][0:25] - Names: {'container': Folder at /mypath, 'context': Folder at /mypath, 'default': Products.PageTemplates.TALES.Default instance at 0x011205D0, 'here': Folder at /mypath, 'loop': Products.PageTemplates.TALES.SafeMapping object at 0x034A6BE8, 'modules': Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x01103760, 'nothing': None, 'options': {'args': ()}, 'repeat': Products.PageTemplates.TALES.SafeMapping object at 0x034A6BE8, 'request': HTTPRequest, URL=http://localhost:/mypath/pagetemplate, 'root': Application at , 'template': ZopePageTemplate at /mypath/pagetemplate, 'traverse_subpath': [], 'user': admin} Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ - __traceback_info__: news['entries'][0:25] Module Python expression news['entries'][0:25], line 1, in expression Module AccessControl.ZopeGuards, line 67, in guarded_getitem TypeError: string indices must be integers ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Mark Pilgrim's Feed Parser in Zope
snip I found a way to test if the ExternalMethod really returned a dict here: http://infrae.com/mailman_/pipermail/silva-dev/2004q2/001091.html And you were right! This is not seen as as a valid dictionary (nor is it seen as a string): stuff = container.externalmethod(feedurl=feedurl) test = same_type(stuff, {}) print test return printed returns 0 However, interestingly enough, if I copy and paste the all the text that is returned by the external method into the script, I am able to confirm that it is a dictionary: stuff= {'lastbuilddate': u'Mon, 24 Jul 2006 12:06:18 EDT', u'subtitle': 'U.S.', u'generator': 'NPR/RSS Generator 2.0 etc...'} test = same_type(stuff, {}) print test return printed returns 1 Also, I tried to render the copied text from the external method using the page template, and received a different error message: TypeError: string indices must be integers (see the attached traceback). I don't know if this last test will be useful, but I thought I'd give it a try. Do you know if there is a way of changing the data type of an object? Do you know if there is a listing of data types that I could test for? /snip There is an easy, but potentially dangerous way to turn a string representative of a python dictionary back into a 'real' python dictionary... only do this if you are sure of the contents of the dictionary: in an external method: def string2dict(instr): dict = {} dict['__builtins__'] = None return eval(instr, dict) hth Jonathan Thanks kindly, John T. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Mark Pilgrim's Feed Parser in Zope
At Wednesday 26/7/2006 18:57, KJZZ Webmaster wrote: And you were right! This is not seen as as a valid dictionary (nor is it seen as a string): stuff = container.externalmethod(feedurl=feedurl) test = same_type(stuff, {}) print test return printed returns 0 However, interestingly enough, if I copy and paste the all the text that is returned by the external method into the script, I am able to confirm that it is a dictionary: stuff= {'lastbuilddate': u'Mon, 24 Jul 2006 12:06:18 EDT', u'subtitle': 'U.S.', u'generator': 'NPR/RSS Generator 2.0 etc...'} In this case you are using the Python syntax to create a dictionary, so it's not a surprise when it *is* a dictionary... Are you sure that your external method returns this *text*? It seems that you are looking at the string representation of some dictionary-like object. You can convert any dictionary-like object into a true dictionary using the builtin function dict: d = dict(an_object_that_acts_like_a_dictionary) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Mark Pilgrim's Feed Parser in Zope
[EMAIL PROTECTED] wrote at 2006-7-24 11:13 -0700: I'm trying to move our sites from Zope 2.5.1 to Zope 2.8.1-final and I'm receiving an error with this script: http://www.zope.org/Members/johntynan/feedparser/ In particular, I receive the following error, when using the attached page template nprnews.pt: Unauthorized: You are not allowed to access 'a particular list' in this context (see traceback.txt attached). This page template renders an rss feed that has been transformed into a dictionary (see dictionary.txt attached) via a python script (feedscript) which calls an external method (newsfeed) which uses Mark Pilgrim's feed parser to parse the xml into a python data type. The object might look like a dictionary but it probably is not. Ensure that your ExternalMethod really returns a dict (or other simple data structure). -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Mark Pilgrim's Feed Parser in Zope
I'm trying to move our sites from Zope 2.5.1 to Zope 2.8.1-final and I'm receiving an error with this script: http://www.zope.org/Members/johntynan/feedparser/ In particular, I receive the following error, when using the attached page template nprnews.pt: Unauthorized: You are not allowed to access 'a particular list' in this context (see traceback.txt attached). This page template renders an rss feed that has been transformed into a dictionary (see dictionary.txt attached) via a python script (feedscript) which calls an external method (newsfeed) which uses Mark Pilgrim's feed parser to parse the xml into a python data type. If I run the python script or the external method directly (via the test tab in the ZMI) I have no problem viewing all the properties of the rss feed. However, if I use the page template, I still receive this error. I've tried to get around this by running the python script using a proxy role of manager or owner, but I still receive the same error. Any suggestions you might have are appreciated. John Tynan - webmaster KJZZ.org / KBAQ.org 480.774.8462 Traceback (innermost last): Module ZPublisher.Publish, line 113, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module OFS.DTMLDocument, line 128, in __call__ - DTMLDocument at /news/index_html - URL: http://localhost/news/index_html/manage_main - Physical Path: /news/index_html Module DocumentTemplate.DT_String, line 476, in __call__ Module DocumentTemplate.DT_Util, line 196, in eval - __traceback_info__: npr Module string, line 1, in expression Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PageTemplates.ZopePageTemplate, line 256, in _exec Module Products.PageTemplates.PageTemplate, line 102, in pt_render - ZopePageTemplate at /newsstories Module TAL.TALInterpreter, line 206, in __call__ Module TAL.TALInterpreter, line 250, in interpret Module TAL.TALInterpreter, line 649, in do_loop_tal Module Products.PageTemplates.TALES, line 206, in setRepeat Module Products.PageTemplates.TALES, line 221, in evaluate - URL: /newsstories - Line 2, Column 2 - Expression: PythonExpr news['entries'][0:4] - Names: {'container': Folder at /newsstories, 'context': Folder at /newsstories, 'default': Products.PageTemplates.TALES.Default instance at 0x011205D0, 'here': Folder at /newsstories, 'loop': Products.PageTemplates.TALES.SafeMapping object at 0x0340CD00, 'modules': Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x01103760, 'nothing': None, 'options': {'args': (None, TemplateDict object at 0x03135680)}, 'repeat': Products.PageTemplates.TALES.SafeMapping object at 0x0340CD00, 'request': HTTPRequest, URL=http://localhost/news/index_html, 'root': Application at , 'template': ZopePageTemplate at /newsstories, 'traverse_subpath': [], 'user': admin} Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ - __traceback_info__: news['entries'][0:4] Module Python expression news['entries'][0:4], line 1, in expression Module AccessControl.ZopeGuards, line 71, in guarded_getitem Unauthorized: You are not allowed to access 'a particular list' in this context {'feed': {'lastbuilddate': u'Mon, 24 Jul 2006 12:06:18 EDT', 'subtitle': u'U.S.', 'generator': u'NPR/RSS Generator 2.0', 'links': [{'href': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'type': 'text/html', 'rel': 'alternate'}, {'type': 'text/html', 'rel': 'alternate'}], 'title': u'NPR Topics: Nation', 'image': {'href': u'http://www.npr.org/images/npr_news_123x20.gif', 'link': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'title': u'Nation'}, 'rights': u'Copyright 2006 NPR - For Personal Use Only', 'generator_detail': {'name': u'NPR/RSS Generator 2.0'}, 'subtitle_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/html', 'value': u'U.S.', 'language': None}, 'title_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/plain', 'value': u'NPR Topics: Nation', 'language': None}, 'link': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'rights_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/plain', 'value': u'Copyright 2006 NPR - For Personal Use Only', 'language': None}}, 'status': 200, 'updated': (2006, 7, 24, 17, 53, 55, 0, 205, 0), 'version': 'rss20', 'encoding': 'us-ascii', 'bozo': 0, 'headers': {'content-length': '17980', 'set-cookie': 'v1st=1DCE87E4F229957A; path=/; expires=Wed, 19 Feb 2020 14:28:00 GMT; domain=.npr.org, Apache=140.198.109.3.318941153763735423; path=/', 'accept-ranges': 'bytes', 'expires': 'Mon, 24 Jul 2006 17:55:35 GMT', 'server': 'Apache', 'last-modified': 'Mon, 24 Jul 2006 17:53:55 GMT', 'connection': 'close', 'etag':
[Zope] Mark Pilgrim's Feed Parser in Zope
I'm trying to move our sites from Zope 2.5.1 to Zope 2.8.1-final and I'm receiving an error with this script: http://www.zope.org/Members/johntynan/feedparser/ In particular, I receive the following error, when using the attached page template nprnews.pt: Unauthorized: You are not allowed to access 'a particular list' in this context (see traceback.txt attached). This page template renders an rss feed that has been transformed into a dictionary (see dictionary.txt attached) via a python script (feedscript) which calls an external method (newsfeed) which uses Mark Pilgrim's feed parser to parse the xml into a python data type. If I run the python script or the external method directly (via the test tab in the ZMI) I have no problem viewing all the properties of the rss feed. However, if I use the page template, I still receive this error. I've tried to get around this by running the python script using a proxy role of manager or owner, but I still receive the same error. Any suggestions you might have are appreciated. John Tynan - webmaster KJZZ.org / KBAQ.org 480.774.8462 Traceback (innermost last): Module ZPublisher.Publish, line 113, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module OFS.DTMLDocument, line 128, in __call__ - DTMLDocument at /news/index_html - URL: http://localhost/news/index_html/manage_main - Physical Path: /news/index_html Module DocumentTemplate.DT_String, line 476, in __call__ Module DocumentTemplate.DT_Util, line 196, in eval - __traceback_info__: npr Module string, line 1, in expression Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PageTemplates.ZopePageTemplate, line 256, in _exec Module Products.PageTemplates.PageTemplate, line 102, in pt_render - ZopePageTemplate at /newsstories Module TAL.TALInterpreter, line 206, in __call__ Module TAL.TALInterpreter, line 250, in interpret Module TAL.TALInterpreter, line 649, in do_loop_tal Module Products.PageTemplates.TALES, line 206, in setRepeat Module Products.PageTemplates.TALES, line 221, in evaluate - URL: /newsstories - Line 2, Column 2 - Expression: PythonExpr news['entries'][0:4] - Names: {'container': Folder at /newsstories, 'context': Folder at /newsstories, 'default': Products.PageTemplates.TALES.Default instance at 0x011205D0, 'here': Folder at /newsstories, 'loop': Products.PageTemplates.TALES.SafeMapping object at 0x0340CD00, 'modules': Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x01103760, 'nothing': None, 'options': {'args': (None, TemplateDict object at 0x03135680)}, 'repeat': Products.PageTemplates.TALES.SafeMapping object at 0x0340CD00, 'request': HTTPRequest, URL=http://localhost/news/index_html, 'root': Application at , 'template': ZopePageTemplate at /newsstories, 'traverse_subpath': [], 'user': admin} Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ - __traceback_info__: news['entries'][0:4] Module Python expression news['entries'][0:4], line 1, in expression Module AccessControl.ZopeGuards, line 71, in guarded_getitem Unauthorized: You are not allowed to access 'a particular list' in this context {'feed': {'lastbuilddate': u'Mon, 24 Jul 2006 12:06:18 EDT', 'subtitle': u'U.S.', 'generator': u'NPR/RSS Generator 2.0', 'links': [{'href': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'type': 'text/html', 'rel': 'alternate'}, {'type': 'text/html', 'rel': 'alternate'}], 'title': u'NPR Topics: Nation', 'image': {'href': u'http://www.npr.org/images/npr_news_123x20.gif', 'link': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'title': u'Nation'}, 'rights': u'Copyright 2006 NPR - For Personal Use Only', 'generator_detail': {'name': u'NPR/RSS Generator 2.0'}, 'subtitle_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/html', 'value': u'U.S.', 'language': None}, 'title_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/plain', 'value': u'NPR Topics: Nation', 'language': None}, 'link': u'http://www.npr.org/templates/topics/topic.php?topicId=1003ft=1f=1003', 'rights_detail': {'base': 'http://www.npr.org/rss/rss.php?id=1003', 'type': 'text/plain', 'value': u'Copyright 2006 NPR - For Personal Use Only', 'language': None}}, 'status': 200, 'updated': (2006, 7, 24, 17, 53, 55, 0, 205, 0), 'version': 'rss20', 'encoding': 'us-ascii', 'bozo': 0, 'headers': {'content-length': '17980', 'set-cookie': 'v1st=1DCE87E4F229957A; path=/; expires=Wed, 19 Feb 2020 14:28:00 GMT; domain=.npr.org, Apache=140.198.109.3.318941153763735423; path=/', 'accept-ranges': 'bytes', 'expires': 'Mon, 24 Jul 2006 17:55:35 GMT', 'server': 'Apache', 'last-modified': 'Mon, 24 Jul 2006 17:53:55 GMT', 'connection': 'close', 'etag':