[Zope] Accessing default properties on addObjectForm

Sidnei da Silva sidnei@x3ng.com.br
Wed, 31 Oct 2001 10:13:26 -0200


Ok. Got it 70%. Just couldnt get about the constructor. Is this something=
=20
like the definition of manage_addProduct, that is done outside the class=20
definition because the class instance was not created yet?=20

See ya'.


Em Tuesday 30 October 2001 07:51, Dieter Maurer escreveu:
> Sidnei da Silva writes:
>  > I wish to look at default properties of my custom object when creati=
ng
>  > the addObjectForm.
>  >
>  > There is any way to do this? Something like:
>  > <dtml-var "Products.MyProduct.Custom.default_title">
>
> With
>
> 	<ObjectManager instance>.manage_addProduct[<Product Name>]
>
> you get the product dispatcher for your product.
>
> It has access to all product functions registered as "constructor"s.
> Now, "constructor" is a misnomer: You can register any function
> as a "constructor". Only the first "constructor" has a special
> meaning: it is used as target in the "add" list...
>
> This provides for the following solution:
>
>   Define a function "getDefaults" in your product
>   that returns a dictionary with the defaults.
>
>   Register is as a constructor (not the first one!).
>
>   Call it as "manage_addProduct['your product'].getDefaults()"
>   and use the default values you need.
>
>   Inside a constructor, you are already in the dispatcher context,
>   thus you can directly call "getDefaults".
>
>
> The factory dispatcher can access some specially declared f=FCrther
> objects in the product. Look at the code in "App.ProductDispatcher"
> (maybe "App.FactoryDispatcher", or something like that), for details.
>
>
> Dieter

--=20
Sidnei da Silva
X3ng Consultoria e Desenvolvimento Ltda.
sidnei@x3ng.com.br