[triangle-zpug] making createObject available to anon
Stephan Altmueller
stephan_altmueller at unc.edu
Thu Aug 3 16:21:54 CEST 2006
Hi,
If I understand the problem correctly you want to have anonymous users
fill out a form and then in the form script create some content.
I did that for a site where people could submit comments on an article.
It's basically a modified version of the the createObject code.
The steps I took are most likely overkill, but it should still contain
pointers.
Here is the relevant portion of the form script:
--------------- CODE start --------------------------------------
...
type_name = "Comment"
id=context.generateUniqueId(type_name)
try:
# add the comment
context.addComment(id, subject, comment)
....
--------------- CODE end --------------------------------------
and here is the method (in the Article class) that actually adds the
"Comment" instance:
--------------- CODE start --------------------------------------
def addComment(self,id,subject,body):
# make sure the id is autogenerated
pu = getToolByName(self, 'plone_utils')
if not pu.isIDAutoGenerated(id):
raise "addComment: ID is not autogenerated !"
new_id = self.invokeFactory(id=id, type_name="Comment")
if new_id is None or new_id == '':
new_id = id
# set the values on that attribute
o=getattr(self, new_id, None)
o.setCommentsubject(subject)
o.setBody(body, mimetype='text/plain')
--------------- CODE end --------------------------------------
You can most likely fold that into the form script. You will probably have
to give that script a Manager proxy role.
I also created a custom work flow for the Comment class where the
initial state
is private. A UML diagram of that is attached.
- Stephan
Jim Allman wrote:
> On Aug 3, 2006, at 8:43 AM, Chris Calloway wrote:
>> I think Frank is trying to authorize the creation of new objects. I
>> don't have time to look this week. Although it sounds like a job for
>> custom permissions, maybe workflow, at least some wiring on the
>> object factory.
>
> I see. Then workflow does sound like the ticket.
>
> Could you could set the "natural" permissions on the object type to be
> lax, so anyone can create it, but they're immediately tightened up by
> workflow..?
>
> =jimA=
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> . . . . . . . . . . . . . . . .
> Jim Allman
> Interrobang Digital Media
> http://www.ibang.com/
> (919) 649-5760
>
>
> _______________________________________________
> triangle-zpug mailing list
> triangle-zpug at starship.python.net
> http://starship.python.net/mailman/listinfo/triangle-zpug
--
--------------------------------------------------------
Stephan Altmueller
Applications Analyst
OASIS - Office of Arts and Sciences Information Services
University of North Carolina at Chapel Hill
Phone: 919-962-4205
Email: stephan_altmueller at unc.edu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: comment_workflow.png
Type: image/png
Size: 2439 bytes
Desc: not available
Url : http://starship.python.net/pipermail/triangle-zpug/attachments/20060803/182a583c/comment_workflow.png
More information about the triangle-zpug
mailing list