I'm trying to setup a way to change skin and language settings on the fly,
based on URL traversal.

I've got it all setup as a python script and access rule, but it ain't
working quite right.

Notably, the default view for the object doesn't "kick in", I have to do it

And I get some page telling me that there is no admin user setup and so on,
which isn't true.

So for instance I have a CMF root at /site/atlas ... This works fine.  The
view is "root_view" (A FS based PT in the skins).

If I do /site/atlas/en or /site/atlas/fr, I get something entirely

If I do /site/atlas/en/root_view or /site/atlas/fr/root_view, then I'm back
in business.

I'm guessing this has something to do with when the access rule actually
gets called and so on (too early? Too late?).

But if not an access rule, where else could I safely put this code?:

request = context.REQUEST

stack = request['TraversalRequestNameStack']

if stack and stack[-1] in ['en','fr']:
    lang = stack.pop()
    virtual_url_parts = request.get('VIRTUAL_URL_PARTS', None)
    # Rewrite the path so all links will have the language path entry
    if virtual_url_parts and len(virtual_url_parts) > 2:
        base_parts = virtual_url_parts[1]
        base_parts = base_parts.split('/')
        request.setVirtualRoot(base_parts + request.steps + [lang])
        request.setVirtualRoot(request.steps + [lang])
    context.changeSkin('atlas-' + lang)
    request.set('HTTP_ACCEPT_LANGUAGE', lang)

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to