[Zope] Mark Pilgrim's Feed Parser in Zope

KJZZ Webmaster kjzz.webmaster at riomail.maricopa.edu
Wed Jul 26 17:57:59 EDT 2006


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.


-------------- next part --------------
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:8888/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


More information about the Zope mailing list