[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - mapper.py:1.1.2.1 apeconf.xml:1.1.2.3 fsmapper.py:1.2.2.4 sqlmapper.py:1.5.2.3
Shane Hathaway
shane@zope.com
Tue, 8 Jul 2003 22:10:52 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv7805/lib/apelib/zope2
Modified Files:
Tag: ape-newconf-branch
apeconf.xml fsmapper.py sqlmapper.py
Added Files:
Tag: ape-newconf-branch
mapper.py
Log Message:
Consolidated Zope 2 mapper configuration in a single module.
Also made Ape look for apeconf.xml files in all products, renamed the
root Zope 2 mapper to simply "root", and made variants extend the
default configuration implicitly.
=== Added File Products/Ape/lib/apelib/zope2/mapper.py ===
##############################################################################
#
# Copyright (c) 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.
#
##############################################################################
"""Zope 2 mapper creation
$Id: mapper.py,v 1.1.2.1 2003/07/09 02:10:46 shane Exp $
"""
import os
import Products
from apelib.config.apeconf import wireMapper
def createMapper(vname, search_products=0):
"""Builds a mapper from apeconf.xml files.
"""
here = os.path.dirname(__file__)
filenames = [os.path.join(here, 'apeconf.xml')]
if search_products:
seen = {} # Product name -> 1
for path in Products.__path__:
for name in os.listdir(path):
if not seen.has_key(name):
seen[name] = 1
fn = os.path.join(path, name, 'apeconf.xml')
if os.path.exists(fn):
filenames.append(fn)
return wireMapper(filenames, vname, 'root')
def createFSMapper(basepath, **kw):
"""Filesystem mapper factory.
Returns (mapper, { name -> connection })
Usage in database configuration file:
factory=apelib.zope2.mapper.createFSMapper
basepath=/var/zope/data
"""
from apelib.fs.connection import FSConnection
mapper = createMapper('filesystem', search_products=1)
conn = FSConnection(basepath, **kw)
return mapper, {'fs': conn}
def createSQLMapper(module_name, **kw):
"""SQL mapper factory.
Returns (mapper, { name -> connection })
Usage in database configuration file:
factory=apelib.zope2.mapper.createSQLMapper
module_name=psycopg
params=
kwparams=
table_prefix=zodb
"""
from apelib.sql.dbapi import DBAPIConnector
mapper = createMapper('sql', search_products=1)
conn = DBAPIConnector(module_name, **kw)
return mapper, {'db': conn}
=== Products/Ape/lib/apelib/zope2/apeconf.xml 1.1.2.2 => 1.1.2.3 ===
--- Products/Ape/lib/apelib/zope2/apeconf.xml:1.1.2.2 Mon Jul 7 23:58:15 2003
+++ Products/Ape/lib/apelib/zope2/apeconf.xml Tue Jul 8 22:10:46 2003
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
+<!-- Basic Zope 2 configuration for Ape. -->
+
<configuration>
<!-- Root mapper -->
-<mapper name="zope2" class="Persistence.PersistentMapping">
+<mapper name="root" class="Persistence.PersistentMapping">
<serializer name="root_items"
factory="apelib.zodb3.serializers.BasicPersistentMapping" />
<serializer name="roll_call" factory="apelib.zodb3.serializers.RollCall" />
@@ -93,33 +95,33 @@
<!-- Mappers for particular content types -->
-<mapper name="OFS.Folder.Folder" extends="base_p" parent="zope2">
+<mapper name="OFS.Folder.Folder" extends="base_p" parent="root">
<serializer name="items" use="folder_items" />
<gateway name="items" use="dir_items" />
<use-for fallback="directory" />
</mapper>
-<mapper name="OFS.Image.File" extends="base_p" parent="zope2">
+<mapper name="OFS.Image.File" extends="base_p" parent="root">
<serializer name="data" factory="apelib.zope2.ofsserial.FilePData" />
<gateway name="data" use="binary_data" />
<use-for fallback="file" />
<option name="content_type_attr" value="content_type" />
</mapper>
-<mapper name="OFS.Image.Image" extends="OFS.Image.File" parent="zope2">
+<mapper name="OFS.Image.Image" extends="OFS.Image.File" parent="root">
<use-for extensions=".gif .jpg .jpeg .png" />
<option name="content_type_attr" value="content_type" />
</mapper>
<mapper name="Products.PageTemplates.ZopePageTemplate.ZopePageTemplate"
- extends="base_p" parent="zope2">
+ extends="base_p" parent="root">
<serializer name="text" factory="apelib.core.serializers.StringDataAttribute"
param="_text" />
<gateway name="text" use="text_data" />
<use-for extensions=".html .htm .zpt .pt" />
</mapper>
-<mapper name="OFS.DTMLMethod.DTMLMethod" extends="base" parent="zope2">
+<mapper name="OFS.DTMLMethod.DTMLMethod" extends="base" parent="root">
<serializer name="text" factory="apelib.core.serializers.StringDataAttribute"
param="raw" />
<gateway name="text" use="text_data" />
@@ -127,11 +129,11 @@
</mapper>
<mapper name="OFS.DTMLMethod.DTMLDocument"
- extends="OFS.DTMLMethod.DTMLMethod" parent="zope2">
+ extends="OFS.DTMLMethod.DTMLMethod" parent="root">
<serializer name="properties" enabled="false" />
</mapper>
-<mapper name="Products.ZSQLMethods.SQL.SQL" extends="base" parent="zope2">
+<mapper name="Products.ZSQLMethods.SQL.SQL" extends="base" parent="root">
<serializer name="properties"
factory="apelib.zope2.scripts.ZSQLMethodPropertiesSerializer" />
<serializer name="text"
@@ -148,14 +150,14 @@
</mapper>
<mapper name="Products.PythonScripts.PythonScript.PythonScript"
- extends="base" parent="zope2">
+ extends="base" parent="root">
<serializer name="body"
factory="apelib.zope2.scripts.PythonScriptSerializer" />
<gateway name="body" use="text_data" />
<use-for extensions=".py" />
</mapper>
-<mapper name="AccessControl.User.UserFolder" extends="base" parent="zope2">
+<mapper name="AccessControl.User.UserFolder" extends="base" parent="root">
<serializer name="data"
factory="apelib.zope2.security.UserFolderSerializer" />
<variant name="filesystem">
@@ -166,20 +168,20 @@
</variant>
</mapper>
-<mapper name="anyfolder" class="any" extends="base_p" parent="zope2">
+<mapper name="anyfolder" class="any" extends="base_p" parent="root">
<serializer name="properties" use="optional_properties" />
<serializer name="items" use="folder_items" />
<gateway name="items" use="dir_items" />
<use-for fallback="folderish_object" />
</mapper>
-<mapper name="anyfile" class="any" extends="base_p" parent="zope2">
+<mapper name="anyfile" class="any" extends="base_p" parent="root">
<serializer name="properties" use="optional_properties" />
<gateway name="remainder" use="binary_data" />
<use-for fallback="fileish_object" />
</mapper>
-<mapper name="OFS.Application.Application" extends="base_p" parent="zope2">
+<mapper name="OFS.Application.Application" extends="base_p" parent="root">
<serializer name="items" use="folder_items" />
<serializer name="id" enabled="false" />
<gateway name="id" enabled="false" />
@@ -193,7 +195,8 @@
</mapper>
<mapper name="anyfile">
- <!-- Workaround -->
+ <!-- Workaround for objects that don't work with the anyfolder mapper,
+ but do fine with anyfile. -->
<use-for class="Products.CMFCore.SkinsTool.SkinsTool" />
<use-for class="App.ApplicationManager.ApplicationManager" />
</mapper>
=== Products/Ape/lib/apelib/zope2/fsmapper.py 1.2.2.3 => 1.2.2.4 ===
--- Products/Ape/lib/apelib/zope2/fsmapper.py:1.2.2.3 Mon Jul 7 23:58:15 2003
+++ Products/Ape/lib/apelib/zope2/fsmapper.py Tue Jul 8 22:10:46 2003
@@ -11,29 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""A basic mapping from Zope 2 objects to the filesystem.
+"""Deprecated alias.
$Id$
"""
+from mapper import createFSMapper as createMapper
-import os
-from apelib.config.apeconf import makeComponentSystem
-from apelib.fs import classification
-
-
-def createAbstractMapper():
- here = os.path.dirname(__file__)
- filenames = (os.path.join(here, 'apeconf.xml'),)
- vnames = ('filesystem', '')
- cs = makeComponentSystem(filenames, vnames)
- m = cs.get('mapper', 'zope2')
- m.checkConfiguration(path='zope2')
- return m
-
-
-def createMapper(basepath, **kw):
- """Returns (mapper, { name -> connection })"""
- mapper = createAbstractMapper()
- conn = connection.FSConnection(basepath, **kw)
- return mapper, {'fs': conn}
-
+from zLOG import LOG, WARNING
+LOG('Ape', WARNING, 'apelib.zope2.fsmapper.createMapper is deprecated. '
+ 'Please use apelib.zope2.mapper.createFSMapper instead.')
=== Products/Ape/lib/apelib/zope2/sqlmapper.py 1.5.2.2 => 1.5.2.3 ===
--- Products/Ape/lib/apelib/zope2/sqlmapper.py:1.5.2.2 Mon Jul 7 23:58:15 2003
+++ Products/Ape/lib/apelib/zope2/sqlmapper.py Tue Jul 8 22:10:46 2003
@@ -11,37 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""A basic mapping from Zope 2 objects to a SQL database.
+"""Deprecated alias.
$Id$
"""
+from mapper import createSQLMapper as createMapper
-import os
-
-from apelib.sql import dbapi
-from apelib.config.apeconf import makeComponentSystem
-
-def createAbstractMapper():
- here = os.path.dirname(__file__)
- filenames = (os.path.join(here, 'apeconf.xml'),)
- vnames = ('sql', '')
- cs = makeComponentSystem(filenames, vnames)
- m = cs.get('mapper', 'zope2')
- m.checkConfiguration(path='zope2')
- return m
-
-
-def createMapper(module_name, **kw):
- """Object mapper factory.
-
- Usage in database configuration file:
- factory=apelib.zope2.sqlmapper.createDBAPIMapper
- module_name=psycopg
- params=
- kwparams=
- table_prefix=zodb
- """
- mapper = createAbstractMapper()
- conn = dbapi.DBAPIConnector(module_name, **kw)
- return mapper, {'db': conn}
-
+from zLOG import LOG, WARNING
+LOG('Ape', WARNING, 'apelib.zope2.sqlmapper.createMapper is deprecated. '
+ 'Please use apelib.zope2.mapper.createSQLMapper instead.')