[Zope3-Users] Error when calling addform

Dominique Lederer dominique.lederer at inode.at
Sun Feb 18 12:20:42 EST 2007


Florian Lindner schrieb:
> Am Dienstag, 13. Februar 2007 12:04 schrieb Stephan Richter:
>> On Monday 12 February 2007 15:56, David Johnson wrote:
>>> Many people have offered approaches.  I find the simplest and  
>>> cleanest approach for declaring interfaces is as follows:
>> The cleanest way, in my opinion, is just not to use the addform directive
>> altogether. zope.formlib is the wildly accepted successor.
> 
> Ok, I've done it now if the formlib.
> Do I really have to create and set all fields manually?
> 
> class BlogCommentAddForm(form.AddForm):
>     form_fields = form.Fields(IBlogComment)
>     
>     def create(self, data):
>         comment = BlogComment()
>         comment.name = data["name"]
>         comment.email = data["email"]
>         comment.content = data["content"]
>         return comment
> 
> If I just omit create is complains that the function must be implemented. Can 
> this be done easier?

you can do this with

def create(self, data):
        comment = BlogComment()
	form.applyChanges(comment, self.form_fields, data)
	return comment

hth Dominique


More information about the Zope3-users mailing list