[Zope] How do I create a folder full of "virtual" DTML objectsfrom records in a database records in a database

Kapil Thangavelu kthangavelu@earthlink.net
Thu, 24 Aug 2000 20:03:44 -0700


Chris Beaumont wrote:
> 
> David,
> 
> Thank you, I've been successful in setting up basic SQL methods, data
> input forms and query forms,
> the problem Ive been having is in trying to break each table record (one
> row in a table, say) out into a separate DTML document.. with fields in
> the record forming the parts of the document..  (I'm making a web
> heirarchy of events which each have to have their own page with various
> kinds of constantly changing information about the event on them..
> These pages have to live at relatively stable URLs.. (of course, it
> doesnt matter if they are physical documents to a search engine..)


Some considerations. 

1. Duplicating data is bad. 

2. Let the RDMBS do as much of the processing as possible.


A possible solution (TMTOWTDI):


create a dtml method 'create event'. its basically an encapsulation to
simulate triggers. in this method make your call to the insertion of the
data into the sql db. after that call you can create a ZClass or DTML
document with the property that stores the primary key of the data
record in the DB (if you do it as a dtml doc, you either want to clone,
or pass its body, check out the ZQR). this is your basic association of
your objects and the sql data. in a dtml method that lives above your
objects have a body that basically calls a retrieval sql on the db which
takes an arg for the id. The body of your dtml doc/ZClass(index_html)
calls this method for presentation of its data passing its property as
an arg. you can arrange your objects in whatever heirarchy you want as
they will acquire the dtml method and the sql methods for presentation
(or put it in the zclass). For deletion create a similiar trigger
encapsulation method, delete row, delete object. 


caveat. DON't use this to display lots of events on a page (hideous
performance). you're much better off going to the db directly and
grabbing all the results you need perhaps with python brain for extra
presentation info.


Cheers 

Kapil


> So far what Ive seen in the ZSQL Methods guide are lots of hints on how
> to use SQL methods to build tables from my data, and how to build
> interfaces to use a given SQL query to filter those tables by content..
> Which is great if you want lots of lists..
> 
> What I want to build are lists *and their linked documents*  the
> records' fields flowing into  the meta tags and body text of many
> individual objects. When a record is deleted from the source SQL table,
> I want to be able to have that deletion propagate to the child
> document..
> 
> Is a valid approach to iterate through all of the rows of the table,
> taking one field of the individual record and using that to deliniate
> the "ID" of the generated document, then writing the others out as HTML
> through dtml-var tags?
> 
> I know this seems like a stupid question, but it seems as if this is
> such a common need that I cant help but feel that one of the available
> products would address it. If one doesnt exist then yes, I'll have to
> figure it out myself.. I've seen similar things done in some Zope
> products.. so I know it can be done... What I was hoping for is for some
> suggestions on the best way to go about it that didnt require me
> figuring it out from scratch....
> 
> Thank you
> 
> "R. David Murray" wrote:
> >
> > On Wed, 23 Aug 2000, Chris Beaumont wrote:
> > > I need to take rows in an SQL database table, and create one or
> > > several nested folders of web pages out of them..
> >
> > I'd suggest checking out the ZSQL Methods manual, and then asking any
> > questions that you still have (and there probably will be some!)
> >
> >
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )