Re: [Zope] FTP for ZClass hierarchies
Robin Becker <robin@jessikat.fsnet.co.uk> wrote:
M. Adam Kendall <mak@kha0s.org> writes
In the past few days I have been working on a patch that will let you edit ZClasses via FTP without the need for typing in actual pathnames to get to the methods (mainly so I can edit ZClasses with HTML-Kit). Strangely enough, even with the modifications, I see this same thing.
I've included this patch in case anyone wants to play around with it. It's not the greatest, and definitely needs to be modified (some of the security mechanisms are bound to be broken). But it is a start anyway. ;)
Does this let you write the methods back?
I was just able to change a DTML method in a ZClass (after patching a single indentation error). Adam, you rock! I am attaching my emended patch. Tres. -- =============================================================== Tres Seaver tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org Index: Method.py =================================================================== RCS file: /cvs-repository/Zope2/lib/python/ZClasses/Method.py,v retrieving revision 1.18 diff -u -r1.18 Method.py --- Method.py 2000/08/14 14:34:23 1.18 +++ Method.py 2000/12/08 03:43:29 @@ -92,6 +92,8 @@ import ZClassOwner from AccessControl.PermissionMapping import aqwrap, PermissionMapper +import marshal + _marker=[] class ZClassMethodsSheet( OFS.PropertySheets.PropertySheet, @@ -104,6 +106,13 @@ icon='p_/Methods_icon' def tpURL(self): return 'propertysheets/methods' + + 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)) ###################################################################### # Hijinks to let us create factories and classes within classes. Index: ZClass.py =================================================================== RCS file: /cvs-repository/Zope2/lib/python/ZClasses/ZClass.py,v retrieving revision 1.50 diff -u -r1.50 ZClass.py --- ZClass.py 2000/11/01 22:59:34 1.50 +++ ZClass.py 2000/12/08 03:43:31 @@ -91,8 +91,9 @@ from ExtensionClass import Base from App.FactoryDispatcher import FactoryDispatcher from ComputedAttribute import ComputedAttribute -import OFS.PropertySheets +import marshal + if not hasattr(Products, 'meta_types'): Products.meta_types=() @@ -281,6 +282,28 @@ ('', '__call__', 'index_html', 'createInObjectManager')), ) + 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)) + def __init__(self, id, title, bases, zope_object=1): """Build a Zope class @@ -640,6 +663,28 @@ views = Basic.ZClassViewsSheet('views') basic = Basic.ZClassBasicSheet('basic') permissions = Basic.ZClassPermissionsSheet('permissions') + + 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)) def __init__(self): self.methods=Method.ZClassMethodsSheet('methods')
Does this let you write the methods back?
I was just able to change a DTML method in a ZClass (after patching a single indentation error). Adam, you rock!
Yeah, I know ;) Only took me two days of playing around and figuring out what objects got called where and realizing that I had to override manage_FTPstat for most of the objects involved. The latest and greatest patches can be found here: http://www.zope.org/Members/akendall/zclassftp This has most of my updates since posting the original patch earlier today including some of the security settings I was missing earlier. Hope everyone can test the hell out of this and make sure I didn't really hose something. Maybe this could be looked at by the DC folks and included in the next test version release of Zope? Just a thought ;) Adam
On Thu, 7 Dec 2000, M. Adam Kendall wrote:
Maybe this could be looked at by the DC folks and included in the next test version release of Zope? Just a thought ;) That would be really great. I like to use the Zope-Debian packages and I don't want to patch and recompile them after every Zope release. This would be more work then necessary for many people in my opinion.
Kind regards Andreas.
participants (3)
-
Andreas Tille -
M. Adam Kendall -
Tres Seaver