Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
I think so.

On Tuesday, 11 September 2012 09:42:05 UTC-5, rochacbruno wrote:
>
> for that cases shouldn't use _before_insert and _before_update triggers? 

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Bruno Rocha
for that cases shouldn't use _before_insert and _before_update triggers?

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
if the user does not pass a value it will still not trigger a computation 
because "" is not None, I think.

On Tuesday, 11 September 2012 09:17:02 UTC-5, Anthony wrote:
>
> I haven't followed this closely, but instead of specifying a "compute" 
> attribute for the field, could you instead specify the "default" attribute 
> as a function? In that case, the field will appear on forms -- if the user 
> enters a value it will be used, and otherwise the default value will be 
> computed. Of course, the record is not passed to the default function, so 
> instead the default function would have to directly access request.vars to 
> get the values of the other fields if needed (so this works with form 
> inserts, but not other inserts).
>
> Anthony
>
> On Tuesday, September 11, 2012 8:17:28 AM UTC-4, Alan Etkin wrote:
>>
>> On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:
>>>
>>> Please open a ticket and this will be easy to fix. 
>>>
>>>
>> Opened the ticket:
>>
>> http://code.google.com/p/web2py/issues/detail?id=980
>>
>> Now it was closed with status fixed, but:
>>
>> -AFAIK, fileld.writable still has no effect in computed fields. You 
>> cannot set a computed field as writable with crud so it shows the widget. 
>> You can with SQLFORM (by using the fields argument), however, entering 
>> blank inputs don't trigger the compute function server side.
>> -There's no modification of SQLFORM to process empty form fields as 
>> computable (in replacement of a previous or new record value)*
>> -SQLFORM doesn't set computed fields as empty on form creation (I think 
>> this should be the default behavior)*
>>
>> * Perhaps it would be necessary to add different checks by field type and 
>> a standard way of detecting a blank input in each case.
>>
>> Of course, it's possible to show a given widget and do further record 
>> processing in the controller without depending on the computed field 
>> facility, but with this changes, it would save that extra code and give a 
>> more clean and web2py like interface.
>>
>>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Anthony
I haven't followed this closely, but instead of specifying a "compute" 
attribute for the field, could you instead specify the "default" attribute 
as a function? In that case, the field will appear on forms -- if the user 
enters a value it will be used, and otherwise the default value will be 
computed. Of course, the record is not passed to the default function, so 
instead the default function would have to directly access request.vars to 
get the values of the other fields if needed (so this works with form 
inserts, but not other inserts).

Anthony

On Tuesday, September 11, 2012 8:17:28 AM UTC-4, Alan Etkin wrote:
>
> On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:
>>
>> Please open a ticket and this will be easy to fix. 
>>
>>
> Opened the ticket:
>
> http://code.google.com/p/web2py/issues/detail?id=980
>
> Now it was closed with status fixed, but:
>
> -AFAIK, fileld.writable still has no effect in computed fields. You cannot 
> set a computed field as writable with crud so it shows the widget. You can 
> with SQLFORM (by using the fields argument), however, entering blank inputs 
> don't trigger the compute function server side.
> -There's no modification of SQLFORM to process empty form fields as 
> computable (in replacement of a previous or new record value)*
> -SQLFORM doesn't set computed fields as empty on form creation (I think 
> this should be the default behavior)*
>
> * Perhaps it would be necessary to add different checks by field type and 
> a standard way of detecting a blank input in each case.
>
> Of course, it's possible to show a given widget and do further record 
> processing in the controller without depending on the computed field 
> facility, but with this changes, it would save that extra code and give a 
> more clean and web2py like interface.
>
>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
Now I see what you are trying to do. I do not consider this a bug. At this 
point this is the intended behavior. You want conditional computed fields 
depending on user input. If a value is provided use it, if one is not 
provided then compute it. That is not what compute fields were designed 
for. What you ask can be done but would break backward compatibility 
because it would require running the compute callback even if there is a 
value provided for the computed field and let the callback decide whether 
to override the provided value. For some an empty value "" is an acceptable 
value and for some it should trigger a computation. For me a field has a 
compute attribute the field is NOT editable in forms, it is only readable.



On Tuesday, 11 September 2012 07:17:28 UTC-5, Alan Etkin wrote:
>
> On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:
>>
>> Please open a ticket and this will be easy to fix. 
>>
>>
> Opened the ticket:
>
> http://code.google.com/p/web2py/issues/detail?id=980
>
> Now it was closed with status fixed, but:
>
> -AFAIK, fileld.writable still has no effect in computed fields. You cannot 
> set a computed field as writable with crud so it shows the widget. You can 
> with SQLFORM (by using the fields argument), however, entering blank inputs 
> don't trigger the compute function server side.
> -There's no modification of SQLFORM to process empty form fields as 
> computable (in replacement of a previous or new record value)*
> -SQLFORM doesn't set computed fields as empty on form creation (I think 
> this should be the default behavior)*
>
> * Perhaps it would be necessary to add different checks by field type and 
> a standard way of detecting a blank input in each case.
>
> Of course, it's possible to show a given widget and do further record 
> processing in the controller without depending on the computed field 
> facility, but with this changes, it would save that extra code and give a 
> more clean and web2py like interface.
>
>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Alan Etkin
On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:
>
> Please open a ticket and this will be easy to fix. 
>
>
Opened the ticket:

http://code.google.com/p/web2py/issues/detail?id=980

Now it was closed with status fixed, but:

-AFAIK, fileld.writable still has no effect in computed fields. You cannot 
set a computed field as writable with crud so it shows the widget. You can 
with SQLFORM (by using the fields argument), however, entering blank inputs 
don't trigger the compute function server side.
-There's no modification of SQLFORM to process empty form fields as 
computable (in replacement of a previous or new record value)*
-SQLFORM doesn't set computed fields as empty on form creation (I think 
this should be the default behavior)*

* Perhaps it would be necessary to add different checks by field type and a 
standard way of detecting a blank input in each case.

Of course, it's possible to show a given widget and do further record 
processing in the controller without depending on the computed field 
facility, but with this changes, it would save that extra code and give a 
more clean and web2py like interface.

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-06 Thread Massimo Di Pierro
Please open a ticket and this will be easy to fix.

On Wednesday, 5 September 2012 19:55:17 UTC-5, Alan Etkin wrote:
>
> El miércoles, 5 de septiembre de 2012 12:51:06 UTC-3, Massimo Di Pierro 
> escribió:
>>
>> yes please. Did this work in 1.99.7?
>>
>>
>  Ok, the current way is the same as in 1.99.7. SQLFORM output hides by 
> default computed fields.
>
> The problem was discussed in this threads before:
> https://groups.google.com/d/topic/web2py/f5T_6j7F3kA/discussion
> https://groups.google.com/d/topic/web2py/qzVIBFs2ZGI/discussion
>
> "...
> Note, by default computed fields are not shown in SQLFORMs, though you can 
> explicitly list them among the fields to be shown.
>
> Anthony ..."
>
> But I belive it's not documented in book, so if there's agreement with 
> having a visible computed field by default in forms the behavior could be 
> changed.
>
> One reason would be to allow the user to provide a value in a form before 
> inserting/updating the db record with a computed value. 
>
> Currently calling SQLFORM( filelds=[... "" ...]) 
> should show the field but with crud.create the computed field is hidden, 
> even if one specifies field.writable as True
>
>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Alan Etkin
El miércoles, 5 de septiembre de 2012 12:51:06 UTC-3, Massimo Di Pierro 
escribió:
>
> yes please. Did this work in 1.99.7?
>
>
 Ok, the current way is the same as in 1.99.7. SQLFORM output hides by 
default computed fields.

The problem was discussed in this threads before:
https://groups.google.com/d/topic/web2py/f5T_6j7F3kA/discussion
https://groups.google.com/d/topic/web2py/qzVIBFs2ZGI/discussion

"...
Note, by default computed fields are not shown in SQLFORMs, though you can 
explicitly list them among the fields to be shown.

Anthony ..."

But I belive it's not documented in book, so if there's agreement with 
having a visible computed field by default in forms the behavior could be 
changed.

One reason would be to allow the user to provide a value in a form before 
inserting/updating the db record with a computed value. 

Currently calling SQLFORM( filelds=[... "" ...]) 
should show the field but with crud.create the computed field is hidden, 
even if one specifies field.writable as True

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Massimo Di Pierro
yes please. Did this work in 1.99.7?

On Wednesday, 5 September 2012 09:07:41 UTC-5, Alan Etkin wrote:
>
> Does NOT seem to work.  computed field is still not visible.
>>
>>
> Same problem with this version: 2.0.7 (2012-09-04 18:33:19) stable 
> (updated with hg)
>
> I think we should open an issue in the google code page.
>
>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Alan Etkin

>
> Does NOT seem to work.  computed field is still not visible.
>
>
Same problem with this version: 2.0.7 (2012-09-04 18:33:19) stable (updated 
with hg)

I think we should open an issue in the google code page.

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-08-14 Thread Mandar Vaze
I have not set readable flag during db definition. Is it set to False by 
default, for compute fields ?

On Tuesday, August 14, 2012 6:16:20 PM UTC+5:30, rochacbruno wrote:
>
> in your controller..
>
> if request.args(0) == "view":
> db.table.field.readable = True
>
> grid = SQLFORM.grid(.)
>

Does NOT seem to work.  computed field is still not visible.

My current workaround : remove compute attribute, I can see it (I've then 
marked it as writable=False so that it is NOT editable in Edit form)
But I'm not happy with it.

BTW, I'm using Version 2.0.0 (2012-07-26 06:06:10) dev

-Mandar 

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-08-14 Thread Bruno Rocha
in your controller..

if request.args(0) == "view":
db.table.field.readable = True

grid = SQLFORM.grid(.)

http://zerp.ly/rochacbruno
Em 14/08/2012 09:37, "Mandar Vaze"  escreveu:

> I have a few fields that have "compute" attribute defined.  I've only
> inserted the records via script - compute fields are updated correctly.
>
> I have a SQLFORM.grid which shows a "join" query. When I explicitly select
> the computed field in the "fields" param - it is shown correctly.
> But when I click the "View" or "Edit" button for that record, the computed
> field does NOT show up.  (Same when I try to update the record via appadmin)
>
> I expect the computed field to definitely show up in the "View" form, and
> as "read-only" field in the "Edit" form.
>
> Why do the computed fields NOT show up in SQLFORM ?
>
> --
>
>
>
>

-- 





[web2py] compute fields do not show up in SQLFORM view form

2012-08-14 Thread Mandar Vaze
I have a few fields that have "compute" attribute defined.  I've only 
inserted the records via script - compute fields are updated correctly.

I have a SQLFORM.grid which shows a "join" query. When I explicitly select 
the computed field in the "fields" param - it is shown correctly.
But when I click the "View" or "Edit" button for that record, the computed 
field does NOT show up.  (Same when I try to update the record via appadmin)

I expect the computed field to definitely show up in the "View" form, and 
as "read-only" field in the "Edit" form.

Why do the computed fields NOT show up in SQLFORM ?

--