External Source query

Jonathan Bowlas <j.bowlas-hclig2XLE9Zaa/[email protected]> Tue, 23 Aug 2011 17:11:51 +0100
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <CAGq+fUH6hSM5ZnUp+hpPG3xv_tsbFnefPMV2soBd+FFTNorUnw@mail.gmail.com>
Hi Devs,

I'm in the process of creating an external source thats an INV
variation but I've encountered a slight problem I'm not sure how to
overcome - appologies in advance for the verbose explanation, but I
couldn't think how else to explain it.

My client would like to be able to select which news articles get
displayed via the INV. I.e we specify the INV returns 20 items, but
they would like to choose say 2 that are displayed in with a large
thumbnail, three with a smaller thumbnail and five with no thumbnail
at all.

To achieve this I decided to generate a MultiListField where each item
in the list is a news or event item from a predefined viewer. I've
done this by adding this TALES expression below to the 'Item' property
on the TALES tab for the MultiListField within my code source
parameters:

python:[[ item.get_news_item().aq_parent.get_title(),
'/'.join(item.get_news_item().getPhysicalPath())] for item in
form.get_specific_items(20,
request.form.setdefault('viewer',form.get_viewers()[0][1]),
form.REQUEST.model)]

As you can see from the above, I create a list containing the news
item title and it's path for each item returned by get_specific_items.
get_specific_items is a variation on get_items() I defined in
InlineViewer.py that accepts an additional parameter 'model'.

Now this all works perfectly until I change the selected viewer; I do
this by changing the viewer in a ListField parameter and clicking
'update' within kupu, whilst I can get the list of articles to update
in the MultiListField, via some
request.form.setdefault('viewer',form.get_viewers()[0][1]) trickery
(i.e If key 'viewers' is in the dictionary, return its value. If not,
insert key with a value of default and return default). I cannot get
the new form, i.e the one with a new list of items inside my
MultiListField, to submit from within kupu when I multi-select some of
these new items, if I click 'update' on this external source I recieve
an error saying:

'Form could not be validated, error message: Primary Items=You
selected an item that was not in the list.'

N.B. Primary items is my MultiListField

However my Primary Items list has updated, all of the items are
different to what they were before I clicked so why am I getting this
error message, plus it's not entirely helpful as there's nothing
output to the log.

Hope someone understands & can help

Cheers

--
Jonathan Bowlas
Web Support Officer
Media Services
University College London
Email: j.bowlas-hclig2XLE9Zaa/[email protected]