Re: [Zope] Dictionary Key Error from Parsed RSS
Tom Von Lahndorff wrote at 2007-6-15 11:45 -0400: >http://www.modscape.com/blog/ >rss.xml')"> > > > > > >gives: > >Site Error > >An error was encountered while publishing this resource. > >Error Type: Unauthorized >Error Value: You are not allowed to access 'feed' in this context > ... >If the error persists please contact the site maintainer. Thank you >for your patience. > >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 OFS.DTMLMethod, line 144, in __call__ > > URL: http://localhost:8080/feeds/nprnews.html/manage_main > Physical Path:/feeds/nprnews.html > * Module DocumentTemplate.DT_String, line 476, in __call__ > * Module DocumentTemplate.DT_Let, line 76, in render > * Module DocumentTemplate.DT_Util, line 196, in eval > __traceback_info__: news > * Module , line 1, in > >Unauthorized: You are not allowed to access 'feed' in this context It is likely that the object looks like a dictionary (it uses a string representation like that of a true 'dict') but it is not a proper dictionary (but rather some instance of a class). Zope's restricted code treats proper dictionaries as unprotected (like it does for lists and tuples) but requires special security declarations for instances to be accessible in untrusted code. A solution for you might be to convert the RSS data into a proper dictionary. How this works in detail depends on the instance at hand. If it implementes an "items" method, then "dict(instance.items())" would do it. Note that substructures, too, may look like Python types but are in fact instances. In this case, you would need to convert such substructures as well (similar to the top level object). -- 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 )
Re: [Zope] Dictionary Key Error from Parsed RSS
Here's a snippet of the rendered RSS feed: {'feed': {'subtitle': u'', 'links': [{'href': u'http:// www.modscape.com/blog', 'type': 'text/html', 'rel': 'alternate'}], 'title': u'modscape.com Home', 'subtitle_detail': {'base': 'http:// www.modscape.com/blog/rss.xml', 'type': 'text/html', 'value': u'', 'language': None}, 'title_detail': {'base': 'http://www.modscape.com/ blog/rss.xml', 'type': 'text/plain', 'value': u'modscape.com Home', 'language': None}, 'link': u'http://www.modscape.com/blog'}, 'status': 200, 'updated': (2007, 6, 15, 16, 48, 28, 4, 166, 0), 'version': 'rss20', 'encoding': 'iso-8859-15', 'bozo': 0, 'headers': {'content-length': '18486', 'via': '1.0 px04.bc.fw.cbs.net:80 (squid)', 'x-cache': 'MISS from px04.bc.fw.cbs.net', 'x-powered-by': 'Zope (www.zope.org), Python (www.python.org)', 'x-cache-lookup': 'HIT from px04.bc.fw.cbs.net:80', 'expires': 'Fri, 15 Jun 2007 17:48:28 GMT', 'server': 'Apache/2.0.52 (Red Hat) DAV/2 SVN/1.2.3 mod_ssl/2.0.52 OpenSSL/0.9.7a PHP/5.1.2 mod_fastcgi/2.4.2', 'last- modified': 'Fri, 15 Jun 2007 16:48:28 GMT', 'connection': 'close', 'cache-control': 'max-age=3600', 'date': 'Fri, 15 Jun 2007 16:48:28 GMT', 'content-type': 'text/xml; charset=iso-8859-15'}, 'etag': None, 'href': 'http://www.modscape.com/blog/rss.xml', 'namespaces': {}, 'entries': [{'updated': u'Mon, Sep 04 2006, 06:23PM', 'updated_parsed': None, 'links': [{'href': u'http://www.modscape.com/ blog/index_html?showall=yes#id1157412223', 'type': 'text/html', 'rel': 'alternate'}], 'title': u'Ubuntu: Linux For Human Beings', 'summary_detail': {'base': 'http://www.modscape.com/blog/rss.xml', 'type': 'text/html', 'value': u'http://www.modscape.com/ blog/1157412223/ubuntu.jpg" width="150" alt="ubuntu.jpg" align="right" hspace="10" />\n\nTom wrote:\n\nhref="http://www.ubuntu.com/";>Ubuntu is an easy On Jun 15, 2007, at 12:17 PM, Andreas Jung wrote: No idea what this method should tell use?! Your code uses "news.feed.href"...nothing's like that can be found here in the code. We can not guess what this snippet is doing and where and why. -aj --On 15. Juni 2007 12:02:48 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: shouldnt this prevent that? def dictify(p): """ Since the FeedParser returns a dictionary-like class instance, rather than a real dictionary, We must iterate through all nested instances and convert them to dicts to avoid security problems within Zope. I have no idea *why* feedparser doesn't just use real nested dicts in the first place. """ newdict = {} if type(p) in [types.DictionaryType, types.InstanceType]: d = p # for clarity for k,v in d.items(): newdict[k] = dictify(v) elif type(p) == types.ListType: l = p # for clarity for ss,v in zip(xrange(len(l)), l): l[ss] = dictify(v) return l else: return p return newdict On Jun 15, 2007, at 11:49 AM, Andreas Jung wrote: --On 15. Juni 2007 11:45:49 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: http://www.modscape.com/blog/ rss.xml')"> gives: Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'feed' in this context Likely because the module has no security assertions. All your stuff runs under the conditions of Restricted Python. The standard Zope security applies. -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376 Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535 Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK -- -- E-Publishing, Python, Zope & Plone development, Consulting ___ 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] Dictionary Key Error from Parsed RSS
No idea what this method should tell use?! Your code uses "news.feed.href"...nothing's like that can be found here in the code. We can not guess what this snippet is doing and where and why. -aj --On 15. Juni 2007 12:02:48 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: shouldnt this prevent that? def dictify(p): """ Since the FeedParser returns a dictionary-like class instance, rather than a real dictionary, We must iterate through all nested instances and convert them to dicts to avoid security problems within Zope. I have no idea *why* feedparser doesn't just use real nested dicts in the first place. """ newdict = {} if type(p) in [types.DictionaryType, types.InstanceType]: d = p # for clarity for k,v in d.items(): newdict[k] = dictify(v) elif type(p) == types.ListType: l = p # for clarity for ss,v in zip(xrange(len(l)), l): l[ss] = dictify(v) return l else: return p return newdict On Jun 15, 2007, at 11:49 AM, Andreas Jung wrote: --On 15. Juni 2007 11:45:49 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: http://www.modscape.com/blog/ rss.xml')"> gives: Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'feed' in this context Likely because the module has no security assertions. All your stuff runs under the conditions of Restricted Python. The standard Zope security applies. -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376 Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535 Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK E-Publishing, Python, Zope & Plone development, Consulting pgpiQY7pxdE3Q.pgp Description: PGP signature ___ 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] Dictionary Key Error from Parsed RSS
shouldnt this prevent that? def dictify(p): """ Since the FeedParser returns a dictionary-like class instance, rather than a real dictionary, We must iterate through all nested instances and convert them to dicts to avoid security problems within Zope. I have no idea *why* feedparser doesn't just use real nested dicts in the first place. """ newdict = {} if type(p) in [types.DictionaryType, types.InstanceType]: d = p # for clarity for k,v in d.items(): newdict[k] = dictify(v) elif type(p) == types.ListType: l = p # for clarity for ss,v in zip(xrange(len(l)), l): l[ss] = dictify(v) return l else: return p return newdict On Jun 15, 2007, at 11:49 AM, Andreas Jung wrote: --On 15. Juni 2007 11:45:49 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: http://www.modscape.com/blog/ rss.xml')"> gives: Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'feed' in this context Likely because the module has no security assertions. All your stuff runs under the conditions of Restricted Python. The standard Zope security applies. -aj ___ 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] Dictionary Key Error from Parsed RSS
--On 15. Juni 2007 11:45:49 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: http://www.modscape.com/blog/rss.xml')"> gives: Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'feed' in this context Likely because the module has no security assertions. All your stuff runs under the conditions of Restricted Python. The standard Zope security applies. -aj pgpZxlGOV6FfQ.pgp Description: PGP signature ___ 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] Dictionary Key Error from Parsed RSS
http://www.modscape.com/blog/ rss.xml')"> gives: Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'feed' in this context Troubleshooting Suggestions * The URL may be incorrect. * The parameters passed to this resource may be incorrect. * A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the error log. If the error persists please contact the site maintainer. Thank you for your patience. 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 OFS.DTMLMethod, line 144, in __call__ URL: http://localhost:8080/feeds/nprnews.html/manage_main Physical Path:/feeds/nprnews.html * Module DocumentTemplate.DT_String, line 476, in __call__ * Module DocumentTemplate.DT_Let, line 76, in render * Module DocumentTemplate.DT_Util, line 196, in eval __traceback_info__: news * Module , line 1, in Unauthorized: You are not allowed to access 'feed' in this context On Jun 15, 2007, at 10:21 AM, Jonathan wrote: - Original Message - From: "Tom Von Lahndorff" <[EMAIL PROTECTED]> To: Sent: Friday, June 15, 2007 10:18 AM Subject: [Zope] Dictionary Key Error from Parsed RSS Hi everyone, I've used Universal Feed Parser to parse an RSS feed. Then used these instructions below to get the parsed data into Zope via an External Method. Everything seems to work fine except that I keep getting an error whenever I try to access a key from the returned data. The resulting data is returned as a dictionary and if I render it as is it works fine, however in both ZPT and DTML, when trying to access a key, for instance "feed" or "href" from the dictionary I'm prompted to login, which I'm unable to do with my admin login. After hitting cancel I get a Key Error that says You are not able to access 'href' (or whatever) in this context. Is there any way to somehow let Zope know that this data is 'ok'? Thanks in advance. You should post the full Key Error message with traceback (from error_log in the root folder of the zmi). Jonathan ___ 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] Dictionary Key Error from Parsed RSS
--On 15. Juni 2007 10:18:20 -0400 Tom Von Lahndorff <[EMAIL PROTECTED]> wrote: I'm prompted to login, -> use VerboseSecurity which I'm unable to do with my admin login. After hitting cancel I get a Key Error that says You are not able to access 'href' (or whatever) in this context. You must provide the full traceback. -aj pgp3DhwdmKNke.pgp Description: PGP signature ___ 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] Dictionary Key Error from Parsed RSS
- Original Message - From: "Tom Von Lahndorff" <[EMAIL PROTECTED]> To: Sent: Friday, June 15, 2007 10:18 AM Subject: [Zope] Dictionary Key Error from Parsed RSS Hi everyone, I've used Universal Feed Parser to parse an RSS feed. Then used these instructions below to get the parsed data into Zope via an External Method. Everything seems to work fine except that I keep getting an error whenever I try to access a key from the returned data. The resulting data is returned as a dictionary and if I render it as is it works fine, however in both ZPT and DTML, when trying to access a key, for instance "feed" or "href" from the dictionary I'm prompted to login, which I'm unable to do with my admin login. After hitting cancel I get a Key Error that says You are not able to access 'href' (or whatever) in this context. Is there any way to somehow let Zope know that this data is 'ok'? Thanks in advance. You should post the full Key Error message with traceback (from error_log in the root folder of the zmi). Jonathan ___ 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 )