-----BEGIN PGP SIGNED MESSAGE-----
Alexander Limi wrote:
> Can anybody from the CMF team give some guidance to Laurence here?
> -- Alexander
> On Fri, 28 Oct 2005 06:31:42 -0700, Laurence Rowe <[EMAIL PROTECTED]> wrote:
>> In Plone ResourceRegistries (1.1 branch) I need to get the current
>> skin name so that the resource (a css or js file) is fetched from the
>> correct skin.
I don't understand the use case, but I will take your word for it.
Normally, you would look up the component CSS / JS files using the same
skin settings as the "base" page.
> Unfortunately it seems that there is no easy way to get
>> the current skin name (when it is not set by a cookie in the
>> request). I can work around this like follows, but it's a bit ugly:
>> security.declareProtected(permissions.View, 'getCurrentSkinName')
>> def getCurrentSkinName(self):
>> """Returns the id of the current skin.
>> Ugh, there really should be a better way of doing this. This is
>> depending on internals in CMFCore and should be added there.
>> skintool = getToolByName(self, 'portal_skins')
>> default_skin_name = skintool.getDefaultSkin()
>> tid = get_ident()
>> if SKINDATA.has_key(tid):
>> skinobj, ignore, resolve = SKINDATA.get(tid)
>> current_skin_path = skinobj.getPhysicalPath()
>> # Perhaps test against default skin first?
>> skinnames = skintool.getSkinSelections()
>> # loop through skin names looking for a match
>> for name in skinnames:
>> skin = skintool.getSkinByName(name)
>> path = skin.getPhysicalPath()
>> if current_skin_path == path:
>> return name
>> return default_skin_name
>> Would it be reasonable to make
>> Skinnable.SkinnableObjectManager.changeSkin set the skin request var
>> name after changing the skin? Such as:
I think it would be better to add the skin name to the tuple cached in
the module global ('SKINDATA[tid]'). This change would involve
overriding or monkeypatching both 'changeSkin' and '__getattr__' in the
Skinnable class, and then add a method, 'getCurrentSkinName', which
I would be happy to merge a patch for this into the 1.5 branch and the
trunk, given tests which show correct behavior.
Tres Seaver +1 202-558-7113 [EMAIL PROTECTED]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests