Daniel Nouri writes:

> Robert Niederreiter writes:

>> yuppie writes:

>>> I like pretty URLs, and 'foo/+/<MyPortalType>' looks much prettier than 
>>> the URLs needed with my approach:
>>>    foo/<AddViewName>?form.portal_type=<MyPortalType>
>>> Your proposal has some advantages. On the other hand this requires to 
>>> create CMF specific code and patterns in a place where a more generic 
>>> solution also works.
>> it does not if you call a formfactory inside the traverser, so it's
>> hoohable for CMF, Plone or whatever even with different formlib
>> implementations.
>> like:
>> formfactory = getAdapter(context,
>>                          IFormFactory,
>>                          name='factoryNameFromFti')
>> return factory()
>> which handles all the magic in there. just a thought.
> If I understand this correctly, it should be more like:
>   formfactory = getMultiAdapter((context, request),
>                                 IAddForm,
>                                 name='factoryNameFromFti')

My suggestion is rubbish.  First, it should be 'form', not
'formfactory'.  Then, I realize it's not the same pattern since your
factory is supposed to do some work before it passes on control (I
believe?) whereas mine is the add form class itself.

Both patterns require the same amount of registrations.  As many for
IFormFactory as for IAddForm.  What's worse is that the implementations
will have a hard time to work reusably without the portal type name,
which they're registered with.

What about the traverser does this:

        view = getMultiAdapter((context, request),
                               IAddForm, name=factory_name)
    except ComponentLookupError, e:
        view = getMultiAdapter((context, request), IAddForm)

    view.factory_name = factory_name
    return view()

In this case, the adapter/form would actually have a chance to work for
more than one portal type.

How does this sound?


Zope-CMF maillist  -  Zope-CMF@lists.zope.org

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

Reply via email to