[Grok-dev] grokcore.resource
Jan-Jaap Driessen
janjaapdriessen at gmail.com
Mon May 14 18:54:30 UTC 2012
Hi Danilo,
Thank you for your input.
On Wed, May 2, 2012 at 1:03 AM, Danilo G B <danilogbotelho at yahoo.com> wrote:
> I'd suggest another name for the directive like 'resources' (in the plural,
> as with 'permissions').
>
> 'includes' is probably too generic but makes a lot of sense to me.
`resources` is a better name indeed. I changed it.
> Also, why include parents' resources for subclasses as the default
> behaviour?
It was indeed not a good idea to include the resources of the parents
of an object. I removed this.
> How to turn that off? I usually subclass layouts to change the
> needed resources. So, I'd suggest extending the 'resources' directive to
> have it accept resources and 'resource includers':
>
> class Layout1(grok.Layout):
> grok.resources(r1, r2)
>
> class Layout2(Layout1):
> grok.resources(Layout1, r3)
I am not sure how I feel about passing in the Layout class to the
`grok.resources` directive. I don't see an immediate use case in my
applications so I won't implement it now.
> "In order to make this work for Layouts I don't see another way than
> emitting an event right before the layout is rendered in
> grokcore.layout:"
>
> I haven't checked this, but can't you get the layout from the view being
> traversed to?
In the most recent release of grokcore.layout, this has been made
available as a "private" method. I am using that one to get to the
layout of a view.
> Maybe a solution which adds a method to the 'resource includers' makes this
> more easy and natural. I haven't thought this through. Lately I've been
> using a method named update_resources called from my layouts which is
> responsible for updating the resources required by each view. This allows
> for subclasses to decide whether use parents resources or not.
>
> I hope we can reach an easy to use and natural way of including resources in
> Grok.
Thanks for thinking with me. I will send a separate email to the
mailing list asking other developers to try grokcore.resource and
learn whether they find it useful.
Cheers,
JJ
More information about the Grok-dev
mailing list