|
Problem overriding IUserPreferredLanguages: msg#00102web.zope.z3base.five
Hello, First of all, note that is my very first forry into Five/Zope 3 ... (Though I know 2.7 well!) I'm using 2.9.2 right now. I'm trying to use my own system of determining the language to use, based on the URL. Using Five/i18n.py and http://codespeak.net/z3/five/i18n.html, I've created a very small product to start with: i18n.py: from zope.interface import implements from zope.i18n.interfaces import IUserPreferredLanguages class PathLanguages(object): implements(IUserPreferredLanguages) def __init__(self, context): self.context = context def getPreferredLanguages(self): request = self.context stack = request['TraversalRequestNameStack'] if stack and len(stack) > 0 and stack[-1] in ['en', 'fr']: # A language entry is in the path lang = stack.pop(-1) # Rewrite the path so all links will have the language path entry base_parts = request['VIRTUAL_URL_PARTS'][1] request.setVirtualRoot([base_parts] + [lang]) return [lang] else: return ['en'] And overrides.zcml: <configure xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:five="http://namespaces.zope.org/five"> <adapter for="zope.publisher.interfaces.http.IHTTPRequest" provides="zope.i18n.interfaces.IUserPreferredLanguages" factory=".i18n.PathLanguages" /> </configure> But this seems to do absolutely nothing :( I've tried adding raises or prints in the code and so on, but as best I can tell, it never gets called. The __init__ for the Product is empty. Basically, it's my first Five product, and it's only supposed to set the language, but I can't even get it to do that. Anyone care to point me in the right direction? Thanks in advance for the help ... Jean-François Doyon Internet Service Development and Systems Support / Spécialiste de dèveloppements internet et soutien technique Canada Centre for Remote Sensing/Centre Canadien de télédétection Natural Resources Canada/Ressources Naturelles Canada http://atlas.gc.ca Tel./Tél.: (613) 992-4902 Fax: (613) 947-2410 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: SVN: Products.Five/branches/regebro-traversal_refactor/ Removed last rests of Traversable usage. Deprecated Traversable and FiveTraversable.: 00102, Lennart Regebro |
|---|---|
| Next by Date: | How the hell do I debug assert _context.stack[-1].context is context: 00102, Martin Aspeli |
| Previous by Thread: | Re: SVN: Products.Five/branches/regebro-traversal_refactor/ Removed last rests of Traversable usage. Deprecated Traversable and FiveTraversable.i: 00102, Philipp von Weitershausen |
| Next by Thread: | How the hell do I debug assert _context.stack[-1].context is context: 00102, Martin Aspeli |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |