I do not like this notation but some time ago Robin proposed allowing funcitons to be passed to default and update
SQLField('totalprice',default=lambda record: record.quantity*record.price) This is actually easy and I could implement it tomorrow. I will think about your other proposal. My first reaction is "no" but I am also very tired today to think straight. Massimo On May 14, 10:53 pm, Steve Shepherd <sargs...@gmail.com> wrote: > While we are talking about this topic. > Is it appropriate to be able to put calculated fields into the model. > ie > > SQLFIELD('totalprice',eval('quantity * price')) > > or something. > > This way we can simply call these calculated fields in our views or selects. > I realise the selects would be harder as these objects would need to be > grafted on after the database portion. > > But using this sort of syntax we could develop very rich comprehenive > database models that utilise the database store and then the fast calc > abilities of python to provide an easy interface to keeping complex fields > in one place. > > The other usage could be a derived calc field. > > is > SQLFIELD('quarter',eval('Qtr' + sjsDate_to_quarter(created_at))) > > So this field could call a function called sjsDate_to_quarter() and return a > string like ie '"Qtr1 '09" or "Qtr4 '08" etc depending on the created_at > date. > > This is getting into the realms of the old data dictionaries that I used to > use in the early ninties. However they were very good for creating the DATA > MODEL not just the storage model that SQLDB does at the moment. > > PS. These > > On Fri, May 15, 2009 at 2:29 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Notice that by default that field has id "album_thumbnail" > > > so you can do form the view > > > <script> > > $(document).ready(function(){$('#album_thumbnail').class('multi');}); > > </script> > > > On May 14, 7:59 pm, Tito Garrido <titogarr...@gmail.com> wrote: > > > Is there a way to set attributes of a field on model? > > > > Like: > > > db.define_table('album', > > > SQLField('name',"string",length=50,default=""), > > > SQLField("thumbnail","upload",default="",autodelete=True,* > > > attr=dict(class='multi')*), <----- > > > SQLField("description","text",default=""), > > > SQLField("date","date",), > > > SQLField("ativo","boolean") > > > > anything like that? > > > > Thanks! > > > > Tito > > > > -- > > > Linux User #387870 > > > .........____ > > > .... _/_õ|__| > > > ..º[ .-.___.-._| . . . . > > > .__( o)__( o).:_______ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---