[Zope-dev] patch for FTP editing of SQL Methods

Brian Takashi Hooper brian@garage.co.jp
Sun, 16 Jan 2000 22:32:38 +0900


Hi there -

I don't know if this will interest anyone, but I added rudimentary
FTP support to SQL Methods (so that people like me who edit through
emacs or some other FTP interface can change stuff that way).  Of course
there is no provision for changing arguments to the SQL Method and what
have you, but exactly how to do that right is kinda unclear at this
point... well, better than nothing?

Here's the patch:
--Brian Hooper


diff -u ZSQLMethods.orig/SQL.py ZSQLMethods/SQL.py
--- ZSQLMethods.orig/SQL.py     Sun Jan 16 22:20:28 2000
+++ ZSQLMethods/SQL.py  Sun Jan 16 22:05:23 2000
@@ -189,3 +189,27 @@

     manage_main=HTMLFile('edit', globals())

+    __ac_permissions__=(
+        ('FTP access', ('manage_FTPstat','manage_FTPget','manage_FTPlist')),
+        ('Change Database Methods',
+         ('manage_edit','manage_advanced', 'manage_testForm','manage_test',
+          'PUT')),
+    )
+
+    def manage_FTPget(self):
+        "Get source for FTP download"
+        return self.src
+
+    def PUT(self, REQUEST, RESPONSE):
+        """Handle HTTP PUT requests."""
+        self.dav__init(REQUEST, RESPONSE)
+        body=REQUEST.get('BODY', '')
+        # self._validateProxy(REQUEST)  is this OK?
+        try:
+            self.src=body
+            self.template=t=Shared.DC.ZRDB.DA.SQL(body)
+            t.cook()
+            RESPONSE.setStatus(204)
+        except ParseError:
+            RESPONSE.setStatus(426)
+        return RESPONSE