[Zope] The persistent variable

Børge Kjeldstad borge.kjeldstad at whiteflower.no
Fri Sep 5 12:43:06 EDT 2003


First:

again apologizing for having mixed up the words "vice" and "wise". I
truely
felt like an idiot and a no-brain. I hope I did not insult anybody. Mea
maxima culpa.
The bacground for my message was my eagernes to try to contribute, even
with my small
abilities, to the zope community which I find great and impressive!
That stupid word "vice", I must have gotten in my head from the
TV-series Miami Vice,
some years ago. To much TV is dangerous  :-)


Now to the problem:

I have a long time been fighting to find and establish something that I
think in
your language is called a "persistent variable". This variable, I wanted
to use
to personalize a website. Further, as my programming knowledge is so
severe, I was
looking for an easy way to do this, i.e. something that in pseudo code
would look like this:

set variable A
let A = 1

And then later use variable A like this:

if A = 1
do something


However, I did not find an easy way to do this. My next plan was then to
use cookies:

<dtml-call expr="RESPONSE.setCookie('guest', 'C')">

And this:

<dtml-if expr="REQUEST.has_key('guest', 'C')">

  <dtml-var site_map>

</dtml-if>


However this also did not work. It was as though my cookie disappeared.
Chris Withers then supplied mit with the following help:

"You could look in REQUEST.cookies to be more on the safe side. I wonder
what path is being set on
your cookies? '/' is  always a safe bet to  prevent wierdness like
this."

I have try to understand and togle with this, but maybe I still do not
understand the concept
of cookies and the REQUEST object. I still cannot make it work. However,
now I just read Dieter Maurers
message (Re: [Zope] Variables and SubFolders):

"Unless you do special things (modifiy a persistent object or store
something in a session object)
Zope forgets everything about a request as soon as it has been
completed. Read the Zope Book
(on zope.org) to learn something about sessions. Look for
"manage_changeProperties" to learn how
to modify properties of persistent objects.


My question is then: Is properties maybe the easiest way to establish
some "persistent variable"
to play with in zope? (Sessions will until some more time unfortunately
be to advanced for me.)


I have also on this topic received the following good advices:

- "The users are able to customise certain aspects of my application
then the preferences
are stored in a MySql database. When  the user logs in, the application
checks their user
id and password but also reads in their preferences. These are used to
apply style sheets
and other various bits of customisation." [Stephen Slack]

- "hint : Don't get started too much on DTML. Use python-scripts for
things like this, and
ZPT for presentation." [Geir Bækholt]


I know I should follow these advices, but until some more time, both
Python, zpt and sql databases are
unfortunately beyond my knowledge ;-)


Kind regards

Børge




More information about the Zope mailing list