Re: [Zope-CMF] caching policy manager

2006-09-15 Thread Dmitry S. Makovey
On Wednesday 13 September 2006 01:15, Jens Vagelpohl wrote:
 If you could, please file a bug report at http://www.zope.org/
 Collectors/CMF/. All that needs to be done is to override
 index_html (which I believe was never done because the
 implementation in OFS.File is quite a beast - it was much easier to
 just reuse it).

Done:
http://www.zope.org/Collectors/CMF/454/collector_issue_contents

-- 
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245


pgpPUBpnQZZDN.pgp
Description: PGP signature
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-15 Thread Dmitry S. Makovey
On Wednesday 13 September 2006 11:32, Dieter Maurer wrote:
 Jens Vagelpohl wrote at 2006-9-13 09:15 +0200:
  ...
 It is a long-standing bug that the CMFDefault File index_html (and
 download, which is obsolete in newer CMF versions) simply defers
  to index_html from OFS.File. That one doesn't know anything about
  Cache Policy Managers, it only deals with the Zope ZCacheable
  cache manager mechanism.

 I have defined CMF-aware ZODB object types. The one for File
 looks like this:

 # DM 2005-11-02: added
  CMF 'File' variant (CMF Cache Policy Manager aware)
...skip...

Dieter, are you saying that it's fixed somwhere in SVN or is it in 
your private repository?


-- 
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245


pgpTvj1PYTwMb.pgp
Description: PGP signature
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-15 Thread Dmitry S. Makovey
On Friday 15 September 2006 11:27, Dieter Maurer wrote:
 Dieter, are you saying that it's fixed somwhere in SVN or is it in
 your private repository?

 In our private repository.

would you care to attach your patch to 

http://www.zope.org/Collectors/CMF/454

?

I believe it will be enormously useful for others who are trying to 
use CMF framework for things that are not HTML :)

For future references: 
For now I've deployed workaround - Apache adds missing headers to 
files that are in a list of known *binary* files 
(.doc, .xls, .pdf, .ppt, etc.)

SetEnvIf Request_URI \.(xls|doc|ppt|mpp|pdf|vsd)
(/download)*$ BINARY_DATA
Header add Cache-Control no-cache env=BINARY_DATA
Header add Pragma no-cache env=BINARY_DATA

As a next step I'll be applying Dieter's changes and if everything is 
fine - discard the ugly workaround.

-- 
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245


pgpEXLLkznUEG.pgp
Description: PGP signature
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-13 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 13 Sep 2006, at 01:30, Dmitry S. Makovey wrote:

whenever I request '/file_view' method on file objects - everything
works as expected, as soon as I use '/download' all the settings are
discarded by CPM.


Well, the settings are not discarded. The Cache Policy Manager just  
does not get a chance to apply them.


It is a long-standing bug that the CMFDefault File index_html (and  
download, which is obsolete in newer CMF versions) simply defers to  
index_html from OFS.File. That one doesn't know anything about Cache  
Policy Managers, it only deals with the Zope ZCacheable cache manager  
mechanism.


If you could, please file a bug report at http://www.zope.org/ 
Collectors/CMF/. All that needs to be done is to override index_html  
(which I believe was never done because the implementation in  
OFS.File is quite a beast - it was much easier to just reuse it).


jens

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFFB7ADRAx5nvEhZLIRAp6vAJoDJy/ndoEh7Gu7EQCjIaO+e/ms4ACeIdJ6
HVDr49sNSs0qKgoIHDtKwM8=
=jESW
-END PGP SIGNATURE-
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-13 Thread Stefan H. Holek
You don't want to cache views for Files and Images. I use this for  
predicate:


python: not view and object.portal_type=='File'

Stefan


On 13. Sep 2006, at 01:30, Dmitry S. Makovey wrote:



Playing with CPM I've discovered that if I put a policy like:

id: Files
Predicate: python:content.portal_type == File
Mod. time: content/modified
Max age: 1

with all noXXX checked, I have weird behaviour:

whenever I request '/file_view' method on file objects - everything
works as expected, as soon as I use '/download' all the settings are
discarded by CPM.



--
It doesn't necessarily do it in chronological order,
though.  --Douglas Adams


___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-13 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 13 Sep 2006, at 10:04, Stefan H. Holek wrote:

You don't want to cache views for Files and Images. I use this for  
predicate:


python: not view and object.portal_type=='File'


I don't think this will help anything. The CPM never even fires,  
unfortunately.


jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFFB8BORAx5nvEhZLIRAv25AKCuxY0dGNPMUK4jPBRfnCZz/2hwRQCeK47D
UpSfIpJuHEpfzF9YJwYLf2g=
=JWy1
-END PGP SIGNATURE-
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-13 Thread Sidnei da Silva
On Wed, Sep 13, 2006 at 09:15:14AM +0200, Jens Vagelpohl wrote:
| It is a long-standing bug that the CMFDefault File index_html (and  
| download, which is obsolete in newer CMF versions) simply defers to  
| index_html from OFS.File. That one doesn't know anything about Cache  
| Policy Managers, it only deals with the Zope ZCacheable cache manager  
| mechanism.
| 
| If you could, please file a bug report at http://www.zope.org/ 
| Collectors/CMF/. All that needs to be done is to override index_html  
| (which I believe was never done because the implementation in  
| OFS.File is quite a beast - it was much easier to just reuse it).

As a workaround you can install the PolicyHTTPCacheManager product and
associate your file objects with it. 

  The PolicyHTTPCacheManager provides the ZCacheable mechanism, but
  when invoked defers to the Caching Policy Manager.

-- 
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


Re: [Zope-CMF] caching policy manager

2006-09-13 Thread Dieter Maurer
Jens Vagelpohl wrote at 2006-9-13 09:15 +0200:
 ...
It is a long-standing bug that the CMFDefault File index_html (and  
download, which is obsolete in newer CMF versions) simply defers to  
index_html from OFS.File. That one doesn't know anything about Cache  
Policy Managers, it only deals with the Zope ZCacheable cache manager  
mechanism.

I have defined CMF-aware ZODB object types. The one for File looks
like this:

# DM 2005-11-02: added
 CMF 'File' variant (CMF Cache Policy Manager aware)

from OFS.Image import File, manage_addFileForm, cookId

from utils import _setCacheHeaders, _ViewEmulator

class CMFFile(File):
'''CMF cache policy manager aware file.'''
meta_type = 'CPM aware File'

def index_html(self, REQUEST, RESPONSE):
' '
r = File.index_html(self, REQUEST, RESPONSE)
if self.ZCacheable_getManager() is None:
# not none cache manager already taken care of
_setCacheHeaders(self._getCPMCachingWrapper(), extra_context={})
return r

# DM 2006-05-17: more modular CPM caching
def _getCPMCachingWrapper(self):
return _ViewEmulator().__of__(self)
  

# essentially a copy of OFS.Image.manage_addFile -- we should probably
# use ReuseUtils.
def manage_addFile(self,id,file='',title='',precondition='', content_type='',
   REQUEST=None):
Add a new File object.

Creates a new File object 'id' with the contents of 'file'

id=str(id)
title=str(title)
content_type=str(content_type)
precondition=str(precondition)

id, title = cookId(id, title, file)

self=self.this()

# First, we create the file without data:
self._setObject(id, CMFFile(id,title,'',content_type, precondition))

# Now we upload the data.  By doing this in two steps, we
# can use a database trick to make the upload more efficient.
if file:
self._getOb(id).manage_upload(file)
if content_type:
self._getOb(id).content_type=content_type

if REQUEST is not None:
REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')


def initialize(context):
context.registerClass(
CMFFile,
permission='Add Documents, Images, and Files',
constructors=(manage_addFileForm,
  manage_addFile),
)



-- 
Dieter
___
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests