[Zope-dev] more external database trouble

Jim Penny jpenny@universal-fasteners.com
Fri, 3 Sep 1999 17:02:31 -0400


I want to thank  Martijn one more time.  

But, I am still confused.

Here is where I am at.

Recap.
Question1:  how do I invoke a ZSQLmethod named sql_test with
argument sequence_number from an external method.

Answer1;  (thanks Martijn).  Well, try
sql_test(sequence_number=value).

Argh.  So blindingly easy.

Question 2:

OK, so that get me a result.  How do I interpret it?

Martijn answerered:
>Returned is a list of row objects, and each row object is just a dumb class
>with the different columns converted to class attributes.

>So you test for the length of the result, loop through it like any list and
>access attributes on the list objects, including list.__dict__.keys() for a
>list of attributes.

I still do not understand, although I am sure it is my density that is 
the problem.

OK, I set
a=sql_test(sequence_number=value)

sql_test has body
select *
from sample_room_list_item
where
sales_request_number = <dtml-sqlvar sales_request_number type=int>

Now I start grubbing around with attributes of a.

I find all of these facts:
dir(a)=['__items__', '_class', '_data', '_data_dictionary', '_names', '_nv', 
	'_parent', '_schema']", "
dir(a.__items__)=['append', 'count', 'extend', 'index', 'insert', 'pop', 
	'remove', 'reverse', 'sort']
dir(a._class)=['DESCRIPTION', 'ITEM', 'LOCATION_QTY', 'QTY_DESIRED', 
	'SALES_REQUEST_NUMBER', '__add__', '__basicnew__', '__comp__',
	'__doc__', '__getattr__', '__getitem__', '__getslice__', 
	'__getstate__', '__init__', '__len__', '__module__', '__mul__', 
	'__record_schema__', '__reduce__',
'__setattr__', '__setitem__', '__setslice__', '__setstate__']
dir(a._data)=['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
dir(a._data_dictionary)=['clear', 'copy', 'get', 'has_key', 'items', 'keys', 'update', 'values']
dir(a._names)=['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
dir(a._nv)=[]
dir(a._parent)=['__ac_local_roles__', '_objects', 'finalize_changes', 'id', 'index_html', 'sql_add_sample_room_items', 'sql_delete', 'sql_test',
'sql_update_sample_room_request', 'test', 'title']
dir(a._schema)=['clear', 'copy', 'get', 'has_key', 'items', 'keys', 'update', 'values']
dir(a._class.ITEM)=['_n']
dir(a._class.ITEM._n)[]

Some parts look real familiar (like _parent, and _class).  But I still have
not been able to get my grubby little fingers on the actual data!

Help me Mr. Wizard!

Thanks.

Jim Penny
str(a._class.ITEM._n)=item")