For exmpale weppy give this opportunity to create

class Post(Model):
    tablename = "post"

    fields = [
        Field("author"),
        Field("title"),
        Field("body"),
        Field("slug")
    ]

    representation = {
        "body": lambda row, value: markdown(value)
    }

    validators = {
        "title": IS_NOT_EMPTY(),
        "body": IS_NOT_EMPTY()
    }
   
     @computation('slug')
    def make_slug(self, row):
        # custom code to create the slug


Web2py not?


On Saturday, 5 December 2015 17:37:01 UTC+1, Alessio Varalta wrote:

> Hi, I have a problem..I have controller with too much code..So I want to 
> use the logic of Java or Ruby. Have a class that represent the object of my 
> database and implement function in this class and use this class in the 
> Controller. The problem is that I try the VirtualField a part of web2py 
> guide 
>
> in db file I create
> class Layer_scheda(object):
>         def change_name(self,nome):
>             self.nome=nome
>             self.update.update_record() 
>             returnTrue
>
> db.order_item.virtualfields.append(Layer_scheda())
>
> after in my Controller i try 
>
> order_item.change_name
> or order_item.change_name() but I have problem   change_name is not defined
>
> I study the guide and there isn't any point to make this part of 
> works..For me is strange because the class model is a part of framework 
> logic that is present in all the big framework Java,Rails so I don't 
> understand. There is a a solution of my problem of use virtual field or 
> there is a esay method for this problem?
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to