Viewlets: Check for availability

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Viewlets: Check for availability

Danilo G B
Hi, guys.

I was wondering why viewlets in Grok, like viewlets in Plone, don't have a method to check their availability at the render time.
This would be as simple as changing the last line in the render method of the ViewletManager component (grokcore.viewlet:components.py):

class ViewletManager(ViewletManagerBase):
    ...
    def render(self):
        ....
   -- return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
  ++ return u'\n'.join([viewlet.render() for viewlet in self.viewlets if viewlet.available()])

and adding the available method to Viewlet:

class Viewlet(ViewletBase):
    ...

    def available(self):
        return True

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Christian Klinger
Hi,

i think there were some discussions lately about this topic on a sprint.
I don't know to which conclusions we come...

For me i want to add a +1 for it.

Christian

> Hi, guys.
>
> I was wondering why viewlets in Grok, like viewlets in Plone, don't have
> a method to check their availability at the render time.
> This would be as simple as changing the last line in the render method
> of the ViewletManager component (grokcore.viewlet:components.py):
>
> class ViewletManager(ViewletManagerBase):
> ...
> def render(self):
> ....
> -- return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
> ++ return u'\n'.join([viewlet.render() for viewlet in self.viewlets i f
> viewlet.available()])
>
> and adding the available method to Viewlet:
>
> class Viewlet(ViewletBase):
> ...
>
> def available(self):
> return True
>
>
>
> _______________________________________________
> Grok-dev mailing list
> [hidden email]
> https://mail.zope.org/mailman/listinfo/grok-dev


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Jan-Wijbrand Kolman-3
On 6/15/11 08:08 , Christian Klinger wrote:
> i think there were some discussions lately about this topic on a sprint.
> I don't know to which conclusions we come...
>
> For me i want to add a +1 for it.

I think to remember we explicitly decided not to add this feature,
somewhere along the line of "different applications have different needs
in this regards, and it is easy to add yourself".

Not sure anymore though.

You suggestion apearts to be reasonable "safe" to add though. Thinking
about it now, I'd not be against it.

BTW, I'm about to work on grokcore.view and grokcore.viewlet soon anyway
for content providers. I could try to include this suggestion too.

regards, jw

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Sylvain Viollon
On Wed, 15 Jun 2011 13:10:20 +0200
Jan-Wijbrand Kolman <[hidden email]> wrote:

  Hello,

> On 6/15/11 08:08 , Christian Klinger wrote:
> > i think there were some discussions lately about this topic on a
> > sprint. I don't know to which conclusions we come...
> >
> > For me i want to add a +1 for it.
>
> I think to remember we explicitly decided not to add this feature,
> somewhere along the line of "different applications have different
> needs in this regards, and it is easy to add yourself".
>
> Not sure anymore though.
>
> You suggestion apearts to be reasonable "safe" to add though. Thinking
> about it now, I'd not be against it.
>
> BTW, I'm about to work on grokcore.view and grokcore.viewlet soon
> anyway for content providers. I could try to include this suggestion
> too.
>

  Honestly I use it at few places, and my customer needs it as well (on
  plain viewlets).

  An available method on a Viewlet and check it in the filter of the
  ViewletManager would be great.

  +1 from my part, and +1 from the part of my customer so that makes
  +2, and it is justified.

  Regards,

  Sylvain.

--
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Jan-Wijbrand Kolman-3
On 6/15/11 14:44 , Sylvain Viollon wrote:

> On Wed, 15 Jun 2011 13:10:20 +0200
> Jan-Wijbrand Kolman <[hidden email]> wrote:
>> On 6/15/11 08:08 , Christian Klinger wrote:
>>> i think there were some discussions lately about this topic on a
>>> sprint. I don't know to which conclusions we come...
>>>
>>> For me i want to add a +1 for it.
>>
>> I think to remember we explicitly decided not to add this feature,
>> somewhere along the line of "different applications have different
>> needs in this regards, and it is easy to add yourself".
>>
>> Not sure anymore though.
>>
>> You suggestion apearts to be reasonable "safe" to add though. Thinking
>> about it now, I'd not be against it.
>>
>> BTW, I'm about to work on grokcore.view and grokcore.viewlet soon
>> anyway for content providers. I could try to include this suggestion
>> too.
>
>   Honestly I use it at few places, and my customer needs it as well (on
>   plain viewlets).
>
>   An available method on a Viewlet and check it in the filter of the
>   ViewletManager would be great.
>
>   +1 from my part, and +1 from the part of my customer so that makes
>   +2, and it is justified.

Checkin on the grokcore.viewlet trunk. I think the change is backwards
compatible. If you guys agree, I could create a release quickly.

regards, jw


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Christian Klinger
Hi JW,

i am ok with the change. It's fine not to use the filter method of the
BaseClass from ViewletManagerBase right? We lost then the filter for
canAccess.

So i am +1 for the change and releasing ;)

Christian


> On 6/15/11 14:44 , Sylvain Viollon wrote:
>> On Wed, 15 Jun 2011 13:10:20 +0200
>> Jan-Wijbrand Kolman<[hidden email]>  wrote:
>>> On 6/15/11 08:08 , Christian Klinger wrote:
>>>> i think there were some discussions lately about this topic on a
>>>> sprint. I don't know to which conclusions we come...
>>>>
>>>> For me i want to add a +1 for it.
>>>
>>> I think to remember we explicitly decided not to add this feature,
>>> somewhere along the line of "different applications have different
>>> needs in this regards, and it is easy to add yourself".
>>>
>>> Not sure anymore though.
>>>
>>> You suggestion apearts to be reasonable "safe" to add though. Thinking
>>> about it now, I'd not be against it.
>>>
>>> BTW, I'm about to work on grokcore.view and grokcore.viewlet soon
>>> anyway for content providers. I could try to include this suggestion
>>> too.
>>
>>    Honestly I use it at few places, and my customer needs it as well (on
>>    plain viewlets).
>>
>>    An available method on a Viewlet and check it in the filter of the
>>    ViewletManager would be great.
>>
>>    +1 from my part, and +1 from the part of my customer so that makes
>>    +2, and it is justified.
>
> Checkin on the grokcore.viewlet trunk. I think the change is backwards
> compatible. If you guys agree, I could create a release quickly.
>
> regards, jw


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Jan-Wijbrand Kolman-3
On 6/27/11 17:01 , Christian Klinger wrote:
> i am ok with the change. It's fine not to use the filter method of the
> BaseClass from ViewletManagerBase right? We lost then the filter for
> canAccess.

The ViewletManagerBase's update() does a lot of things, including
filtering (by default on canAccess indeed), sorting and calling the
viewlet update() methods. So I think it is the best place to check the
availability only after all of that has happened. Hence the override of
update() in grokcore.viewlet's ViewletManager component.

> So i am +1 for the change and releasing ;)

Cool. Will do asap.

regards, jw

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Jan-Wijbrand Kolman-3
On 6/28/11 09:08 , Jan-Wijbrand Kolman wrote:

> On 6/27/11 17:01 , Christian Klinger wrote:
>> i am ok with the change. It's fine not to use the filter method of the
>> BaseClass from ViewletManagerBase right? We lost then the filter for
>> canAccess.
>
> The ViewletManagerBase's update() does a lot of things, including
> filtering (by default on canAccess indeed), sorting and calling the
> viewlet update() methods. So I think it is the best place to check the
> availability only after all of that has happened. Hence the override of
> update() in grokcore.viewlet's ViewletManager component.
>
>> So i am +1 for the change and releasing ;)
>
> Cool. Will do asap.

released grokcore.viewlet 1.9.
regards, jw

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Viewlets: Check for availability

Christian Klinger
Hi JW,

perfect, thanks for your work.

Christian

> On 6/28/11 09:08 , Jan-Wijbrand Kolman wrote:
>> On 6/27/11 17:01 , Christian Klinger wrote:
>>> i am ok with the change. It's fine not to use the filter method of the
>>> BaseClass from ViewletManagerBase right? We lost then the filter for
>>> canAccess.
>>
>> The ViewletManagerBase's update() does a lot of things, including
>> filtering (by default on canAccess indeed), sorting and calling the
>> viewlet update() methods. So I think it is the best place to check the
>> availability only after all of that has happened. Hence the override of
>> update() in grokcore.viewlet's ViewletManager component.
>>
>>> So i am +1 for the change and releasing ;)
>>
>> Cool. Will do asap.
>
> released grokcore.viewlet 1.9.
> regards, jw


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev