Commit 14bc8871 authored by Tres Seaver's avatar Tres Seaver

* Merge fix for Collector #998 (Adds FTP/WebDAV editing to ZClasses)

parent f9f0ddd0
...@@ -11,6 +11,14 @@ Zope changes ...@@ -11,6 +11,14 @@ Zope changes
and standard_error_message in Data.fs.in to use "new" DTML syntax and standard_error_message in Data.fs.in to use "new" DTML syntax
(as opposed to SSI-style syntax). (as opposed to SSI-style syntax).
Zope 2.3.0 beta 3
Features Added
- Make ZClasses navigable to FTP/WebDAV; implement 'PUT_factory'
hook to create PythonScripts (for MIMEtype 'text/x-python')
and DTMLMethods (for other 'text' MIMEtypes) (Collector #998).
Zope 2.3.0 beta 1 Zope 2.3.0 beta 1
Features Added Features Added
......
...@@ -92,6 +92,12 @@ import App.Dialogs, ZClasses, App.Factory, App.Product, App.ProductRegistry ...@@ -92,6 +92,12 @@ import App.Dialogs, ZClasses, App.Factory, App.Product, App.ProductRegistry
import ZClassOwner import ZClassOwner
from AccessControl.PermissionMapping import aqwrap, PermissionMapper from AccessControl.PermissionMapping import aqwrap, PermissionMapper
import OFS.content_types
from OFS.DTMLMethod import DTMLMethod
from Products.PythonScripts.PythonScript import PythonScript
import marshal
_marker=[] _marker=[]
class ZClassMethodsSheet( class ZClassMethodsSheet(
OFS.PropertySheets.PropertySheet, OFS.PropertySheets.PropertySheet,
...@@ -240,6 +246,30 @@ class ZClassMethodsSheet( ...@@ -240,6 +246,30 @@ class ZClassMethodsSheet(
def possible_permissions(self): def possible_permissions(self):
return self.classDefinedAndInheritedPermissions() return self.classDefinedAndInheritedPermissions()
#
# FTP support
#
def manage_FTPstat(self,REQUEST):
"Psuedo stat used for FTP listings"
mode=0040000|0770
mtime=self.bobobase_modification_time().timeTime()
owner=group='Zope'
return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
def PUT_factory( self, name, typ, body ):
"""
Hook PUT creation to make objects of the right type when
new item uploaded via FTP/WebDAV.
"""
if typ is None:
typ, enc = OFS.content_types.guess_content_type()
if typ == 'text/x-python':
return PythonScript( name )
if typ[ :4 ] == 'text':
return DTMLMethod( '', __name__=name )
return None # take the default, then
default_dm_html='''<html> default_dm_html='''<html>
<head><title><dtml-var document_title></title></head> <head><title><dtml-var document_title></title></head>
<body bgcolor="#FFFFFF" LINK="#000099" VLINK="#555555"> <body bgcolor="#FFFFFF" LINK="#000099" VLINK="#555555">
......
...@@ -91,7 +91,9 @@ from ZPublisher.mapply import mapply ...@@ -91,7 +91,9 @@ from ZPublisher.mapply import mapply
from ExtensionClass import Base from ExtensionClass import Base
from App.FactoryDispatcher import FactoryDispatcher from App.FactoryDispatcher import FactoryDispatcher
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
import OFS.PropertySheets import webdav.Collection
import marshal
if not hasattr(Products, 'meta_types'): if not hasattr(Products, 'meta_types'):
Products.meta_types=() Products.meta_types=()
...@@ -158,7 +160,7 @@ from OFS.misc_ import p_ ...@@ -158,7 +160,7 @@ from OFS.misc_ import p_
p_.ZClass_Icon=Globals.ImageFile('class.gif', globals()) p_.ZClass_Icon=Globals.ImageFile('class.gif', globals())
class PersistentClass(Base): class PersistentClass(Base, webdav.Collection.Collection ):
def __class_init__(self): pass def __class_init__(self): pass
manage_addZClassForm=Globals.DTMLFile( manage_addZClassForm=Globals.DTMLFile(
...@@ -267,7 +269,10 @@ def PersistentClassDict(doc=None, meta_type=None): ...@@ -267,7 +269,10 @@ def PersistentClassDict(doc=None, meta_type=None):
return dict return dict
_marker=[] _marker=[]
class ZClass(OFS.SimpleItem.SimpleItem): class ZClass( Base
, webdav.Collection.Collection
, OFS.SimpleItem.SimpleItem
):
"""Zope Class """Zope Class
""" """
meta_type="Z Class" meta_type="Z Class"
...@@ -319,10 +324,11 @@ class ZClass(OFS.SimpleItem.SimpleItem): ...@@ -319,10 +324,11 @@ class ZClass(OFS.SimpleItem.SimpleItem):
isheets_base_classes.append(Property.ZInstanceSheets) isheets_base_classes.append(Property.ZInstanceSheets)
# Create the meta-class property sheet # Create the meta-class property sheet
sheet_id = id+'_ZPropertySheetsClass'
zsheets_class=type(PersistentClass)( zsheets_class=type(PersistentClass)(
id+'_ZPropertySheetsClass', sheet_id,
tuple(zsheets_base_classes)+(Globals.Persistent,), tuple(zsheets_base_classes)+(Globals.Persistent,),
PersistentClassDict(id+'_ZPropertySheetsClass')) PersistentClassDict(sheet_id, sheet_id))
self.propertysheets=sheets=zsheets_class() self.propertysheets=sheets=zsheets_class()
# Create the class # Create the class
...@@ -628,6 +634,47 @@ class ZClass(OFS.SimpleItem.SimpleItem): ...@@ -628,6 +634,47 @@ class ZClass(OFS.SimpleItem.SimpleItem):
def _getZClass(self): return self def _getZClass(self): return self
#
# FTP support
#
def manage_FTPlist(self,REQUEST):
"Directory listing for FTP"
out=()
files=self.__dict__.items()
if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and
self.isTopLevelPrincipiaApplicationObject):
files.insert(0,('..',self.aq_parent))
for k,v in files:
try: stat=marshal.loads(v.manage_FTPstat(REQUEST))
except:
stat=None
if stat is not None:
out=out+((k,stat),)
return marshal.dumps(out)
def manage_FTPstat(self,REQUEST):
"Psuedo stat used for FTP listings"
mode=0040000|0770
mtime=self.bobobase_modification_time().timeTime()
owner=group='Zope'
return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
#
# WebDAV support
#
isAnObjectManager=1
def objectValues( self, filter=None ):
"""
"""
values = [ self.propertysheets ]
if filter is not None:
if type( filter ) == type( '' ):
filter = [ filter ]
for value in values:
if not self.propertysheets.meta_type in filter:
values.remove( value )
return values
class ZClassSheets(OFS.PropertySheets.PropertySheets): class ZClassSheets(OFS.PropertySheets.PropertySheets):
"Manage a collection of property sheets that provide ZClass management" "Manage a collection of property sheets that provide ZClass management"
...@@ -646,6 +693,39 @@ class ZClassSheets(OFS.PropertySheets.PropertySheets): ...@@ -646,6 +693,39 @@ class ZClassSheets(OFS.PropertySheets.PropertySheets):
self.methods=Method.ZClassMethodsSheet('methods') self.methods=Method.ZClassMethodsSheet('methods')
self.common=Property.ZInstanceSheetsSheet('common') self.common=Property.ZInstanceSheetsSheet('common')
#
# FTP support
#
def manage_FTPlist(self,REQUEST):
"Directory listing for FTP"
out=()
files=self.__dict__.items()
if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and
self.isTopLevelPrincipiaApplicationObject):
files.insert(0,('..',self.aq_parent))
for k,v in files:
try: stat=marshal.loads(v.manage_FTPstat(REQUEST))
except:
stat=None
if stat is not None:
out=out+((k,stat),)
return marshal.dumps(out)
def manage_FTPstat(self,REQUEST):
"Psuedo stat used for FTP listings"
mode=0040000|0770
mtime=self.bobobase_modification_time().timeTime()
owner=group='Zope'
return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
#
# WebDAV support
#
isAnObjectManager=1
def objectValues( self, filter=None ):
return [ self.methods, self.common ]
class ZObject: class ZObject:
......
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