[Cubicweb] About uiprops and postcreate

Stéphane Bugat stephane.bugat at free.fr
Mon Jul 30 16:36:05 CEST 2012


Sylvain, thanx for these explanations.

Indeed, I was looking for making the searchbox totally disappear. Actually I wanted to put it in the header part of the HTML page, not in the left column, but after a few and unsuccessful tries to change its context I realized that there was no other way than hiding it and creating a new one in a specific HTMLPageHeader.main_header() method.
I was pretty sure that from a pure performance point of view, this was not well optimized, so I'm glad you gave me the solution.

If I understood well, to unregister it, I have to use the vreg.unregister() method in registration_callback(vreg), is that it?

Stephane

----- Mail original -----
> De: "Sylvain Thénault" <sylvain.thenault at logilab.fr>
> À: "Stéphane Bugat" <stephane.bugat at free.fr>
> Cc: cubicweb at lists.cubicweb.org
> Envoyé: Lundi 30 Juillet 2012 09:26:54
> Objet: Re: [Cubicweb] About uiprops and postcreate
> 
> On 27 juillet 13:05, Stéphane Bugat wrote:
> > > It's because both are in the ``ctxcomponents`` registry, not the
> > > ``boxes`` one.
> > > 
> > > Please, try :
> > > 
> > >   set_property('ctxcomponents.search_box.visible', u'')
> > >   set_property('ctxcomponents.blog_summary_box.visible', u'')
> > > 
> > 
> > Worked well for 'search_box', thank you Adrien.
> >  
> > 'blog_summary_box' has been renamed in something like
> > 'blog_latest_blogs' (obtained through the source code of HTML
> > page), however in the source of cw-blog I found a ctxcomponent
> > with regid 'blog.latest_blogs'. How does the class id is derived
> > from the __regid__ of the component? Both the following failed:
> > 
> >   set_property('ctxcomponents.blog_latest_blogs.visible', u'')
> >   set_property('ctxcomponents.blog.latest_blogs.visible', u'')
> 
> The DOM id is usually extracted from the __regid__ using the
> cw.uilib.domid function which does:
> 
>   string.replace('.', '_').replace('-', '_')
> 
> But set_property expect a property key. All existing property keys
> are
> defined in a special register, which contains the property
> description
> (type, default, description...). The value to be specified to a
> property
> shall be acceptable according to its type. Last but not least,
> appobjects
> which have a cw_property_defs dictionary, like those derived from
> `CtxComponent` will have those property automatically registered
> using:
> 
>   <__registry__>.<__regid__>.<key>
> 
> for each key in the dictionary. So in your case,
> 'ctxcomponents.blog.latest_blogs.visible' should be the right key,
> provided
> that the relevant appobject is actually registered. And empty string
> should
> be an acceptable value for boolean type, evaluated to false. So
> please send
> us the traceback if this doesn't work.
> 
> That being said, if what you want is to deactivate the box by default
> but
> let users reactivate it using their preferences, fine. However if you
> wish
> to remove it totally from your site, you should rather unregister the
> class than playing with the visible property. Beside the difference
> explained
> above (possible reactivation from user prefs), removing from the
> registry
> has also a performance impact since, when looking for possible boxes,
> the class
> won't ever be evaluated while if deactivated using visible property,
> it'ill
> be considered each time, but eventually not displayed because not
> visible.
> 
> --
> Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse
> (09.54.03.55.76)
> Formations Python, Debian, Méth. Agiles:
> http://www.logilab.fr/formations
> Développement logiciel sur mesure:
>       http://www.logilab.fr/services
> CubicWeb, the semantic web framework:    http://www.cubicweb.org
> 



More information about the Cubicweb mailing list