Hi All,

I'm trying to implement a computer booking system for staff members here. At
the moment I have a table with date, timeslot (eg 8:00 - 9:00), resource
(eg. PC 1) and person. I want to draw a table showing the bookings for the
day looking something like this:

|Time| PC 1 | PC 2 | PC 3 |
|8:00|  AH  |      |      |
|9:00|      |  BC  |  MD  |
+----+------+------+------+  etc...

I thought the best way to do it would be use the table to populate a
dictionary of dictionaries like:

booking['8:00']['PC 1'] = 'AH'

Then when I'm rendering the table using ZPT I can use a nested loop to look
through the timeslots and resources and fill table cells with the
booking[slot][resource] value if it exists.

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 understand
what I am doing wrong.




#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\Publish.py, line 150, in
  File D:\ongaku\lib\python\ZPublisher\Publish.py, line 114, in publish
  File D:\ongaku\lib\python\Zope\__init__.py, line 159, in
    (Object: bookings)
  File D:\ongaku\lib\python\ZPublisher\Publish.py, line 98, in publish
  File D:\ongaku\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: render_bookings)
  File D:\ongaku\lib\python\ZPublisher\Publish.py, line 39, in call_object
    (Object: render_bookings)
  File D:\ongaku\lib\python\Shared\DC\Scripts\Bindings.py, line 252, in
    (Object: render_bookings)
  File D:\ongaku\lib\python\Shared\DC\Scripts\Bindings.py, line 283, in
    (Object: render_bookings)
  File D:\ongaku\lib\python\Products\PythonScripts\PythonScript.py, 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)

Anton Hughes

Data Administrator
Childhood Determinants of Adult Health Project
Menzies Centre for Population Health Research
GPO Box 252-23, Hobart Tasmania 7001

Web:  http://www.menzies.utas.edu.au/cohort/CDAH.htm
Phone: +61 (0) 3 6226 7761

Sattinger's Law:
      It works better if you plug it in.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to