On Sunday, December 6, 2015 at 9:49:49 AM UTC-5, Alessio Varalta wrote:
>
> This solution for me is not good. Ok in this case work but virtual field 
> allows only simple operation on the single filed of a table.
>

A virtual/method field can be as complex as you want it to be, and it does 
not operate on only a single field of a record. Rather, an entire record is 
passed to it. Furthermore, method fields can take additional arguments and 
of course have access to any global objects as well. Perhaps you are 
confused because the functions of virtual/method fields are often defined 
using lambdas, but you could instead define a separate function using "def" 
and then specify that function in the definition of the virtual field.
 

> I want class with function where i can use cicle and where i can use 
> another dal object..This is present for all frameworks 
> java-ruiby!!!!!!!!!!!!!!! for exmpale
>

I don't see how you would *need* a class for anything you want to do. You 
could simply create functions and pass the records to the functions (the 
DAL method fields are just a convenient way to attach such functions as 
pseudo-methods of the record). If you want a way to organize a set of 
related functions, you could still create a class and just define a set of 
static methods.

If you want an ORM, you might try the weppy ORM or SQLAlchemy or another 
framework altogether, but the web2py DAL is simply not an ORM and is not 
going to be. Nevertheless, it is not clear why you would need an ORM or 
classes to do what you want to do.
 

> Class Person extend Model
>   string name,
>   int age ecc..
>   function calculateNationOfPerson(id){
>     Nation nation=new Nation('all')
>     return nation.find_nation_of_person(id)
>   }
> }
>

I don't know exactly what the above is attempting to do, as the data model 
of nation is not clear (i.e., is "id" the id of the Person record, and if 
so, how does the Nation object use that to find the person's nation?), so I 
won't attempt any web2py code. But in principle, I don't see why you 
couldn't define a similar function and just pass a web2py Row object to it 
(and optionally, attach it as a method via a method field).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to