[Zope] Re: SUF Problems

Chris Withers chrisw@nipltd.com
Wed, 20 Nov 2002 11:43:50 +0000


andy toenz wrote:
> Hi Chris,
> 
> 1. I can't add ZSQL Methods because I've only one user which is the 'emergency'-user. So I'm not able to add a Method
> X Error Type: EmergencyUserCannotOwn
> X Error Value: Objects cannot be owned by the emergency user

I don't think that's a SUF problem. Why have you only got access to the 
emergency user? Are you trying to use SUF as your top-level user folder?
If so, get the ZSQL methods working before you delete the old user folder ;-)

> 2. When I define a ZSQL Method e.g.
> X Id: get_users_from_db
> X Query Template:
> X select m_admin_uid, m_admin_pwd, rules from user;
> 
> How can I use this ZSQL method (get_users_from_db) together with SUF ?

You should read the readme.txt file in the SUF distribution.

The method needs to be called 'getUserDetails', not 'get_users_from_db'.

It also needs to take a parameter called 'name'

then, the select would be something like:

SELECT m_admin_uid as NAME, m_admin_pwd as PASSWORD, ROLE FROM user WHERE 
m_admin_uid=<dtml-sqlvar name type="string">

Now, you'll notice that you probably don't have a column called 'ROLE'.

What I do is have a seperate table mapping user names to roles, something like:

Table:roles
NAME  ROLE
chris Manager
andy  Manager
andy  Member

Do you see what I mean?

Then the select becomes:

SELECT m_admin_uid as NAME, m_admin_pwd as PASSWORD, ROLE
FROM user LEFT JOIN roles
ON user.m_admin_uid=roles.NAME
WHERE m_admin_uid=<dtml-sqlvar name type="string">

cheers,

Chris