[Zope3-Users] how to set predefined values on newly created content object

2006-10-25 Thread Dominique Lederer
hello

i would like to set predefined metadata, when i create a new content object.

from my point of knowledge i could to this with a custom factory or by
listening to events.

is there any other possibility to to this, mabe somehow in the interface?

thanks
cheers
Dom
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] how to set predefined values on newly created content object

2006-10-25 Thread FB
Hi,

On Wed, Oct 25, 2006 at 05:11:44PM +0200, Dominique Lederer wrote:
 hello
 
 i would like to set predefined metadata, when i create a new content object.
 
 from my point of knowledge i could to this with a custom factory or by
 listening to events.
 
 is there any other possibility to to this, mabe somehow in the interface?

Taking into account that creating content objects can be done manually in
python, i'd use a view like this on the container of the new object:


predefined={
   'set1':{
  title:'something',
  otherfield:'foo',
  [...]
   },
   'set2':{
  title:'something else',
  otherfield:'bar',
  [...]
   },
   [...]
}

class CreateView(BrowserView):
   def __call__(self):
  if 'create' in self.request.form:
 if 'paramset' in self.request.form:
paramsetname=self.request.form['paramset']
if paramsetname in predefined:
   newobj=MyClass(**paramset)
   name=INameChooser(self.context)('',newobj)
   self.context[name]=newobj

In this case the view could i.e. react to some html-form which presents a
select name=paramset ... , returning either 'set1', 'set2' , [...] .

Regards,

Frank
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users