[Cubicweb] WFHistoryVComponent show/hide

Carlos Balderas carlos.balderas at gmail.com
Tue Nov 29 07:00:54 CET 2011


Hi List!

I am trying to hide the workflow history component in views for anonymous
users and I thought unregistering the component "WFHistoryVComponent" could
be the way to go in this case. e.i.

from cubicweb.web.views.workflow import WFHistoryVComponent

MyView(primary.PrimaryView):

  def call(self):
      if self._cw.user.is_anonymous():
          self._cw.vreg['ctxcomponents'].unregister(WFHistoryVComponent)
      else:
           # this will fail if the component is already registered!!
           self._cw.vreg['ctxcomponents'].register(WFHistoryVComponent)

In this case I supposed I need to register again the components for logged
users, so they can see it again, but I am not sure that playing around with
register and unregister methods is the correct thing to do in this case.

The other option I think could be to overwrite the method
"content_navigation_components" where all the components of the view are
read and sent to render, then make the proper validation when the user is
anonymous to avoid displaying the WFHistoryVComponent.

Do you think that one of those options are correct to get the right
solution of my case?

Thank you very much.
Best Regards
Carlos Balderas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20111129/ae7eb118/attachment-0185.html>


More information about the Cubicweb mailing list