[Grok-dev] REPOST Re: Add Form URLS

Tim Cook timothywayne.cook at gmail.com
Sat Jan 24 17:50:49 EST 2009


Sebastian you are a STAR!

Thanks,
Tim



On Sat, 2009-01-24 at 20:28 +0100, Sebastian Ware wrote:
> 24 jan 2009 kl. 20.05 skrev Tim Cook:
> 
> > On Sat, 2009-01-24 at 18:58 +0100, Sebastian Ware wrote:
> >> This is also behaves like a dictionary, but
> >> grok.Application, unlike grok.Container, kan be populated during
> >> __init__. In other words, you can add your root Ehr object when you
> >> are creating your
> >
> > So are you saying that "somewhere" (app.py???) I could setup my  
> > database
> > with:
> >
> > app["Oship"]=grok.application()
> > Oship["clinical"]=grok.Container()
> > Oship["demographics"]=grok.Container()
> > Oship["ar"]=grok.Container()
> > Oship["termserver"]=grok.Container()
> >
> > automagically?
> >
> 
> Kind of. The application is added by you manually in the admin  
> interface. The __init__ method is run when the application is added  
> and you can do your setup there.
> 
> 
> class Oship(grok.Application):
> 
>     def __init__(self):
>         self.context['clinical'] = grok.Container()
>         # etc... "automagically"
>         # Note, this only runs when you create the application
> 
> Another way to add that stuff is through a view:
> 
> class Setup(grok.View):
>     grok.context(Oship)
> 
>     def render(self):
>         self.context['clinical'] = grok.Container()
>         # etc.
>         return "Done!"
> 
> You access the setup view with an url like this:
> 
>     http://localhost:8080/app_name/setup
> 
> You will need to change the context of your add class since you adding  
> objects to grok.Container.
> 
> class AddEhr(grok.AddForm):
>     grok.context(grok.Container)
>     form_fields = grok.AutoFields(Ehr)
> 
>     def add(self, **data):
>        new_obj = Ehr()
>        self.applyData(new_obj, **data)
>        self.context[key] = new_obj
> 
> You access the add view with an url like this:
> 
>     http://localhost:8080/app_name/clinical/addehr
> 
> Mvh Sebastian
-- 
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
**************************************************************
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090124/5438ba7b/attachment.bin 


More information about the Grok-dev mailing list