[Zope-CMF] HELP-cannot publish folder as manager-HTTPResponse.py

Carl Rendell cer@sol43.com
Wed, 18 Sep 2002 09:09:44 -0700


On Wednesday, September 18, 2002, at 06:51  AM, Tres Seaver wrote:

> On Tue, 2002-09-17 at 18:20, Florent Guillaume wrote:
>> Hmmm I thought I mentionned that somewhere in the past.
>>
>> '/view' has to be inserted for contentish types otherwise images and
>> files (whose base url has the meaning "download") would not be treated
>> correctly.
>
> I have a workaround for this problem, which I will probably land on the
> head RSN:
>
>   - Add a new (FS)PythonScript, 'search_suffix', which tests the
>     'portal_type' of its context and returns either '/view' (for Image,
>     File, etc.) or '' (the default).
>
>   - Add 'search_suffix' to the catalog's schema.
>
>   - Reindex the catalog.
>
>   - Modify the 'search' template to concatenate the absolute URL with
>     the value of the brain's 'search_suffix'.
>
> Perhaps a better implementation would be to add a 'search_suffix'
> property to the TypeInformation base class, and then have the method
> return the property from its context's type.
>
>

That would work, but I did things a little different based on 
testing for 'meta_type'. First, I test on meta_type because I have 
many folderish portal_type's but they all have the same meta_type 
(Portal Folder). It's fine to test meta_type in 
content_status_modify.py because you have the object there to test, 
but no true for a catalog search. For the second issue I have 
meta_type added to the catalog Metadata and Indexes (actually this 
allows the Type column to display the meta_type instead of CMF 
Catalog for every item)

Here are my two changes:
content_status_modify.py

## Script (Python) "content_status_modify"
##parameters=workflow_action, comment=''
##title=Modify the status of a content object

context.portal_workflow.doActionFor(
     context,
     workflow_action,
     comment=comment)

if workflow_action == 'reject':
	redirect_url = context.portal_url() + '/search?review_state=pending'
else:
	if context.meta_type == 'Portal Folder':
		redirect_url = '%s?%s' % ( context.absolute_url()
                                   , 
'portal_status_message=Status+changed.'
                                   )
	else:
		redirect_url = '%s/view?%s' % ( context.absolute_url()
		                              , 
'portal_status_message=Status+changed.'
		                              )

context.REQUEST[ 'RESPONSE' ].redirect( redirect_url )


search.pt (in the tal:define)

from

<td tal:define="global objURL python: results.getURL() + '/view'">

to

<td tal:define="global objURL python: results.getURL();
                 folderTypes python:['Portal Folder',];
                 global objURL python:test(results.meta_type not in 
folderTypes,
                                           '%s%s' % 
(objURL,'/view'),objURL)">



Carl E. Rendell
Solution43
Information Distribution Consulting        |   "Ahhhh the power of
cer@sol43.com                              |    acquisition"  - Chef Z