[Grok-dev] Containers with different object types and traversal
Steve Schmechel
steveschmechel at yahoo.com
Sat Mar 28 12:27:57 EDT 2009
--- On Sat, 3/28/09, Roger Erens <roger.erens at e-s-c.biz> wrote:
> From: Roger Erens <roger.erens at e-s-c.biz>
> Subject: Re: [Grok-dev] Containers with different object types and traversal
> Hi Steve,
>
> Another small question: I expect that there will be
> multiple instances
> of Perfomance, each with its own location and leader. Do
> you have a
> reason for not moving those variables into the __init__()
> method?
Not really. After reading Kevin Teague's great howto [1], I believe that those two field could go in the init because the schema actually marks them as "required". Either way, they will end up in the database.
I also added two more fields for the start and end time, but left them optional. Those have a default value that I will probably leave at the class level because, if I decide to change the default, any that are not explicitly assigned a value will take on the new default.
(Kevin explains it better though.)
[1] http://grok.zope.org/documentation/how-to/understanding-default-values-for-object-database/
Thanks for your question. It got me thinking about that topic and I learned something new.
Thanks,
Steve
> To:
> Cc: "Grok list" <grok-dev at zope.org>
> Date: Saturday, March 28, 2009, 9:38 AM
> on 27-3-2009 23:05 Steve Schmechel wrote:
> > I will try to cover this topic in the tutorial I am
> writing.
> > I want to post back what I ended up doing here, in
> case someone else finds this thread during a search.
> >
> > The class holding the two containers ended up looking
> like this:
> >
> > class Performance(grok.Container):
> > interface.implements(IPerformance) #Only affects
> display of
> > location = u''
> #fields on forms. Template
> > leader = u'' #must
> handle containers.
> > def __init__(self):
> > super(Performance, self).__init__() #See note
> below.
> > self['musicians'] = Musicians()
> #Inherits from grok.Container
> > self['songs'] = Songs()
> #Inherits from grok.Container
> >
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list