Hmmm..... I posted code on the end of that message. I don't know what
happened to it. Anyway, I'll post the code here:

#parameters: booking_date
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST

bookings = {}   # declare the bookings dictionary
resource_hash = {} #declare the resource dictionary

#populate bookings dictionary with timeslot keys
for row in context.resources():
      resource = row['name']
      resource_hash[resource] = ''

#populate bookings dictionary with timeslot keys
for row in context.timeslots():
      slot = row['slot_name']
      bookings[slot] = resource_hash

#fill the bookings dictionary of arrays with actual bookings
for row in context.getBookings(on_date=booking_date):
     slot = row['timeslot']
     resource = row['resource'] - 1
     person = ['person']
     bookings[slot][resource] = person

return bookings

Error Type: TypeError
Error Value: unsupported operand type(s) for -

Traceback (innermost last):
  File D:\ongaku\lib\python\ZPublisher\, line 150, in
  File D:\ongaku\lib\python\ZPublisher\, line 114, in publish
  File D:\ongaku\lib\python\Zope\, line 159, in
    (Object: bookings)
  File D:\ongaku\lib\python\ZPublisher\, line 98, in publish
  File D:\ongaku\lib\python\ZPublisher\, line 88, in mapply
    (Object: render_bookings)
  File D:\ongaku\lib\python\ZPublisher\, line 39, in call_object
    (Object: render_bookings)
  File D:\ongaku\lib\python\Shared\DC\Scripts\, line 252, in
    (Object: render_bookings)
  File D:\ongaku\lib\python\Shared\DC\Scripts\, line 283, in
    (Object: render_bookings)
  File D:\ongaku\lib\python\Products\PythonScripts\, line
302, in _exec
    (Object: render_bookings)
    (Info: ({'script': <PythonScript instance at 01707050>, 'context':
<PortalFolder instance at 01CFFEE0>, 'container': <PortalFolder
instance at 01CFFEE0>, 'traverse_subpath': []}, ('9/9/02',), {}, None))
  File Script (Python), line 23, in render_bookings
TypeError: (see above)

Thanks again,


-----Original Message-----
From: Andy McKay [mailto:[EMAIL PROTECTED]]
Sent: Friday, 6 September 2002 3:12 PM
To: Anton Hughes; [EMAIL PROTECTED]
Subject: Re: [Zope-dev] Trouble populating a dictionary of dictionaries

> After playing around for too long on it, I can't seem to get it to work. I
> even tried pre-filling the d-o-d with empty strings. I just don't
> what I am doing wrong.

Its really rather hard to say if you dont show us some code ;)
  Andy McKay
  Agmweb Consulting

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to