[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/FSSync - FSRegistry.py:1.1.2.1
Naveen P
pnaveen@zeomega.com
Fri, 11 Oct 2002 08:30:50 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/FSSync
In directory cvs.zope.org:/tmp/cvs-serv32465
Added Files:
Tag: FileSystemSync-branch
FSRegistry.py
Log Message:
FSRegistry Created by naveen
=== Added File Zope3/lib/python/Zope/App/FSSync/FSRegistry.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.
#
##############################################################################
"""
$Id: FSRegistry.py,v 1.1.2.1 2002/10/11 12:30:49 pnaveen Exp $
"""
from IGlobalFSSyncService import IGlobalFSSyncService
from Zope.Exceptions import DuplicationError
class FSRegistry:
"""Regsitory Wrapper class - It is Maping from Class -> Serializer Factory Method
"""
__implements__ = IGlobalFSSyncService
def __init__(self):
self._class_factory_reg = {}
def querySynchronizer(self, object):
"""Return factory method for a given class.
The factory is returned of the object if None of the
Factory method is present return None
"""
factory = self._class_factory_reg.get(object.__class__)
if factory is not None:
return factory(object)
return None
def provideSynchronizer(self,class_, factory):
"""sets class_,factory into the dictionary
"""
if class_ in self._class_factory_reg:
raise DuplicationError
else:
self._class_factory_reg[class_] = factory