Hi David,

Questions about using Zope are better answered at [EMAIL PROTECTED] since
they are off topic at [EMAIL PROTECTED], but since we're already here,
see below

On Mon, 2002-05-27 at 13:25, David Williams wrote:
> Hi all
> First-time posting from a Zope newbie ... hopefully someone can help 
> 
> I have defined a number of ClientProjects within Zope and I am trying to
> display these in a number of ways, filtered by object property values.
> So, for example, I want to display all client projects, or perhaps only
> those marketing projects, ie. where the marketing property has a value.
> 
> I display the client project titles in an HTML table, 3 per row, and for all
> projects this works OK - I use the sequence-number to control the table
> formatting, and the index sequence is unbroken when all objects are
> displayed.

I gather from this that you're doing all your selecting and filtering
inside the DTML

> 
> My problem arises when I have a sub-set of projects to display, because the
> sequence-number and sequence-index values still seem to relate to the full
> set of objects. So if the sub-set only comprises objects 7 & 8 (eg the only
> marketing projects), the sequence-number is not reset automatically to 1 & 2
> - they remain at 7 & 8. The same applies to the property sequence-index. So
> the way I check for the 3rd item in the collection, using sequence-number,
> does not work becuase the sequence number is not guaranteed to start at 1.

Exactly, dtml-in cannot guess you are ignoring some of the objects it
selected for you.

> I think I need a Python function to query and return a subset of objects,
> but how do I go about writing such an external method ? And how does it
> access my Zope ClientProject objects ?

A 'Script (Python)' will do nicely, no need to bother with an external
method.

> I also looked at using dtml-let and trying to keep a separate count ticking
> along, but seem to run into trouble with the variable's scope. 
> 
> Or is there an easier way around this that I have missed ?

No. As a rule, you should never try to select or filter objects inside
your dtml, since selecting and filtering is 'logic' not 'presentation',
and dtml is a presentation language, ill suited for doing 'logic'.

You should probably write a PythonScript that calls the same function
that you call to select the ClientProjects, but puts in a list only
those that are relevant for you. Then, in your templates, you can call
this function instead of the one you used to select all ClientProjects.

Information about how to write PythonScripts is left as an exercise to
the reader :-)

        Cheers, Leo

-- 
Ideas don't stay in some minds very long because they don't like
solitary confinement.



_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to