[Zope] accessing files using forms
alice
RobinHood42 at clickta.com
Sun Nov 23 05:25:14 EST 2003
I want to create a site which requires Monkeys to login.
Login is done via a form.
When a Monkey first creates an account she enters her "monkey_name" and
"password" and clicks "submit"
Now a script is called which creates a file with Id "monkey_name" containing
"password".
This bit works fine, no problem.
The problem is when the Monkey comes back to log into to their account.
They must type in their monkey_name and password.
Now, to check if the password is right, I have to open the file named
"monkey_name" and check if its content is the same as the password which the
monkey typed.
This is the script I wrote:
('monkey_name' and 'password' are variables which come from a form)
existing_monkeys=container.objectIds('File')
no_monkeys=len(existing_monkeys)
i=0
for i in range(no_monkeys):
if (monkey_name == existing_monkeys[i]):
if (container.monkey_name == password):
return "Your password is correct."
else:
return "Your password is incorrect."
else:
return "there is no monkey by that name."
The problem is: 'container.monkey_name'
If the script is run with monkey_name = Heidi.
What we want is the file: container.Heidi
But what Zope looks for is: container.monkey_name, which of course doesn't
exist.
I checked this by creating a file named Heidi and then a script named
cat_file, which contains a single line:
return container.Heidi
This returned the contents of the file Heidi without any complaints.
I then changed cat_file so that it took a parameter file_name
return container.file_name
If I then call this file cat_file(Heidi) it doesn't work :-(
What should I do?
More information about the Zope
mailing list