Commit 74d323b9 authored by 's avatar

Added preliminary webdav support.

parent ee70a7f5
......@@ -102,7 +102,7 @@
##############################################################################
"""DTML Document objects."""
__version__='$Revision: 1.8 $'[11:-2]
__version__='$Revision: 1.9 $'[11:-2]
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from ZPublisher.Converters import type_converters
from Globals import HTML, HTMLFile, MessageDialog
......@@ -154,24 +154,6 @@ class DTMLDocument(DTMLMethod, PropertyManager):
state[k]=v
return state
def on_update(self):
# This is just experimental!
if 1: return
try: meta=hp(self.raw)
except: return
for key, val in meta.metavars.items():
if not self.hasProperty(key):
t=find(key, ':')
if t > 0:
type=key[t+1:]
key=key[:t]
else: type='string'
if type_converters.has_key(type):
val=type_converters[type](val)
self._setProperty(key, val, type)
if not self.title:
self.title=meta.title
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
dtpref_rows='20',REQUEST=None):
"""
......@@ -189,7 +171,6 @@ class DTMLDocument(DTMLMethod, PropertyManager):
self.title=title
if type(data) is not type(''): data=data.read()
self.munge(data)
self.on_update()
if REQUEST: return MessageDialog(
title ='Success!',
message='Your changes have been saved',
......@@ -200,20 +181,11 @@ class DTMLDocument(DTMLMethod, PropertyManager):
self._validateProxy(REQUEST)
if type(file) is not type(''): file=file.read()
self.munge(file)
self.on_update()
if REQUEST: return MessageDialog(
title ='Success!',
message='Your changes have been saved',
action ='manage_main')
def PUT(self, BODY, REQUEST, RESPONSE):
"""Handle HTTP PUT requests."""
self._validateProxy(REQUEST)
self.munge(BODY)
self.on_update()
RESPONSE.setStatus(204)
return RESPONSE
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
"""Render the document given a client object, REQUEST mapping,
Response, and key word arguments."""
......@@ -234,54 +206,6 @@ class DTMLDocument(DTMLMethod, PropertyManager):
class hp(SGMLParser):
from htmlentitydefs import entitydefs
def __init__(self, data):
SGMLParser.__init__(self, verbose=0)
self.metavars={}
self.headers={}
self.data=None
self.title=''
try: self.feed(data)
except done: pass
def handle_data(self, data):
if self.data is not None:
self.data=self.data + data
else: pass
def save_bgn(self):
self.data=''
def save_end(self):
data=self.data
self.data=None
return data
def start_head(self, attrs):
pass
def end_head(self):
# avoid parsing whole file!
raise done, done
def start_title(self, attrs):
self.save_bgn()
def end_title(self):
self.title=self.save_end()
def do_meta(self, attrs):
dict={}
for key, val in attrs:
dict[key]=val
if dict.has_key('http-equiv'):
self.headers[dict['http-equiv']]=dict['content']
elif dict.has_key('name'):
self.metavars[dict['name']]=dict['content']
default_dd_html="""<!--#var standard_html_header-->
......@@ -301,7 +225,6 @@ def add(self, id, title='', file='', REQUEST=None, submit=None):
if not file: file=default_dd_html
ob=DTMLDocument(file, __name__=id)
ob.title=title
ob.on_update()
self._setObject(id, ob)
if REQUEST is not None:
u=REQUEST['URL1']
......
......@@ -102,7 +102,7 @@
##############################################################################
"""DTML Method objects."""
__version__='$Revision: 1.5 $'[11:-2]
__version__='$Revision: 1.6 $'[11:-2]
from Globals import HTML, HTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi,lower
......@@ -308,10 +308,12 @@ class DTMLMethod(cDocument, HTML, Explicit, RoleManager, Item_w__name__):
## Protocol handlers
def PUT(self, BODY, REQUEST, RESPONSE):
def PUT(self, REQUEST, RESPONSE):
"""Handle HTTP PUT requests."""
self.init_headers(RESPONSE)
body=REQUEST.get('BODY', '')
self._validateProxy(REQUEST)
self.munge(BODY)
self.munge(body)
RESPONSE.setStatus(204)
return RESPONSE
......
......@@ -105,15 +105,17 @@
Folders are the basic container objects and are analogous to directories.
$Id: Folder.py,v 1.65 1999/02/18 22:56:51 amos Exp $"""
$Id: Folder.py,v 1.66 1999/03/03 22:41:32 brian Exp $"""
__version__='$Revision: 1.65 $'[11:-2]
__version__='$Revision: 1.66 $'[11:-2]
import Globals, SimpleItem, Acquisition, mimetypes, content_types
from Globals import HTMLFile
from ObjectManager import ObjectManager
from PropertyManager import PropertyManager
from AccessControl.Role import RoleManager
from webdav.NullResource import NullResource
from webdav.Collection import Collection
from CopySupport import CopyContainer
from FindSupport import FindSupport
from Image import Image, File
......@@ -141,8 +143,8 @@ def manage_addFolder(self,id,title='',createPublic=0,createUserF=0,
if createPublic: i.manage_addDTMLDocument(id='index_html',title='')
if REQUEST is not None: return self.manage_main(self,REQUEST,update_menu=1)
class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
CopyContainer, FindSupport):
class Folder(ObjectManager, PropertyManager, RoleManager, Collection,
SimpleItem.Item, CopyContainer, FindSupport):
"""
The basic container object in Principia. Folders can hold almost all
other Principia objects.
......@@ -220,15 +222,10 @@ class Folder(ObjectManager, PropertyManager, RoleManager, SimpleItem.Item,
return r
def __getitem__(self, key):
# Hm, getattr didn't work, maybe this is a put:
if key[:19]=='manage_draftFolder-':
id=key[19:]
if hasattr(self, id): return getattr(self, id).manage_supervisor()
raise KeyError, key
try:
if self.REQUEST['REQUEST_METHOD']=='PUT':
return PUTer(self,key).__of__(self)
except: pass
if hasattr(self, 'REQUEST'):
method=self.REQUEST.get('REQUEST_METHOD', 'GET')
if not method in ('GET', 'POST'):
return NullResource(self, key).__of__(self)
raise KeyError, key
def folderClass(self):
......
......@@ -107,20 +107,22 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.36 1999/02/22 20:43:43 jim Exp $'''
__version__='$Revision: 1.36 $'[11:-2]
$Id: SimpleItem.py,v 1.37 1999/03/03 22:41:32 brian Exp $'''
__version__='$Revision: 1.37 $'[11:-2]
import regex, sys, Globals, App.Management
from webdav.Resource import Resource
from ExtensionClass import Base
from DateTime import DateTime
from CopySupport import CopySource
from string import join, lower
from types import InstanceType, StringType
import marshal
HTML=Globals.HTML
class Item(Base, CopySource, App.Management.Tabs):
class Item(Base, Resource, CopySource, App.Management.Tabs):
"""A simple Principia object. Not Folderish."""
isPrincipiaFolderish=0
isTopLevelPrincipiaApplicationObject=0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment