[Grok-dev] Question about using the grok.name('index')
geoHUZ
geohuz at gmail.com
Thu Jan 29 12:27:06 EST 2009
I assumed the entry is the instance of Entry and I tried to use
entry/entryindex to access it but it still failed, 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)
Christian Klinger wrote:
>
> Hello
>
>> In the Grok tutorial, the last example shows how to use grok directive to
>> explicitly connect to model, and associate a view as the index view.
>> While
>> playing with the example code, I'm wondering how can I access the object
>> through the url if I don't use grok.name('index'),
>>
>> class EntryIndex(grok.View):
>> grok.context(Entry)
>> grok.name('index')
>> ....
>>
>> by removing the grok.name('index'), I know I'm supposed to use url such
>> as
>> /entryindex to access the Entry, but I can't work it out.
>>
>
> you have a grok.context(Entry). So I think your url is
>
> /yourEntryobject/entryindex
>
> hth chrisitan
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>
>
--
View this message in context: http://www.nabble.com/Question-about-using-the-grok.name%28%27index%27%29-tp21711269p21731605.html
Sent from the Grok mailing list archive at Nabble.com.
More information about the Grok-dev
mailing list