Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

Customising types with add views

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


optilude at gmx

Dec 8, 2008, 7:20 AM

Post #1 of 4 (606 views)
Permalink
Customising types with add views

Hi,

Currently, we have this situation (on trunk):

- Add views are looked up by evaluating the FTI add_view_expr

- The default/conventional add_view_expr is

string:${folder_url}/++add++<typename>

- This will look for an adapter (context, request, fti) with name =
fti.factory and return that as the add view

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.

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?

Martin

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

_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


y.2008 at wcm-solutions

Dec 8, 2008, 10:08 AM

Post #2 of 4 (580 views)
Permalink
Re: Customising types with add views [In reply to]

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".

> 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.


Cheers,

Yuppie


_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


optilude at gmx

Dec 8, 2008, 4:22 PM

Post #3 of 4 (578 views)
Permalink
Re: Customising types with add views [In reply to]

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

_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


y.2008 at wcm-solutions

Dec 9, 2008, 4:49 AM

Post #4 of 4 (570 views)
Permalink
Re: Customising types with add views [In reply to]

Martin Aspeli wrote:
> yuppie wrote:
>> 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.

Oops! I just realized that I didn't read your example correctly. I
thought you would *want* to set Beta's fti.factory to something different.

As you noticed, using the same factory *and* add view for different
portal types is supported. In fact that's the reason why we adapt the
type info and can't use normal browser pages.

Cheers, Yuppie

_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.