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
On 19 Apr 1999, Kent Polk wrote:
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.colNames() ['ID', 'SAMPLE', 'DATE', 'VIAL', 'SAMPLE', 'TYPE', 'PROJ', 'COMMNT', 'PNTR']
(I obviously don't have things wired up correctly...)
I am not sure I understand what you want to do but one thing that might help (assuming you are running the above from ZPublisher) is to replace: def summary (self): return HTML(self.summary_dtml) with summary=HTML(self.summary_dtml) in your class definition. I hope it helps Pavlos
On 19 Apr 1999 17:55:01 -0500, Pavlos Christoforou wrote:
On 19 Apr 1999, Kent Polk wrote:
How do I point a DTML method at the correct object ?
I am not sure I understand what you want to do but one thing that might help (assuming you are running the above from ZPublisher) is to replace:
def summary (self): return HTML(self.summary_dtml) with
summary=HTML(self.summary_dtml)
Thanks Much! That gets rid of the double parens, but still doesn't find the instance method, so I'm still pointing off in space there or something. Kent
On 19 Apr 1999 21:48:36 GMT, Kent Polk wrote: [...]
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.
[...]
Question #2: ------------
How do I point a DTML method at the correct object ?
Hmmm... re-re-reading ExtensionClass.stx, I ran across this statement: "Currently, when accessing a class instance attribute, the attribute value is bound together with the instance in a method object *if and only if* the attribute value is a python function. For some applications, we might also want to be able to bind extension functions, or other types of callable objects, such as HTML document templates [2]." I think this describes my problem where my instance mapping a.b.c.d.e() can call Python methods and attributes, but DTML can't locate the methods or attributes. I suspect that I am not instantiating my objects correctly, but don't see what I'm supposed to be doing. Currently, as a parent object determines its children, I have it instantiate them and then call their 'load' method which (recursively) has them locate their children, instantiate and load them, etc. def _setObject(self,id,object): setattr(self,id,object) try: t=object.meta_type except: t=None self._objects=self._objects+({'id':id,'meta_type':t},) self._setObject(name, SubDir(name)) obj = getattr(self, name) obj.load() my classes are: class Connection(ExtensionClass.Base): class SubDir(Acquisition.Implicit) : class Database(Acquisition.Implicit) : class PedSysFile(Acquisition.Implicit) : and all but the last can contain children. Does anyone have an example of how objects are supposed to be recursively instantiated using ExtensionClass? I've seen a few potential examples, but each is instantiated differently and doesn't provide an explanation for why they are instantiated differently. Thanks Much! Kent
participants (2)
-
kent@tiamat.goathill.org -
Pavlos Christoforou