[Checkins] SVN: Products.ExternalEditor/trunk/ - Added support for unaware mimetype browser - we now add the .zem extension no
Matthias Broquet
mbroquet at atreal.net
Wed Dec 1 05:21:07 EST 2010
Log message for revision 118653:
- Added support for unaware mimetype browser - we now add the .zem extension no
matter what the user-agent
- Modified the cache's parameters - special case for MSIE
- Corrected and added tests
Changed:
U Products.ExternalEditor/trunk/CHANGES.txt
U Products.ExternalEditor/trunk/Products/ExternalEditor/ExternalEditor.py
U Products.ExternalEditor/trunk/Products/ExternalEditor/tests/edit.txt
U Products.ExternalEditor/trunk/Products/ExternalEditor/tests/link.txt
-=-
Modified: Products.ExternalEditor/trunk/CHANGES.txt
===================================================================
--- Products.ExternalEditor/trunk/CHANGES.txt 2010-12-01 10:11:07 UTC (rev 118652)
+++ Products.ExternalEditor/trunk/CHANGES.txt 2010-12-01 10:21:05 UTC (rev 118653)
@@ -1,10 +1,17 @@
Changelog
=========
-1.0.1 - unreleased
+1.1.0 - 2010-12-01
------------------
+- Added support for unaware mimetype browser - we now add the .zem extension no
+ matter what the user-agent
+
+- Modified the cache's parameters - special case for MSIE
+- Corrected and added tests
+
+
1.0 - 2010-07-01
----------------
Modified: Products.ExternalEditor/trunk/Products/ExternalEditor/ExternalEditor.py
===================================================================
--- Products.ExternalEditor/trunk/Products/ExternalEditor/ExternalEditor.py 2010-12-01 10:11:07 UTC (rev 118652)
+++ Products.ExternalEditor/trunk/Products/ExternalEditor/ExternalEditor.py 2010-12-01 10:21:05 UTC (rev 118653)
@@ -93,7 +93,7 @@
path = request['TraversalRequestNameStack']
if path:
target = path[-1]
- if request.get('macosx') and target.endswith('.zem'):
+ if target.endswith('.zem'):
# Remove extension added by EditLink() for Mac finder
# so we can traverse to the target in Zope
target = target[:-4]
@@ -240,8 +240,20 @@
# Using RESPONSE.setHeader('Pragma', 'no-cache') would be better, but
# this chokes crappy most MSIE versions when downloads happen on SSL.
# cf. http://support.microsoft.com/support/kb/articles/q316/4/31.asp
- RESPONSE.setHeader('Last-Modified', rfc1123_date())
+ #RESPONSE.setHeader('Last-Modified', rfc1123_date())
RESPONSE.setHeader('Content-Type', 'application/x-zope-edit')
+
+ # We have to test the msie behaviour
+ user_agent = self.REQUEST.get_header('User-Agent')
+ if user_agent and (("msie" in user_agent.lower())
+ or ("microsoft internet explorer" in user_agent.lower())):
+ RESPONSE.setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
+ RESPONSE.setHeader('Pragma', 'public')
+ else:
+ RESPONSE.setHeader('Pragma', 'no-cache')
+ now = rfc1123_date()
+ RESPONSE.setHeader('Last-Modified', now)
+ RESPONSE.setHeader('Expires', now)
def _write_metadata(self, RESPONSE, metadata, length):
# Set response content-type so that the browser gets hinted
@@ -256,7 +268,7 @@
InitializeClass(ExternalEditor)
-is_mac_user_agent = re.compile('.*Mac OS X.*|.*Mac_PowerPC.*').match
+#is_mac_user_agent = re.compile('.*Mac OS X.*|.*Mac_PowerPC.*').match
def EditLink(self, object, borrow_lock=0, skip_data=0):
"""Insert the external editor link to an object if appropriate"""
@@ -268,15 +280,10 @@
or hasattr(base, 'read'))
if editable and user.has_permission(ExternalEditorPermission, object):
query = {}
- if is_mac_user_agent(object.REQUEST['HTTP_USER_AGENT']):
- # Add extension to URL so that the Mac finder can
- # launch the ZopeEditManager helper app
- # this is a workaround for limited MIME type
- # support on MacOS X browsers
- ext = '.zem'
- query['macosx'] = 1
- else:
- ext = ''
+ # Add extension to URL so that the Client
+ # launch the ZopeEditManager helper app
+ # this is a workaround for limited MIME type
+ ext = '.zem'
if borrow_lock:
query['borrow_lock'] = 1
if skip_data:
Modified: Products.ExternalEditor/trunk/Products/ExternalEditor/tests/edit.txt
===================================================================
--- Products.ExternalEditor/trunk/Products/ExternalEditor/tests/edit.txt 2010-12-01 10:11:07 UTC (rev 118652)
+++ Products.ExternalEditor/trunk/Products/ExternalEditor/tests/edit.txt 2010-12-01 10:21:05 UTC (rev 118653)
@@ -16,13 +16,15 @@
>>> self.folder.manage_addFile('some-file', file='some content')
>>> print http(r"""
- ... GET /test_folder_1_/externalEdit_/some-file HTTP/1.1
+ ... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
Content-Length: 167
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -57,8 +59,10 @@
... """ % (user_name, user_password))
HTTP/1.1 200 OK
Content-Length: ...
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -79,8 +83,10 @@
... """ % (user_name, user_password))
HTTP/1.1 200 OK
Content-Length: ...
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -103,7 +109,9 @@
HTTP/1.1 200 OK
Content-Length: ...
Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -129,8 +137,10 @@
... """ % (user_name_2, user_password_2))
HTTP/1.1 200 OK
Content-Length: 163
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -159,8 +169,10 @@
... """ % (user_name, user_password))
HTTP/1.1 200 OK
Content-Length: 140
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/another-file
meta_type:Side Effects
@@ -189,8 +201,10 @@
... """ % (user_name, user_password))
HTTP/1.1 200 OK
Content-Length: 191
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -220,7 +234,9 @@
HTTP/1.1 200 OK
Content-Length: 155
Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
@@ -248,7 +264,62 @@
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 159
- Content-Type: application/x-zope-edit; charset=iso-8859-15
+ Content-Type: application/x-zope-edit
+ Expires:...
Last-Modified:...
+ Pragma:...
>>> _callbacks[:] = old_cb
+
+
+MSIE cache behaviour
+====================
+
+We set the user agent at `MSIE` and look at the cache headers.
+
+ >>> print http(r"""
+ ... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
+ ... User-Agent: MSIE
+ ... Authorization: Basic %s:%s
+ ... """ % (user_name, user_password))
+ HTTP/1.1 200 OK
+ Cache-Control: must-revalidate, post-check=0, pre-check=0
+ Content-Length: 167
+ Content-Type: application/x-zope-edit
+ Expires:...
+ Last-Modified:...
+ Pragma: public
+ <BLANKLINE>
+ url:http://localhost/test_folder_1_/some-file
+ meta_type:File
+ title:
+ content_type:application/octet-stream
+ auth:...
+ cookie:
+ <BLANKLINE>
+ some content
+
+Because we also are IE 1.0 compliant, we try with `Microsoft Internet Explorer'
+Cheers JNUT !! ;)
+
+ >>> print http(r"""
+ ... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
+ ... User-Agent: Microsoft Internet Explorer
+ ... Authorization: Basic %s:%s
+ ... """ % (user_name, user_password))
+ HTTP/1.1 200 OK
+ Cache-Control: must-revalidate, post-check=0, pre-check=0
+ Content-Length: 167
+ Content-Type: application/x-zope-edit
+ Expires:...
+ Last-Modified:...
+ Pragma: public
+ <BLANKLINE>
+ url:http://localhost/test_folder_1_/some-file
+ meta_type:File
+ title:
+ content_type:application/octet-stream
+ auth:...
+ cookie:
+ <BLANKLINE>
+ some content
Modified: Products.ExternalEditor/trunk/Products/ExternalEditor/tests/link.txt
===================================================================
--- Products.ExternalEditor/trunk/Products/ExternalEditor/tests/link.txt 2010-12-01 10:11:07 UTC (rev 118652)
+++ Products.ExternalEditor/trunk/Products/ExternalEditor/tests/link.txt 2010-12-01 10:21:05 UTC (rev 118653)
@@ -33,14 +33,14 @@
'test_user_1_'
>>> EditLink(self.folder, ob)
- '<a href="http://nohost/test_folder_1_/externalEdit_/some-file" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
+ '<a href="http://nohost/test_folder_1_/externalEdit_/some-file.zem" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
Borrow Lock feature:
>>> EditLink(self.folder, ob, borrow_lock=1)
- '<a href="http://nohost/test_folder_1_/externalEdit_/some-file?borrow_lock=1" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
+ '<a href="http://nohost/test_folder_1_/externalEdit_/some-file.zem?borrow_lock=1" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
Skip Data feature:
>>> EditLink(self.folder, ob, skip_data=1)
- '<a href="http://nohost/test_folder_1_/externalEdit_/some-file?skip_data=1" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
+ '<a href="http://nohost/test_folder_1_/externalEdit_/some-file.zem?skip_data=1" title="Edit using external editor"><img src="/misc_/ExternalEditor/edit_icon" align="middle" hspace="2" border="0" alt="External Editor" /></a>'
More information about the checkins
mailing list