[Zope-dev] Acquisition Questions

Kent Polk kent@goathill.org
19 Apr 1999 21:48:36 GMT


I have a couple of probably dumb questions...

I'm attempting to develop a future Zope product and am currently
testing it using ZPublisher in order to make sure I'm not too far
off in left field.

I have a rather large set of file-based genetic databases which I
want to publish.  There is no 'database manager', only 25 or so
years worth of Fortran code to build, manage and query the database
files besides the database search capabilities that I'm writing.

The database files are actually two files which include a table
format specification and the table file. The databases are arranged
in a  fashion in the file-system which includes a file
index for each database encountered in that directory.

What I have done is to build a hierarchy of object instances which
correspond to the subdirectories and files contained within that
file-system. Not by happenstance, each instance highly resembles a
TinyTable and is query-able in the same fashion as TinyTables.

For example, say I have a base subdirectory named 'psys', which
contains a single subdirectory 'XMP' which contained one Database
and one Subdirectory 'LOCUS' containing unlinked files (support
files not directly linked to a database)

psys/                              (Connection)
     example/                      (SubDir)
             XMP/                  (PedSys_DB - Database)
	        <Database Files>   (PedSysFile)
             LOCUS/                (SubDir)
	        <unlinked files>   (PedSysFile)

>>> for i in psys.__dict__.keys():
...  print i,': ',psys.__dict__[i]
id :  psys
title :  '' 
_objects :  ({'meta_type': 'PedSys_SubDir', 'id': 'example'},)
_rows :  ['example']
example :  <SubDir instance at 0x975a0>

>>> for i in psys.example.XMP.__dict__.keys():
... print i,': ',psys.example.XMP.__dict__[i]
id :  XMP
title :  Example Database 
_objects :  ({'meta_type': 'PedSys_Datafile', 'id': 'MASTER'}, [...]
_rows :  [['XMP', 'MASTER', 'Example Master File', 'Example',  [...]
SAMPLES :  <PedSysFile instance at 0x97600>
MASTER :  <PedSysFile instance at 0x975c0>
QUANTGEN :  <PedSysFile instance at 0x975d0>
HEMOGLOB :  <PedSysFile instance at 0x97610>

An example query would be:
>>> psys.example.XMP.SAMPLES(EGO='ID097', PNTR=1)
[['ID097', 'S219', '19800701', '9ML', 'LOW', '', 'HL', 'HOSP', 1]]

And from ZPublisher:
 http://<hostname>/psys/example/XMP/SAMPLES/index_html
returns the default HTML view of the table.

It's basically a superset of the capability to publish a file-system
hierarchy which recursively instantiates subdirectories and builds
tables of the items found in those subdirectories.

Question #1:
------------

With Zope External Methods, I can instantiate an external method
at the root of the Zope hierarchy which returns attributes of self,
where self is any object instance. When I take the exact same method
and include it in the base Connection class, All references to self
look at that base class:

>>> for i in psys.testit():
...  print i
self.__dict__=
_rows:['example']
_objects:({'meta_type': 'PedSys_SubDir', 'id': 'example'},)
example:<SubDir instance at 0x975a0>

>>> for i in psys.example.testit():
...  print i
self.__dict__=
_rows:['example']
_objects:({'meta_type': 'PedSys_SubDir', 'id': 'example'},)
example:<SubDir instance at 0x975a0>

So how do I get the method 'testit' to point to the correct 'self'
as I can do with an External Method?

Question #2:
------------

How do I point a DTML method at the correct object ?

   summary_dtml = """<!--#in colNames -->
   <!--#var id-->, <!--#var title--><BR>
   <!--#/in -->
   """

   def summary (self):
       return HTML(self.summary_dtml)

>>> psys.example.XMP.SAMPLES.summary()()                    
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "./DT_String.py", line 513, in __call__
  File "./DT_In.py", line 620, in renderwob
  File "./DT_Util.py", line 266, in eval
  File "<string>", line 0, in ?
NameError: colNames

>>> psys.example.XMP.SAMPLES.colNames()
['ID', 'SAMPLE', 'DATE', 'VIAL', 'SAMPLE', 'TYPE', 'PROJ', 'COMMNT', 'PNTR']

(I obviously don't have things wired up correctly...)

Thanks
Kent