Anahide Tchertchian wrote:

> CP Hennessy wrote:
>> Hi,
>>  I've a class which has several fields, some of these
>> fields are filled from a database and some are filled
>> in by the user. I'm trying to figure out what is the
>> correct way in CPS to do this.
>> 
>> My user enters a clientId and "Add" which causes data
>> to be retrieved from a database for a few fields. The
>> user should be presented with a form where the relevant
>> fields are populated from the database info and where
>> several other fields should be entered by the user
>> before the new object is created.
>> 
>> I'm currently basing my new class on CPSDocument and
>> I'd really like to know what I need to change to get
>> the behaviour mentioned above. If anyone can point me
>> at a simple example, then it would be even better.
> 
> Hi,
> 
> It looks like you could achieve the same behaviour by defining default
> expressions on the fields that are supposed to be populated from your
> database. Maybe you just have to define a way to access this database in
> your application, but it does not have to be on your document class.

Thanks for the hint Anahide.
I've tried to use it but have one problem. Using the following :
  'default_expr': 'python:portal.REQUEST.widget__name',

in the schema works to initialize the data in the form. This expression is
used when populating the creation form AND when the object is actually
being created.

However the problem with this approach is that if this data is for a field
that should be readonly (i.e. the data coming from the database should not
be changed), then there is no field widget__name :(

What is the correct approach for this ?
To create a new "create_form" for my class ?

Thanks
CP Hennessy

_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to