| 1 |
from Products.CMFCore.DirectoryView import registerDirectory |
|---|
| 2 |
from App.version_txt import getZopeVersion |
|---|
| 3 |
from Products.CMFCore.utils import ToolInit |
|---|
| 4 |
import logging |
|---|
| 5 |
from AccessControl import allow_module, ModuleSecurityInfo |
|---|
| 6 |
import config |
|---|
| 7 |
import CaptchaTool |
|---|
| 8 |
|
|---|
| 9 |
allow_module('Products.qPloneCaptchas.utils') |
|---|
| 10 |
allow_module('Products.qPloneCaptchas.config') |
|---|
| 11 |
registerDirectory('skins', config.GLOBALS) |
|---|
| 12 |
|
|---|
| 13 |
tools = (CaptchaTool.CaptchaTool, ) |
|---|
| 14 |
def initialize(context): |
|---|
| 15 |
ToolInit(meta_type="CaptchaTool", |
|---|
| 16 |
tools=tools, |
|---|
| 17 |
product_name=config.PRODUCT_NAME, |
|---|
| 18 |
icon=config.TOOL_ICON,).initialize(context) |
|---|
| 19 |
|
|---|
| 20 |
def MessageFactory(projectname): |
|---|
| 21 |
"Get a i18n message factory" |
|---|
| 22 |
vmajor, vminor, vmicro, vstatus, vrelease = getZopeVersion() |
|---|
| 23 |
MessageFactory = lambda : "no message factory found" |
|---|
| 24 |
if (vmajor > 2) or ((vmajor, vminor) == (2,9)): |
|---|
| 25 |
from zope.i18nmessageid import MessageFactory |
|---|
| 26 |
elif (vmajor, vminor) == (2,8): |
|---|
| 27 |
from zope.i18nmessageid import MessageIDFactory as MessageFactory |
|---|
| 28 |
else: |
|---|
| 29 |
try: |
|---|
| 30 |
from Products.PlacelessTranslationService.MessageID import MessageIDFactory as MessageFactory |
|---|
| 31 |
except: |
|---|
| 32 |
logging.info("[qPloneCaptchas] No i18n Message Factory found -> cannot provide translations!") |
|---|
| 33 |
return MessageFactory(projectname.lower()) |
|---|
| 34 |
|
|---|
| 35 |
ProductMessageFactory = MessageFactory('%s' % config.PRODUCT_NAME) |
|---|
| 36 |
ModuleSecurityInfo('Products.%s' % config.PRODUCT_NAME).declarePublic("ProductMessageFactory") |
|---|