I am trying to create a product that will grab all of the weather information from a weather site and return it to the document so I can render it with a DTML method. I have an extension method that is invoked with <dtml-var "download_weather(this())">. The definition of download_weather (slightly stripped down) is as follows: def download_weather(loc): city = capitalize(lower(loc.city)) state = upper(loc.state) # Download HTML and strip excessive formatting. data = urllib.urlopen(url).read() # Grab the current conditions. loc.current = get_current_conditions(data) # Grab the extended forecast. loc.forecast = get_extended_forecast(data) The weather object "loc" has a city and state property which is used to create the proper URL. get_current_conditions and get_extended_forecast both return simple classes similar to the following: class Current: def __init__(self,temperature,image,conditions): self.temperature = temperature self.image = image self.conditions = conditions The problem comes when setting the loc.current and loc.forecast attributes. They seem to do what they are supposed to when viewing the output in the management screens, but as soon as I view the output outside of the management screen I get the following error: Error Type: SystemError Error Value: Failed to import class Current from module __main__ In addition to that, the weather object turns into a Folder object which can't be modified or deleted. I still haven't figured out how to get rid of it. What am I doing wrong? -- Kevin Smith anathema@iname.com carpe noctum
Have you tried putting your module which contains the classes in the lib/python/Shared dir? I thought to have read somewhere that Zope doesn't doe imports etc from the Extensions dir. Jeroen
-----Original Message----- From: kesmit@bellsouth.net [mailto:kesmit@bellsouth.net]On Behalf Of Kevin Smith Sent: dinsdag 18 januari 2000 22:08 To: zope@zope.org Subject: [Zope] How can I persist some simple data?
I am trying to create a product that will grab all of the weather information from a weather site and return it to the document so I can render it with a DTML method. I have an extension method that is invoked with <dtml-var "download_weather(this())">. The definition of download_weather (slightly stripped down) is as follows:
def download_weather(loc): city = capitalize(lower(loc.city)) state = upper(loc.state)
# Download HTML and strip excessive formatting. data = urllib.urlopen(url).read()
# Grab the current conditions. loc.current = get_current_conditions(data)
# Grab the extended forecast. loc.forecast = get_extended_forecast(data)
The weather object "loc" has a city and state property which is used to create the proper URL. get_current_conditions and get_extended_forecast both return simple classes similar to the following:
class Current: def __init__(self,temperature,image,conditions): self.temperature = temperature self.image = image self.conditions = conditions
The problem comes when setting the loc.current and loc.forecast attributes. They seem to do what they are supposed to when viewing the output in the management screens, but as soon as I view the output outside of the management screen I get the following error:
Error Type: SystemError Error Value: Failed to import class Current from module __main__
In addition to that, the weather object turns into a Folder object which can't be modified or deleted. I still haven't figured out how to get rid of it.
What am I doing wrong?
-- Kevin Smith anathema@iname.com carpe noctum
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Jeroen Baekelandt -
Kevin Smith