[Zope3-checkins] CVS: Zope3/lib/python/Zope/App - i18n-metaConfigure.py:1.1 event-metaConfigure.py:1.1 i18n-meta.zcml:1.3 event-meta.zcml:1.3
Gary Poster
gary@zope.com
Wed, 18 Dec 2002 14:27:04 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App
In directory cvs.zope.org:/tmp/cvs-serv30456
Modified Files:
i18n-meta.zcml event-meta.zcml
Added Files:
i18n-metaConfigure.py event-metaConfigure.py
Log Message:
First half of moving event and i18n metaConfigure files to App
=== Added File Zope3/lib/python/Zope/App/i18n-metaConfigure.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
This module handles the :startup directives.
$Id: i18n-metaConfigure.py,v 1.1 2002/12/18 19:27:02 poster Exp $
"""
import os
from Zope.Configuration.Action import Action
from Zope.I18n.GettextMessageCatalog import GettextMessageCatalog
from Zope.I18n.GlobalTranslationService import translationService
def registerTranslations(_context, directory):
""" """
actions = []
path = _context.path(directory)
path = os.path.normpath(path)
for language in os.listdir(path):
lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
if os.path.isdir(lc_messages_path):
for domain_file in os.listdir(lc_messages_path):
if domain_file.endswith('.mo'):
domain_path = os.path.join(lc_messages_path, domain_file)
domain = domain_file[:-3]
catalog = GettextMessageCatalog(language, domain,
domain_path)
actions.append(Action(
discriminator = catalog.getIdentifier(),
callable = translationService.addCatalog,
args = (catalog,) ))
return actions
def defaultLanguages(_context, languages):
langs = [L.strip() for L in languages.split()]
return [Action(discriminator = ('gts', languages),
callable = translationService.setLanguageFallbacks,
args = (langs,))]
=== Added File Zope3/lib/python/Zope/App/event-metaConfigure.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Revision information:
$Id: event-metaConfigure.py,v 1.1 2002/12/18 19:27:02 poster Exp $
"""
from Zope.Configuration.Action import Action
from Zope.Event import globalSubscribeMany
from Zope.Event.IEvent import IEvent
from Interface import Interface
counter = 0
def subscribe(_context, subscriber, event_types=(IEvent), filter=None):
global counter
counter += 1
subscriber = _context.resolve(subscriber)
event_type_names = event_types
event_types=[]
for event_type_name in event_type_names.split():
event_types.append(_context.resolve(event_type_name))
if filter is not None:
filter = _context.resolve(filter)
return [
Action(
# subscriptions can never conflict
discriminator = ('subscribe', counter),
callable = globalSubscribeMany,
args = (subscriber, event_types, filter)
),
Action(
discriminator = None,
callable = globalSubscribeMany,
args = ('Interfaces', 'provideInterface',
type.__module__+'.'+type.__name__, type)
)
]
=== Zope3/lib/python/Zope/App/i18n-meta.zcml 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/i18n-meta.zcml:1.2 Tue Nov 19 18:25:12 2002
+++ Zope3/lib/python/Zope/App/i18n-meta.zcml Wed Dec 18 14:27:02 2002
@@ -4,11 +4,11 @@
<directive name="registerTranslations"
attributes="directory"
- handler="Zope.I18n.metaConfigure.registerTranslations" />
+ handler=".i18n-metaConfigure.registerTranslations" />
<directive name="defaultLanguages"
attributes="languages"
- handler="Zope.I18n.metaConfigure.defaultLanguages" />
+ handler=".i18n-metaConfigure.defaultLanguages" />
</directives>
</zopeConfigure>
=== Zope3/lib/python/Zope/App/event-meta.zcml 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/event-meta.zcml:1.2 Tue Nov 19 18:25:12 2002
+++ Zope3/lib/python/Zope/App/event-meta.zcml Wed Dec 18 14:27:02 2002
@@ -3,7 +3,7 @@
<directives namespace="http://namespaces.zope.org/event">
<directive name="subscribe" attributes="subscriber event_types filter"
- handler="Zope.Event.metaConfigure.subscribe" />
+ handler=".event-metaConfigure.subscribe" />
</directives>