[Zope-CVS] CVS: Products/ExternalEditor - ExternalEditor.py:1.22 zopeedit.py:1.40

Shane Hathaway shane@zope.com
Tue, 4 Mar 2003 14:24:43 -0500


Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv15003

Modified Files:
	ExternalEditor.py zopeedit.py 
Log Message:
Allowed the server to specify to the client that it should always borrow the
WebDAV lock instead of prompt the user.  To use this, render the edit link
using "externalEditLink_(obj, borrow_lock=1)".


=== Products/ExternalEditor/ExternalEditor.py 1.21 => 1.22 ===
--- Products/ExternalEditor/ExternalEditor.py:1.21	Mon Oct 28 11:18:02 2002
+++ Products/ExternalEditor/ExternalEditor.py	Tue Mar  4 14:24:42 2003
@@ -96,6 +96,8 @@
                 if creator and creator[1] == user_id:
                     # Found a lock for this user, so send it
                     r.append('lock-token:%s' % lock.getLockToken())
+                    if REQUEST.get('borrow_lock'):
+                        r.append('borrow_lock:1')
                     break       
               
         r.append('')
@@ -137,7 +139,7 @@
 
 InitializeClass(ExternalEditor)
 
-def EditLink(self, object):
+def EditLink(self, object, borrow_lock=0):
     """Insert the external editor link to an object if appropriate"""
     base = Acquisition.aq_base(object)
     user = getSecurityManager().getUser()
@@ -146,13 +148,15 @@
                 or hasattr(base, 'document_src')
                 or hasattr(base, 'read'))
     if editable and user.has_permission(ExternalEditorPermission, object):
-        return ('<a href="%s/externalEdit_/%s" '
+        url = "%s/externalEdit_/%s" % (
+            object.aq_parent.absolute_url(), urllib.quote(object.getId()))
+        if borrow_lock:
+            url += '?borrow_lock=1'
+        return ('<a href="%s" '
                 'title="Edit using external editor">'
                 '<img src="%s/misc_/ExternalEditor/edit_icon" '
                 'align="middle" hspace="2" border="0" alt="External Editor" />'
-                '</a>' % (object.aq_parent.absolute_url(), 
-                          urllib.quote(object.getId()),
-                          object.REQUEST.BASEPATH1)
+                '</a>' % (url, object.REQUEST.BASEPATH1)
                )
     else:
         return ''


=== Products/ExternalEditor/zopeedit.py 1.39 => 1.40 ===
--- Products/ExternalEditor/zopeedit.py:1.39	Sun Sep 29 02:05:49 2002
+++ Products/ExternalEditor/zopeedit.py	Tue Mar  4 14:24:42 2003
@@ -296,10 +296,11 @@
         if use_locks and self.metadata.get('lock-token'):
             # A lock token came down with the data, so the object is
             # already locked, see if we can borrow the lock
-            if int(self.options.get('always_borrow_locks', 0)) \
-               or askYesNo('This object is already locked by you in another'
-                           ' session.\n Do you want to borrow this lock'
-                           ' and continue?'):
+            if (int(self.options.get('always_borrow_locks', 0))
+                or self.metadata.get('borrow_lock')
+                or askYesNo('This object is already locked by you in another'
+                            ' session.\n Do you want to borrow this lock'
+                            ' and continue?')):
                 self.lock_token = 'opaquelocktoken:%s' \
                                   % self.metadata['lock-token']
             else: