[Zope] zope basics

Rik Hoekstra rik.hoekstra@inghist.nl
Thu, 23 Nov 2000 17:47:56 +0100


Using Zope, I have managed to put together a nice site for friends to create
folders, pages and upload images, etc. But there are some fundamentals that
are eluding me.

I am able to 'register' a new user through a form to create a new acl_user.
But I cannot figure out how to let them login again using that name/password
and be an AUTHENTICATED_USER with that acl_user name--other than Anonymous
User. I tried to look at AUTHENTICATION_PATH, but my browser wants to
download it--an empty file.

[rh]If you have an object to which an Anonymous user has no access, an
authentication dialog automatically pops up. If you want a real login page,
just give it restricted access, but you could any page in a restricted area
for that. Using basic authentication this is a bit clumsy. There are more
sophisticated authentication mechanisms available for Zope.

I can manage objects using dtml pretty well: create, delete, edit. If I can
figure out how to authenticate a user, I would like to be able to add a
property to new objects as they are created: (createdby:AUTHENTICATED_USER)
so that I can control which objects get a checkbox (for delete) and an edit
link for a particular user. InOtherWords, if a user creates a object, I want
that same person to be able to go back and delete or edit that object.
Anyone else can see it, but they won't be able to delete or edit the object.

[rh]Objects normally get an Owner property (under the ownder tab). In this
case you could use something like (untested)

  <!--#if "AUTHENTICATED_USER.has_role('Owner',this())"-->
  You own this Folder.
  <!--#/if-->

this is taken from http://www.zope.org/Documentation/How-To/DetectRoles


This confuses me: manage_addProperty takes (id, value, type and optionally
REQUEST) as args. What is the id? Is it the ID of the object that you want
to add a property to? Or is it the ID of the new property? The Zope Quick
Reference doesn't say, but I think it is the property's ID.

[rh]It's the id of the property. Remember you call the method on an object
(or rather in the context of an object) with an id, so passing the
manage_addProperty the object's id once again would be superfluous.


I am trying to learn from looking at the Zope interface work. After
submitting the add property form, the page url looks like this:
appRoot/objectname/manage_addProperty. I see that the objectname is behind
manage_addProperty, I know the value, id and type are passed in the REQUEST.
How can I take advantage of this following a line like:

<dtml-call expr="manage_addImage(id=title, file=file, title=title)">

...to add a property to that image?

several options (just in dtml, all not tested):

<dtml-call expr="<your_image>.manage_addProperty(id=<yourid>,
value=<yourvalue>, type=<yourtype>)">

<dtml-with <your_image>>
   <dtml-call expr="manage_addProperty(id=<yourid>, value=<yourvalue>,
type=<yourtype>)">
</dtml-with>

Note that if the REQUEST has the right values (from a form)   you can
alternatively also just pass it the REQUEST , the manage_addProperty method
will know how to take the variables from the REQUEST.

I found some useful tidbits at a howto page on Zope site somewhere. But it
was pretty sparse and just whetted my appetite. I am coming from NT/IIS ASP
world. So I am struggling.

[rh] But you have much to win ;-)

Can anyone point me to a richer source of samples that will help me get up
this hill?

There are a faq and a ZSnippets on zdp.zope.org which may provide some more
examples. Also look at the many howtos. The documentation section of the
zope site should be making them more easily accessible in some time.

hth

Rik