[Cubicweb] cubicweb.web.views.basetemplates.HTMLPageHeader

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Jul 6 17:44:14 CEST 2009


On 06 juillet 17:03, Aurélien Campéas wrote:
> On Mon, Jul 06, 2009 at 09:53:52AM -0500, Carlos Balderas wrote:
> > Salut,
> 
> Salut,
> 
> > 
> > I am trying to modify the HTMLPageHeader of the main template but I am getting
> > an error:
> > 
> > (cubicweb.registry) ERROR: select ambiguity, args:
> > (<cubicweb.etwist.request.CubicWebTwistedRequestAdapter object at 0xb3e3d4c>,
> > None)
> > kwargs: ['w', 'view'] ["<class
> > 'cubicweb.web.views.basetemplates.HTMLPageHeader'>", "<class
> > 'cubes.alltests.views.maintemplates.MyHTMLPageHeader'>"]
> 
> Yes, cubicweb does not know how to choose between the two
> implementations ... So you have to tell it. At the end of the module
> that redefines your html header, add the following :
> 
> def registration_callback(vreg):
>     vreg.register_and_replace(MyHTMLPageHeader, HTMLPageHeader)
> 
> 
> Having this function there immediately tells cw not to automatically register
> stuff. Instead it executes it (with the vregistry as argument).

another side effect of adding this is that if you've other classes in the same
module, they won't be registered anymore. The usual trick in this case is:

  def registration_callback(vreg):
     # register everything in this module byt the MyHTMLPageHeader class
     vreg.register_all(globals().values(), __name__, (MyHTMLPageHeader,)
     # register MyHTMLPageHeader by replacing standard HTMLPageHeader
     vreg.register_and_replace(MyHTMLPageHeader, HTMLPageHeader)

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
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