[Zope] How can I persist some simple data?

Kevin Smith anathema@iname.com
Tue, 18 Jan 2000 16:08:22 -0500


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