Silva and nested local sites
Andrew Altepeter <[email protected]> Wed, 17 Aug 2011 12:15:33 -0500
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Message-ID | <CAEssFdDZxWAnrRXjOS_erjJoa4B-4MX7HZvn_+-XdDfaagdaEw@mail.gmail.com> |
--===============1016874983120207469== Content-Type: multipart/alternative; boundary=000e0cd3a4d6de0f2904aab6a4f9 --000e0cd3a4d6de0f2904aab6a4f9 Content-Type: text/plain; charset=ISO-8859-1 Greetings Devs, Per sylvain's suggestion from months ago, I've implemented a local utility for one of our extensions. (we used to get it by acquisition using an id/naming convention). Sylvain suggested this be converted to a local utility / silva service. Now the nearest object can be found using getUtility(ISpecialServiceInterface, context=content). This is working great for this purpose. In order to add this as a service, the container first needs to be converted to a localsite. This is working fine, however once a container is a local site, I've noticed an odd side-effect with the breadcrumbs (both in the SMI and in our public layout): Let's say that within a fresh Silva root, we have a container which is now a local site, e.g. /silva/localsite_container. When the edit tab for this container is accessed directly, supplying no vhost information, e.g. localhost:8080/silva/localsite_container/edit, the breadcrumb _starts_ at 'localsite_container'. When the edit tab is accessed with vhost info, e.g. localhost:8080/VirtualHostBase/http/ www.somewhere.edu:80/silva/VirtualHostRoot/localsite_container/edit, the complete breadcrumb is displayed. Digging in to this a bit, I found that the breadcrumb code (in silva.core.views.absoluteurl.AbsoluteURL.breadcrumbs) gets an IVirtualSite adapter, which is here: silva.core.views.site.VirtualSite, and calls it's get_root function. When vhost information is supplied, VirtualSite finds the virtual host root and returns that. However, when vhost info is absent, VirtualSite.get_root() calls get_silva_root() which in turn returns zope.site.hooks.getSite(). This apparently returns the nearest local site, or the global site if none is defined. I think this is where the problem is occurring. There is an 'XXX' comment in get_silva_root: # XXX Check for nested localsites in Silva I think this situation could be described as a 'nested localsite', and this code is in fact not returning the Silva Root (as it's name implies) but instead is returning the nearest localsite. Any thoughts or comments on why this is the case? Looking in Silva 3.0, this has not been addressed yet. Since the method is supposed to return the Silva Root, can't it just call self.context.get_silva_root() (finding the root by acquisition)? peace, Andy --000e0cd3a4d6de0f2904aab6a4f9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Greetings Devs,<div><br></div><div>Per sylvain's suggestion from months= ago, I've implemented a local utility for one of our extensions. =A0(w= e used to get it by acquisition using an id/naming convention). =A0Sylvain = suggested this be converted to a local utility / silva service. =A0Now the = nearest object can be found using getUtility(ISpecialServiceInterface, cont= ext=3Dcontent). =A0This is working great for this purpose.</div> <div><br></div><div>In order to add this as a service, the container first = needs to be converted to a localsite. =A0This is working fine, however once= a container is a local site, I've noticed an odd side-effect with the = breadcrumbs (both in the SMI and in our public layout):</div> <div><br></div><div>Let's say that within a fresh Silva root, we have a= container which is now a local site, e.g. /silva/localsite_container.</div= ><div><br></div><div>When the edit tab for this container is accessed direc= tly, supplying no vhost information, e.g. localhost:8080/silva/localsite_co= ntainer/edit, =A0the breadcrumb _starts_ at 'localsite_container'.<= /div> <div><br></div><div>When the edit tab is accessed with vhost info, e.g. loc= alhost:8080/VirtualHostBase/http/<a href=3D"http://www.somewhere.edu:80/sil= va/VirtualHostRoot/localsite_container/edit">www.somewhere.edu:80/silva/Vir= tualHostRoot/localsite_container/edit</a>, the complete breadcrumb is displ= ayed.</div> <div><br></div><div>Digging in to this a bit, I found that the breadcrumb c= ode (in silva.core.views.absoluteurl.AbsoluteURL.breadcrumbs) gets an IVirt= ualSite adapter, which is here: silva.core.views.site.VirtualSite, and call= s it's get_root function.</div> <div><br></div><div>When vhost information is supplied, VirtualSite finds t= he virtual host root and returns that. =A0However, when vhost info is absen= t, VirtualSite.get_root() calls get_silva_root() which in turn returns zope= .site.hooks.getSite(). =A0This=A0apparently returns the nearest local site,= or the global site if none is defined. =A0I think this is where the proble= m is occurring.</div> <div><br></div><div>There is an 'XXX' comment in get_silva_root: = =A0# XXX Check for nested localsites in Silva</div><div><br></div><div>I th= ink this situation could be described as a 'nested localsite', and = this code is in fact not returning the Silva Root (as it's name implies= ) but instead is returning the nearest localsite.</div> <div><br></div><div>Any thoughts or comments on why this is the case? =A0Lo= oking in Silva 3.0, this has not been addressed yet. =A0Since the method is= supposed to return the Silva Root, can't it just call self.context.get= _silva_root() (finding the root by acquisition)?</div> <div><br></div><div>peace,</div><div>Andy</div> --000e0cd3a4d6de0f2904aab6a4f9-- --===============1016874983120207469== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ silva-dev mailing list silva-dev-IAPFreCvJWM6s/[email protected] https://lists.infrae.com/mailman/listinfo/silva-dev --===============1016874983120207469==--