[Zope3-checkins] CVS: Zope3/src/zope/app/dav - interfaces.py:1.1
adapter.py:1.7 configure.zcml:1.14 metaconfigure.py:1.3
mkcol.py:1.3 propfind.py:1.14 widget.py:1.6
globaldavschemaservice.py:NONE
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Mar 3 12:07:01 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/dav
In directory cvs.zope.org:/tmp/cvs-serv16742/src/zope/app/dav
Modified Files:
adapter.py configure.zcml metaconfigure.py mkcol.py
propfind.py widget.py
Added Files:
interfaces.py
Removed Files:
globaldavschemaservice.py
Log Message:
Changed DAV schemas to be utilities. However, I left the dav:provideInterface
directive in place, since it hides some unnecessary indirections.
=== Added File Zope3/src/zope/app/dav/interfaces.py ===
##############################################################################
#
# Copyright (c) 2004 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.
#
##############################################################################
"""WebDAV-specific interfaces
$Id: interfaces.py,v 1.1 2004/03/03 17:06:30 srichter Exp $
"""
from zope.interface import Interface
from zope.schema import Text
from zope.app.interfaces.form import IWidget
class IDAVNamespace(Interface):
"""Represents a namespace available in WebDAV XML documents.
DAV namespaces and their associated interface are utilities that fullfill
provide this interface
"""
class IDAVCreationDate(Interface):
creationdate = Text(title=u'''Records the time and date the resource\
was created''',
description=u'''\
The creationdate property should be
defined on all DAV compliant
resources. If present, it contains a
timestamp of the moment when the
resource was created (i.e., the moment
it had non- null state).''')
class IDAVDisplayName(Interface):
displayname = Text(title=u'''Provides a name for the resource that\
is suitable for presentation to a\
user''',
description=u'''\
The displayname property should be
defined on all DAV compliant
resources. If present, the property
contains a description of the resource
that is suitable for presentation to a
user.''')
class IDAVSource(Interface):
source = Text(title=u'''The destination of the source link\
identifies the resource that contains\
the unprocessed source of the link\
source''',
description=u'''\
The source of the link (src) is
typically the URI of the output
resource on which the link is defined,
and there is typically only one
destination (dst) of the link, which
is the URI where the unprocessed
source of the resource may be
accessed. When more than one link
destination exists, this specification
asserts no policy on ordering.''')
class IOptionalDAVSchema(IDAVCreationDate, IDAVDisplayName, IDAVSource):
"""DAV properties that SHOULD be present but are not required"""
class IGETDependentDAVSchema(Interface):
"""DAV properties that are dependent on GET support of the resource"""
getcontentlanguage = Text(title=u'''Contains the Content-Language\
header returned by a GET without\
accept headers''',
description=u'''\
The getcontentlanguage property MUST
be defined on any DAV compliant
resource that returns the
Content-Language header on a GET.''')
getcontentlength = Text(title=u'''Contains the Content-Length header\
returned by a GET without accept\
headers''',
description=u'''\
The getcontentlength property MUST be
defined on any DAV compliant resource
that returns the Content-Length header
in response to a GET.''')
getcontenttype = Text(title=u'''Contains the Content-Type header\
returned by a GET without accept\
headers''',
description=u'''\
This getcontenttype property MUST be
defined on any DAV compliant resource
that returns the Content-Type header
in response to a GET.''')
getetag = Text(title=u'''Contains the ETag header returned by a GET\
without accept headers''',
description=u'''\
The getetag property MUST be defined
on any DAV compliant resource that
returns the Etag header.''')
getlastmodified = Text(title=u'''Contains the Last-Modified header\
returned by a GET method without\
accept headers''',
description=u'''\
Note that the last-modified date on a
resource may reflect changes in any
part of the state of the resource, not
necessarily just a change to the
response to the GET method. For
example, a change in a property may
cause the last-modified date to
change. The getlastmodified property
MUST be defined on any DAV compliant
resource that returns the
Last-Modified header in response to a
GET.''')
class IDAV1Schema(IGETDependentDAVSchema):
"""DAV properties required for Level 1 compliance"""
resourcetype = Text(title=u'''Specifies the nature of the resource''',
description=u'''\
The resourcetype property MUST be
defined on all DAV compliant
resources. The default value is
empty.''')
class IDAV2Schema(IDAV1Schema):
"""DAV properties required for Level 2 compliance"""
lockdiscovery = Text(title=u'''Describes the active locks on a\
resource''',
description=u'''\
The lockdiscovery property returns a
listing of who has a lock, what type
of lock he has, the timeout type and
the time remaining on the timeout,
and the associated lock token. The
server is free to withhold any or all
of this information if the requesting
principal does not have sufficient
access rights to see the requested
data.''')
supportedlock = Text(title=u'''To provide a listing of the lock\
capabilities supported by the\
resource''',
description=u'''\
The supportedlock property of a
resource returns a listing of the
combinations of scope and access types
which may be specified in a lock
request on the resource. Note that
the actual contents are themselves
controlled by access controls so a
server is not required to provide
information the client is not
authorized to see.''')
class IDAVSchema(IOptionalDAVSchema, IDAV2Schema):
"""Full DAV properties schema"""
class ISimpleDAVWidget(IWidget):
"""A specialized widget used to render DAV properties output (eg:
for the response of a PROPFIND request)"""
=== Zope3/src/zope/app/dav/adapter.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/dav/adapter.py:1.6 Wed Mar 3 06:03:59 2004
+++ Zope3/src/zope/app/dav/adapter.py Wed Mar 3 12:06:30 2004
@@ -11,19 +11,25 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""WebDAV Adapters
+"""WebDAV-related Adapters
$Id$
"""
-
from xml.dom import minidom
+
from zope.component import getAdapter, queryAdapter
+from zope.interface import implements
+
+from zope.app import zapi
+from zope.app.dav.interfaces import IDAVSchema
from zope.app.dublincore.interfaces import IDCTimes
from zope.app.interfaces.file import IReadDirectory
from zope.app.size.interfaces import ISized
-from zope.app import zapi
class DAVSchemaAdapter:
+ """An adapter for all content objects that provides the basic DAV
+ schema/namespace."""
+ implements(IDAVSchema)
def __init__(self, object):
self.context = object
=== Zope3/src/zope/app/dav/configure.zcml 1.13 => 1.14 ===
--- Zope3/src/zope/app/dav/configure.zcml:1.13 Mon Mar 1 10:02:48 2004
+++ Zope3/src/zope/app/dav/configure.zcml Wed Mar 3 12:06:30 2004
@@ -79,26 +79,17 @@
allowed_attributes="getData hasInput setRenderedValue __call__ __str__" />
<adapter
- provides="zope.app.interfaces.dav.IDAVSchema"
+ provides="zope.app.dav.interfaces.IDAVSchema"
for="*"
permission="zope.Public"
factory=".adapter.DAVSchemaAdapter" />
- <serviceType
- id="DAVSchema"
- interface="zope.app.interfaces.component.IDAVSchemaService" />
-
- <service
- serviceType="DAVSchema"
- permission="zope.Public"
- component="zope.app.dav.globaldavschemaservice.davSchemaService" />
-
<dav:provideInterface
for="http://purl.org/dc/1.1"
interface="zope.app.dublincore.interfaces.IZopeDublinCore" />
<dav:provideInterface
for="DAV:"
- interface="zope.app.interfaces.dav.IDAVSchema" />
+ interface="zope.app.dav.interfaces.IDAVSchema" />
</configure>
=== Zope3/src/zope/app/dav/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/dav/metaconfigure.py:1.2 Sat Aug 2 13:26:12 2003
+++ Zope3/src/zope/app/dav/metaconfigure.py Wed Mar 3 12:06:30 2004
@@ -15,12 +15,10 @@
$Id$
"""
-from zope.app.services.servicenames import DAVSchema
-from zope.app.component.metaconfigure import handler
+from zope.app.component.metaconfigure import utility
+from zope.interface import directlyProvides
+from interfaces import IDAVNamespace
def interface(_context, for_, interface):
- _context.action(
- discriminator = ('dav', 'provideInterface', for_, interface),
- callable = handler,
- args = (DAVSchema, 'provideInterface', for_, interface) )
-
+ directlyProvides(interface, IDAVNamespace)
+ utility(_context, IDAVNamespace, interface, name=for_)
=== Zope3/src/zope/app/dav/mkcol.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/dav/mkcol.py:1.2 Sun Sep 21 13:32:03 2003
+++ Zope3/src/zope/app/dav/mkcol.py Wed Mar 3 12:06:30 2004
@@ -13,17 +13,14 @@
$Id$
"""
-__metaclass__ = type
-
+from zope.app import zapi
from zope.app.interfaces.file import IWriteDirectory
from zope.app.interfaces.file import IDirectoryFactory
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.component import queryAdapter, getAdapter
-class NullResource:
- """MKCOL handler for creating collections
- """
+class NullResource(object):
+ """MKCOL handler for creating collections"""
def __init__(self, context, request):
self.context = context
@@ -42,12 +39,12 @@
container = self.context.container
name = self.context.name
- dir = queryAdapter(container, IWriteDirectory, None)
+ dir = zapi.queryAdapter(container, IWriteDirectory, None)
if dir is None:
request.response.setStatus(403)
return ''
- factory = getAdapter(container, IDirectoryFactory)
+ factory = zapi.getAdapter(container, IDirectoryFactory)
newdir = factory(name)
publish(self.context, ObjectCreatedEvent(newdir))
dir[name] = newdir
@@ -55,9 +52,9 @@
request.response.setStatus(201)
return ''
-class MKCOL:
- """MKCOL handler for existing objects
- """
+
+class MKCOL(object):
+ """MKCOL handler for existing objects"""
def __init__(self, context, request):
self.context = context
=== Zope3/src/zope/app/dav/propfind.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/dav/propfind.py:1.13 Wed Mar 3 05:38:40 2004
+++ Zope3/src/zope/app/dav/propfind.py Wed Mar 3 12:06:30 2004
@@ -13,20 +13,18 @@
$Id$
"""
-__metaclass__ = type
-
from xml.dom import minidom
-from zope.component import getView, queryView, queryAdapter
from zope.proxy import removeAllProxies
from zope.schema import getFieldNamesInOrder
+from zope.app import zapi
from zope.app.container.interfaces import IReadContainer
-from zope.app.dav.globaldavschemaservice import availableNamespaces
-from zope.app.dav.globaldavschemaservice import queryInterface
from zope.app.form.utility import setUpWidgets, getWidgetsDataFromAdapter
-class PROPFIND:
- """PROPFIND handler for all objects
- """
+from interfaces import IDAVNamespace
+
+
+class PROPFIND(object):
+ """PROPFIND handler for all objects"""
def __init__(self, context, request):
self.context = context
@@ -43,7 +41,7 @@
def PROPFIND(self):
request = self.request
- resource_url = str(getView(self.context, 'absolute_url', request))
+ resource_url = str(zapi.getView(self.context, 'absolute_url', request))
if IReadContainer.isImplementedBy(self.context):
resource_url = resource_url + '/'
data = request.bodyFile
@@ -74,8 +72,8 @@
# XXX For now, list the propnames for the all namespaces
# but later on, we need to list *all* propnames from *all* known
# namespaces that this object has.
- for ns in availableNamespaces():
- _avail_props[ns] = getFieldNamesInOrder(queryInterface(ns))
+ for ns, iface in zapi.getUtilitiesFor(None, IDAVNamespace):
+ _avail_props[ns] = getFieldNamesInOrder(iface)
propname = xmldoc.getElementsByTagNameNS(self.default_ns, 'propname')
if propname:
self._handlePropname(response, re, _avail_props)
@@ -106,7 +104,7 @@
count += 1
prop.setAttribute('xmlns:%s' % attr_name, ns)
iface = _props[ns]['iface']
- adapter = queryAdapter(self.context, iface, None)
+ adapter = zapi.queryAdapter(self.context, iface, None)
initial = getWidgetsDataFromAdapter(
adapter, iface, names=avail.get(ns))
setUpWidgets(self, iface, initial=initial, \
@@ -168,7 +166,7 @@
if depth != '0':
if IReadContainer.isImplementedBy(self.context):
for id, obj in self.context.items():
- pfind = queryView(obj, 'PROPFIND', self.request, None)
+ pfind = zapi.queryView(obj, 'PROPFIND', self.request, None)
if pfind is not None:
pfind.setDepth(subdepth)
value = pfind.PROPFIND()
@@ -184,7 +182,7 @@
if e.nodeType == e.ELEMENT_NODE]
for node in childs:
ns = node.namespaceURI
- iface = queryInterface(ns, None)
+ iface = zapi.queryUtility(None, IDAVNamespace, None, ns)
value = _props.get(ns, {'iface': iface, 'props': []})
value['props'].append(node.localName)
_props[ns] = value
@@ -192,7 +190,7 @@
def _handleAllprop(self, _avail_props, _props):
for ns in _avail_props.keys():
- iface = queryInterface(ns, None)
+ iface = zapi.queryUtility(None, IDAVNamespace, None, ns)
_props[ns] = {'iface': iface, 'props': _avail_props.get(ns)}
return _props
@@ -228,7 +226,7 @@
l.append(p)
not_avail[ns] = l
continue
- adapter = queryAdapter(self.context, iface, None)
+ adapter = zapi.queryAdapter(self.context, iface, None)
if adapter is None:
l = not_avail.get(ns, [])
l.append(p)
=== Zope3/src/zope/app/dav/widget.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/dav/widget.py:1.5 Wed Aug 13 17:28:30 2003
+++ Zope3/src/zope/app/dav/widget.py Wed Mar 3 12:06:30 2004
@@ -15,8 +15,7 @@
$Id$
"""
-
-from zope.app.interfaces.dav import ISimpleDAVWidget
+from zope.app.dav.interfaces import ISimpleDAVWidget
from zope.app.interfaces.form import IWidget
from zope.component.interfaces import IViewFactory
from zope.app.form.widget import Widget
=== Removed File Zope3/src/zope/app/dav/globaldavschemaservice.py ===
More information about the Zope3-Checkins
mailing list