[Grok-dev] URL Construction

Tim Cook timothywayne.cook at gmail.com
Sat May 2 08:04:38 EDT 2009

Hi Michael,

I've tried several attempts at context changes and most of them had
obvious effects.  I think that my (mental) problem lies in understanding
the relationships between what is viewed inn the browser and where it is
located in the ZODB.

Let me kind of think this (the design) through out loud here and see if
someone can tell where I am making my mistake.

On Sat, 2009-05-02 at 08:32 +0200, Michael Haubenwallner wrote:

> grok.Viewlets are registered for the context object or the module context.
> They have an associated grok.ViewletManager.
> grok.ViewletManagers are called (provider:viewletmanager_name) in
> grok.Views (and their templates).

Right.  So I have an application 'bptrack'
The Index has it's own render method that does some setup when you
access it. Basically Setup creates 2 grok containers 'demographics' &
'clinical'.  So the ZODB path (if you will) is:

bptrack ----demographics

I have one View -- BPMain.  BPMain registers 4 ViewletManagers:

BPMain ----Header == grok.name('header')
       |---Patients == grok.name('patients')
       |---DataArea == grok.name('dataarea')
       |---Footer   == grok.name('footer')

1. Header has one Viewlet - PageTitle == pagetitle.pt  

2. Patients has 2 Viewlets - PatientsHead == patientshead.pt &
PatientsList - has it's own render method to create an HTML unordered
list of all the records (keys) in the demographics container.  It also
needs to create an HTML link for each displayed name so that when it is
clicked, the appropriate clinical record will be selected (based on the
attribute ehrid) and certain items will display in the DataArea

3. DataArea has 3 Viewlets - 

DataArea Viewlet  NewPatient - newpatient.pt (an html POST form with the
action set to the View AddPatient - this is where the  class
Patient(grok.Model), is instantiated and added to the demographics
container. Also, one of the attributes is called ehrid and is supposed
to be the link from the demographics container to a matching object in
the clinical container. Add Patient works fine and the container within
the demographics container is created, with the correct name (verified
via the object browser).

DataArea Viewlet  BPData - bpdata.pt will be an HTML data entry form.
Right now it just renders a simple text statement in the correct place
in the viewlet. 
DataArea Viewlet EhrIndex - Will be charged with listing previously
entered data from the clinical record (when the link is working).  Right
now it just renders a simple text statement in the correct place in the

4. Footer - footertext.pt - works fine. 

So my problem is that I have objects (from thee demographics container)
listed in the Patients viewlet that are supposed to have html links that
display a related object (from the clinical container) in the DataArea

Without me saying what is registered where; using grok.context().  Can
someone tell me from the above description where each View,
ViewletManager and Viewlet should be registered?     

I will say that I originally though that if everything was registered to
bptrack (the application) then it should all work.  It didn't.

Again; my mental disconnect is how to relate the browser display
controls (Views, ViewletManagers & Viewlets) to what is actually in the
ZODB.  Because using the grok object browser; everything is in place as
far as the right data in the right containers. So how do I relate the
clinical container and demographics container to what will be in the
display?  Shouldn't those container names be in the URL? 

Thanks for any hints or tips.  I have a feeling that this will turn into
a tutorial when it's solved.  ;-)
> Any (lowercased) grok.View class name registered for the context object
> ('2009-05-01T17:52:46.791189' ) or (if registered for
> zope.interface.Interface) containing the associated grok.ViewletManager
> should work fine.

Hmmmm, can a viewlet have an __init__() where I can then set the context
to the currently selected object?????  Answering myself; no I don't
think so because grok.context requires and Interface or a class.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090502/982d13ad/attachment.bin 

More information about the Grok-dev mailing list