[Zope-CMF] Customising types with add views

Martin Aspeli optilude at gmx.net
Mon Dec 8 19:22:24 EST 2008


yuppie wrote:
> Hi Martin!
> 
> 
> Martin Aspeli wrote:
>> [...]
>>
>> Let's consider a type Alpha that has a custom add form registered as 
>> such a (context, request, fti) adapter with name "Alpha". fti.factory is 
>> "Alpha", and there's a corresponding IFactory utility (with name "Alpha").
>>
>> Now, let's say I want to create a new type Beta (e.g. by copying the FTI 
>> object TTW), based on Alpha. I want this to use Alpha's add form, but 
>> construct objects with portal_type Beta.
>>
>> Is this possible? If I set Beta's fti.factory to be something other than 
>> "Alpha", then it won't find the add view, but if fti.factory is "Alpha" 
>> then the objects constructed will use Alpha's factory.
> 
> You should be able to register the same add view twice. One registration 
> for the name "Alpha" and one for the name "Beta".

Sure. I was thinking more about the case of customising by copying the 
FTI TTW.

>> I can't quite decide whether this is a problem in real life or not, 
>> although it does seem a bit strange that the add view adapter name and 
>> the factory utility name have to be the same.
>>
>> Would it make sense to decouple these, e.g. with a new "add_view_name" 
>> property?
> 
> If people really have that problem we can decouple this later. For now I 
> can't see a need.

I suspect it's YAGNI since the add view calls _setPortalTypeName() on 
the newly created instance as well, so the resulting object will have 
type Beta, not type Alpha.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-CMF mailing list