[Zope] Help with DTML
R. David Murray
R. David Murray" <bitz@bitdance.com
Sat, 11 Mar 2000 18:27:13 -0500 (EST)
On Sat, 11 Mar 2000, Tom Wright wrote:
> 1) using the subdirectory RegisteredUsers, check if a ZClass object of type
> Player exists in the RegisteredUsers directory with an id that matches that
> in the Request ( a form from the client ). This currently doesnt work for
[...]
> <dtml-with RegisteredUsers>
> <dtml-if REQUEST['new_user_name']>
> User currently exists
I think I see what you are trying to do here, but I don't think
DTML works that way. The array reference is a python expression,
so you have to go to an expr. But if you just enclose the above
in quotes you'll be testing whether or not REQUEST has a non-null
new_user_name variable.
One way to do what you want would be (tested):
<dtml-with RegisteredUsers>
<dtml-if "new_user_name in objectIds(['Player'])">
User currently exists
[...]
REQUEST is on the name space stack, so new_user_name will be found
without having to refer to REQUEST explicitly. 'objectIds' returns
a list of object ids, and the argument gives a list of meta_types
of the Ids to return. So this call results in a list of just the
Player ids. The python 'in' operator checks to see that the
left hand string is a member of the list of strings on the
right hand side.
Note: you'll run into some interesting issues with your planned
setup of the number of players gets large (say that large is several
hundred) due to practical limits on the capacity of Zope Folders.
> Is there an easier/better way of achieving what i am trying to do, or am i
> barking up the wrong tree ?
Well, you may want to take a look at GUF and perhaps the (RealSoonNow) the
Portal Toolkit, but they may both be overkill for your application.
It depends on just what functionality you are trying to put into
your Player objects.
> nage_changeProperties(
> user_name = REQUEST['new_user_name'],
> password = REQUEST['new_password'],
> player_name = REQUEST['new_player_name'],
> planet_name = REQUEST['new_planet_name'],
> email = REQUEST['new_email'],
> )" >
I forget which How-To I got this out of (maybe the CatalogAware
How-To?), but I think the call to update the property list function
name is (copied from some of my own code):
propertysheets.<your-sheet-name>.manage_changeProperties
Since your cut and paste dropped some stuff there, though, that may
be what you have, in which case I don't know why your properties
aren't getting updated. Though you might try adding the _.None,_
arguments to the beginning of the call.
--RDM