[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - fssync.py:1.1.2.1
Guido van Rossum
guido@python.org
Thu, 1 May 2003 16:13:20 -0400
Update of /cvs-repository/Zope3/src/zope/app/interfaces
In directory cvs.zope.org:/tmp/cvs-serv5599/interfaces
Added Files:
Tag: fssync-branch
fssync.py
Log Message:
First rough and tumble conversion of filesystem synchronization.
Don't expect this to work, but it does implement.
=== Added File Zope3/src/zope/app/interfaces/fssync.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.
#
##############################################################################
"""Interfaces for filesystem synchronization.
$Id: fssync.py,v 1.1.2.1 2003/05/01 20:13:19 gvanrossum Exp $
"""
from zope.component.interfaces import IView
from zope.interface import Interface
class IObjectEntry(Interface):
"""File-system object representation."""
def extra():
"""Return extra data for the entry.
The data are returned as a mapping object that allows *both*
data retrieval and setting. The mapping is from names to
objects that will be serialized to or from the file system.
"""
def typeIdentifier():
"""Return a dotted name that identifies the object type.
This is typically a dotted class name.
This is used when synchronizing from the file system to the
database to decide whether the existing object and the new
object are of the same type.
"""
def factory():
"""Return the dotted name of a factory to recreate an empty entry.
The factory will be called with no arguments. It is usually
the dotted name of the object class.
"""
class IObjectFile(IObjectEntry):
"""File-system object representation for file-like objects."""
def getBody():
"""Return the file body."""
def setBody(body):
"""Change the file body."""
class IObjectDirectory(IObjectEntry):
"""File-system object representation for directory-like objects."""
def contents():
"""Return the contents.
A sequence of name, value object are returned. The value in each
pair will be syncronized.
"""
class IContentDirectory(IObjectDirectory):
"""Marker interface for synchronization of content containers.
Any container type object should implement this interface
verifying if the objects are of container types.
"""
class IFSSyncService(Interface):
"""Lookup file-system representation adapters."""
def getSynchronizer(object):
"""Return an object that implements IObjectEntry for the argument.
The return value may be:
- An IDirectoryEntry adapter for the object is returned if the
object is represented as a directory on the file system.
- An IFileEntry adapter for the object is returned if the
object is represented as a file on the file system.
or
- Default, if no synchronizser has been registered.
"""
class IGlobalFSSyncService(IFSSyncService):
"""Global registry for file-system representation adapters."""
def provideSynchronizer(class_, factory):
"""Register a synchronizer.
A factory for a Synchronization Adapter is provided to create
synchronizers for instances of the class.
"""
class IFSAddView(IView):
"""Add objects to ZODB from file system.
Implementation of this view helps in creating
file system representation for zope objects.
"""
def create(fspath=None):
"""Create file system representation for zope objects."""