bugfix : pour obtenir l'url d'un brain, c'est getURL et non absolute_url
[Portfolio.git] / utils.py
1 # -*- coding: utf-8 -*-
2 ############################################################
3 # Copyright © 2008 Benoît PIN <benoit.pin@ensmp.fr> #
4 # Plinn - http://plinn.org #
5 # #
6 # This program is free software; you can redistribute it #
7 # and/or modify it under the terms of the Creative Commons #
8 # "Attribution-Noncommercial 2.0 Generic" #
9 # http://creativecommons.org/licenses/by-nc/2.0/ #
10 ############################################################
11 """ Global utilities for portfolio / photo objects.
12 """
13
14 from AccessControl import ModuleSecurityInfo
15 from zope.i18n import translate as i18ntranslate
16 from zope.i18nmessageid import MessageFactory
17
18 security = ModuleSecurityInfo('Products.Portfolio.utils')
19
20 security.declarePublic('Message')
21 Message = MessageFactory('portfolio')
22
23 security.declarePublic('translate')
24 def translate(message, context):
25 """ Translate i18n message.
26 """
27 if isinstance(message, Exception):
28 try:
29 message = message[0]
30 except (TypeError, IndexError):
31 pass
32 return i18ntranslate(message, domain='portfolio', context=context.REQUEST)