add instance of ZClass as authenticated user
I have a Product called Course which contains a ZClass called ProjectSubmission (which resides in /Control_Panel/Products/Course). I want authenticated users to be able to add ProectSubmission instances. I have a web form that calls ProjectSubmission_add_py: REQUEST = container.REQUEST RESPONSE = REQUEST.RESPONSE pid = REQUEST.get('project_id') submission = context.ProjectSubmission.createInObjectManager(pid, REQUEST) submission.manage_addFile(id='',file=file_data) submission.manage_addFolder(id='Comments') submission.Comments.manage_addProperty('next_id', 0, 'int') propSheet = submission.propertysheets.ProjectSubmissionPropertySheet propSheet.manage_changeProperties(REQUEST) propSheet.manage_changeProperties(file_name=file_data.filename) propSheet.manage_changeProperties(submission_date=DateTime()) REQUEST.RESPONSE.redirect(submission.absolute_url()) This works fine if the user has manager/owner permissions at root level, but I want it to work for a user that is simply authenticated at the container level. If I try and execute the script simply as an authenticated user at container level, I get the error: Error Type: AttributeError Error Value: ProjectSubmission Could someone advise me on how I should can change the script and/or the ProjectSubmission and Course properties and security settings so that authenticated users can add PrjectSubmissions Thanks, John Hunter
John Hunter writes:
I have a Product called Course which contains a ZClass called ProjectSubmission (which resides in /Control_Panel/Products/Course). I want authenticated users to be able to add ProectSubmission instances. ... This works fine if the user has manager/owner permissions at root level, but I want it to work for a user that is simply authenticated at the container level. If I try and execute the script simply as an authenticated user at container level, I get the error:
Error Type: AttributeError Error Value: ProjectSubmission
Could someone advise me on how I should can change the script and/or the ProjectSubmission and Course properties and security settings so that authenticated users can add PrjectSubmissions Did you map the "Add ProjectSubmission" permission correctly?
You may also remap the "Create class instance" permission in the ZClass's "Define permissions" tab. Dieter
"Dieter" == Dieter Maurer <dieter@handshake.de> writes:
Dieter> Did you map the "Add ProjectSubmission" permission Dieter> correctly? I have tried 'View' and 'Add ProjectSubmissions', but get the same error. I think it is a path/acquisition error rather than an ownership/security issue because even if I try to use the add form http://somehost.com/some_folder/ProjectSubmission_addForm as a manager/owner in 'some_folder' I get the same problem. Further, if I call the add form from the manager interface, I can successfully add the class instance. So I think it has something to do with the context variable in python not seeing the ProjectSubmission class/ The ProjectSubmission_addForm and ProjectSubmission_add_py are located at http://somehost.com/Control_Panel/Products/Course/ProjectSubmission_addForm http://somehost.com/Control_Panel/Products/Course/ProjectSubmission_add_py and the error is occurring in the following line of ProjectSubmission_add_py: submission = context.ProjectSubmission.createInObjectManager(pid, REQUEST) What it looks like to me is that the Course Product (which contains ProjectSubmission) is not acquired by the 'context' of validated (or manager/owner) users at the some_folder level (eg, users residing in a acl_users folder in some_folder). Dieter> You may also remap the "Create class instance" permission Dieter> in the ZClass's "Define permissions" tab. I have tried various permutations (eg, associating 'Access Contents Information' with 'Create Class instance' in the ProjectSubmissions 'Define Permissions' tab, always with the same result and error described in the OP. Any more suggestions will be much appreciated, John Hunter
John Hunter writes:
... I think it is a path/acquisition error rather than an ownership/security issue because even if I try to use the add form
http://somehost.com/some_folder/ProjectSubmission_addForm
as a manager/owner in 'some_folder' I get the same problem. Which one?
The above should give you a "Resource not found" error. That's because "some_folder" does not have a "ProjectSubmission_addForm" nor can it acquire one. The correct URL would be http://<host>/<folder>/manage_addProduct/<product>/ProjectSubmission_addForm
Further, if I call the add form from the manager interface, I can successfully add the class instance. So I think it has something to do with the context variable in python not seeing the ProjectSubmission class/ In Python, it would look something like:
context.manage_addProduct[<your product's name (a string)>].ProjectSubmission_addForm(context,container.REQUEST) Not sure, how often this has already been discussed (an FAQ). Do you want to write a HowTo (but probably there already is one)... Dieter
"Dieter" == Dieter Maurer <dieter@handshake.de> writes:
Dieter> http://<host>/<folder>/manage_addProduct/<product>/ProjectSubmission_addForm Beautiful. Thank you very much, works like a charm. John Hunter
On Thu, May 02, 2002 at 01:45:33PM -0500, John Hunter wrote:
"Dieter" == Dieter Maurer <dieter@handshake.de> writes:
Dieter> http://<host>/<folder>/manage_addProduct/<product>/ProjectSubmission_addForm
Just in case, Dieter is one of the real Zope good guys. There are many others I put in this category. But for shear willingness to answer questions day after day, Dieter deserves special praise. Jim Penny
On Friday 03 May 2002 02:57 am, Jim Penny wrote:
On Thu, May 02, 2002 at 01:45:33PM -0500, John Hunter wrote:
> "Dieter" == Dieter Maurer <dieter@handshake.de> writes:
Dieter> http://<host>/<folder>/manage_addProduct/<product>/ProjectSubmission_addF orm
Just in case, Dieter is one of the real Zope good guys. There are many others I put in this category. But for shear willingness to answer questions day after day, Dieter deserves special praise.
Jim Penny
and, as norman drabble would've said - Dieter deserves four thumbs up! http://www.comics.com/comics/drabble/archive/drabble-20020501.html -- http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org If you SMELLLL...
participants (4)
-
Bakhtiar A Hamid -
Dieter Maurer -
Jim Penny -
John Hunter