[Grok-dev] Question about using the grok.name('index')

Uli Fouquet uli at gnufix.de
Thu Jan 29 13:07:29 EST 2009


Hi there,

geoHUZ wrote:
> I assumed the entry is the instance of Entry and I tried to use
> entry/entryindex to access it but it still failed,

Your assumption sounds correct. The entry should be contained in the
app, right? So you must create an app first and in this app an entry
object (an instance of `Entry`). If this happend, something like

  http://localhost:8080/myapp/myentry/entryindex

or 

  http://localhost:8080/myapp/myentry/@@entryindex

should display the view of the `Entry`-instance which is stored under
the name ``myentry`` in an application-instance named ``myapp``.

>  here is the full code:
> 
> import grok
> 
> class Sample(grok.Application, grok.Container):
>     pass
> 
> class Entry(grok.Model):
>     def __init__(self, text):
>         self.text = text
> 
> class SampleIndex(grok.View):
>     grok.context(Sample)
>     grok.name('index')
> 
>     def update(self, name=None, text=None):
>         if name is None or text is None:
>             return
>         self.context[name] = Entry(text)
> 
> class EntryIndex(grok.View):
>     grok.context(Entry)
> 

Looks okay to me. Did you create an entry before trying to access it?
Something like

  http://localhost:8080/myapp?name=myentry&text=blah

maybe?

Best regards,

-- 
Uli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090129/1a0d971e/attachment.bin 


More information about the Grok-dev mailing list