[Zope-dev] varibable defining and using

josh on josh@zesty.com
Wed, 10 May 2000 12:08:19 +0100


Hello,

I am no programmer, but I am dangerously lurking in the world of zope. So
Newbie alert!  Please bear with me if this is an inappropriate palace to
post this.  I am more than happy to take any behavioural tips as well as
progromattic.  I have been scouring manuals and documents for weeks before I
have come to bug real people!

I have started off with what I thought would be a pretty simple problem in
order top get my head around zope.  I want to make a product that allows
users to collaboratively build a story line by line.  When the user enters
the product they are given a choice of alternative first lines left by other
users, and they can choose one then be presented with a second set of lines
which have been added to the first, of which they can choose any one... and
so on.  At any stage if they are not happy with a line they can submit their
own.

I have tried building this in Zope using the zodb, and using sql.
In both cases I have run into similar problems.

In zodb, lines get submitted, but do not seem to get catalogged til I
manually force the catalog to update, as far as I can tell they are class
aware.

The half working vbersion of this can be seen at:

http://194.80.197.3:8080/addaline/

I guess I want to have something that forces the catalog to uppdate itself,
I have been using:

<dtml-call reindex_object> in the method of the product that adds new class
instances of the lines

My second problem has been keeping a record for the user of the story as
they have selected it up to that point.

I thought of a structure which names the lines with a position.  The first
lines are named with just one letter ie "a" or "b".  If a user adds another
line to line "a" it will have the position "ab" and so on.  I know that
there are a limited number of chars available and I guess that was a problem
I was going to try and sort out later.

This way any line contains its history in its position.  In the sql version
if I do a query on a line 5 deep like this:

select content
from lines
where
position = '<dtml-var position size=1 etc="" >' OR
position = '<dtml-var position size=2 etc="" >' OR
position = '<dtml-var position size=3 etc="" >' OR
position = '<dtml-var position size=4 etc="" >' OR
position = '<dtml-var position size=5 etc="" >'

I get all the lines up to that point.  Of course this is hard wired.  I'd
like to have it so that it works something like this:

select content
from lines
where
<dtml-call "REQUEST.set('leng',_.len(position))">
<dtml-call "REQUEST.set('n', 0)">
<dtml-loop while n lt leng>
<dtml-call "REQUEST.set('n', n+1)">
position = '<dtml-var position size=n etc="" >' OR
</dtml-loop>
position = '<dtml-var position size=leng etc="" >'

(The one one the end doesn't have an OR so I left it out of the loop...)

OK so I shudder to think how that looks to someone who knows python and
zope!!!
But I'd be so happy to see how it is meant to look.

I haven't tried looping, so excuse my tag for it, I know that is wrong, but
I have tried setting a varible based upon the length of a string, this
worked in a normal DTML document:

<dtml-call "REQUEST.set('leng',_.len('werte'))">
<br>
leng=<dtml-var leng>

but when I use it in a SQL query like this:

<dtml-call "REQUEST.set('leng',_.len('werte'))">
select content
from lines
where
position = '<dtml-var position size=1 etc="" >' OR
position = '<dtml-var position size=2 etc="" >' OR
position = '<dtml-var position size=3 etc="" >' OR
position = '<dtml-var position size=4 etc="" >' OR
position = '<dtml-var position size=leng etc="" >'

it doesn't work.

I am sure these are just the beginnings of my problems.  This has been a
steep learning curve, and I am determined not to give up.  After I finish I
would like to give a go at writing it up and add to the oyther useful
documents out there.  I am convinced that this is a great project to start
learning zope with.

Thanks for your time.

Josh On

www.crd.rca.ac.uk/~josh