[Zope-dev] Object references from dtml

Ross Boylan RossBoylan@stanfordalumni.org
Fri, 20 Oct 2000 10:16:44 -0700


> -----Original Message-----
> From: ender@earthlink.net [mailto:ender@earthlink.net]On Behalf Of Ender
> Sent: Thursday, October 19, 2000 10:13 PM
> To: Ross Boylan
> Cc: zope-dev@zope.org
> Subject: Re: [Zope-dev] Object references from dtml
>
>
> Ross Boylan wrote:
> >
> > I have a log composed of sublogs, and so on.  I would like for
> people to be
> > able to see some kind of summary (e.g., short versions of the
> logs down n
> > levels) on the screen and then click on one of interest and see a fuller
> > display of it.
> >
> > Is there a good way to do this using dtml?
> >
> > I've thought of two approaches.  The "standard" zope
>
> having recently debugged company's zope server, i can safely say that
> there is no 'standard'.
>
> > way seems to be to
> > make each log folderish, and give each entry an id.  Then I can
> embed the
> > address in the html.  The problem with this is that I would
> have to make up
> > the id's and add extra machinery that the logs don't really need.
>
> > I'm leaning toward a second approach, of getting an object id
> and putting
> > it in the html.  This also raises some issue.
>
> you lost me. your problem with the first method is having ids for your
> log entries and your second method starts with getting ids for your
> objects.

The first method involves my creating and managing object id's.  Since this
is presumably done by the system anyway, I'd rather use the system's.  Also,
the first method involves having to add the "id" variable to each entry, and
folder capability to each container, and so on.  (Most of the entries are
simultaneously containers).
>
>
> looking ahead, YIKES, you just went from can i do this in dtml to
> messing with python code in the guts of the ZODB. that was a SERIOUS
> leap. IMO i'd highly recommend against messing with the zodb stuff, _p_
> attrs are supposed to be reserved. i understand you want to treat them
> as read only, but i wouldn't even go near it if it could be implemented
> easily otherwise or i had developed a strong masochistic tendency and
> already knew the zodb well (well enough to know the answers to the below
> questions).
>
> > This also raises some issue.
> >    * Will the id be stable in the face of the db potentially
> > dematerializing objects underneath?
>
> what id?
The question is general, but I presumably have a choice of two id's: the
regular python object id and the persistent object id.

The question is asking whether the regular id or the persistent id are
stable.  I presume the former is not (if you're using the db), while I hope
that the latter is.
>
> >    * If I use a persistent id (_p_oid, I think), will that be stable?
>
> see above commentX2.
>
> >    * (Also, I'll need to be sure everything has persisted, but I think I
> > can do that by forcing a transaction end before getting the _p_oid).
>
> transactions are important, but also telling it before hand that the
> object is dirty and needs to be saved. you might want to read jim's
> paper on the zodb. it and alot of other good material are linked from
I think I've read them all.  Dirtyness is not a problem, since the only
objects
that might lack a _p_oid are new ones.  I don't know at what point they get
created, so I figure I want to force a commit to assure they have meaningful
values.
>
> http://www.zope.org/Members/itamar/LearningZope/LearningZope.html
>
> >    * Can I map from object id back to object?
> (_p_jar.something or other)
>
> this is getting worse(scarier?) as i go on... i have no idea. consider
> also that a url is also a unique persistent object id that maps into the
> zodb, why your first method works.
>
> >    * Will this be robust across database changes (minimally,
> from ZODB to
> > ZEO)?
> >    * Will the object id consist of characters which can be
> embedded easily
> > in html?
> >
>
> ...
>
> there are alot of other ways to do this... of the top of my head
>
> you could always store log entries in a sql db.
I want to avoid relational db's.  They are particularly ill-suited to this
task, which involves deeply nested, heterogeneous object graphs.
>
> since you seem not adverse to doing it in python, despite your original
> question...
Oh, I'd much rather be doing python.  I only bring up dtml because I need to
display something the user can see.  So d/html is the presentation language,
and I need some way of associating gui elements with objects.
>
> so why not just write a python class for the log folder thats
> persistent, add some methods for managing/storing log entries in a some
> attr (maybe list of dicts) of the logfolder. write some dtml accessible
> accessor methods to the attrs. write a dtml page for summary and one for
> details.
That might be the best solution.  As I say, it just seems silly to be
recreating an oid scheme when we've already got a couple of them.
>
> kapil