The really ugly thing is that compute can silently fail and you could end 
up with None in the db table cell :(

2013. január 29., kedd 9:13:29 UTC+1 időpontban szimszon a következőt írta:
>
> Something about this issue? Should it work?
>
> 2013. január 28., hétfő 15:44:22 UTC+1 időpontban szimszon a következőt 
> írta:
>>
>> Hi!
>>
>> I wonder if somebody could help me.
>>
>> The
>>
>> definet_table('sometable',
>>     Field('otherid', compute=lambda r: r['id'])
>> )
>>
>>
>> doesn't work for me. :( Sould it work? With other than r['id'] it's 
>> working.
>>
>> Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17
>>
>>
>> 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a következőt 
>> írta:
>>>
>>> yes 
>>>
>>> On May 28, 3:44 am, Mathieu Clabaut <mathieu.clab...@gmail.com> wrote: 
>>> > I guess that one may want some more constraints on the autoincrement 
>>> field. 
>>> > For example, it shall begin at 100  for ecample. 
>>> > It may be because for example, before the application exists some 
>>> paper 
>>> > records where made which were referenced by number < 100) 
>>> > 
>>> > For such a problem, I've set up with: 
>>> > 
>>> > Field('ref_number', compute=lambda r: r['id'] + 100) 
>>> > 
>>> > Which I hope would eliminate the race solution as it is calculate upon 
>>> > insertion in the database... Is it the case ? 
>>> > 
>>> > -Mathieu 
>>> > 
>>> > On Thu, May 27, 2010 at 23:25, mdipierro <mdipie...@cs.depaul.edu> 
>>> wrote: 
>>> > > What is wrong with the default id field that web2py creates for 
>>> every 
>>> > > table? 
>>> > 
>>> > > On May 27, 3:16 pm, matclab <mathieu.clab...@gmail.com> wrote: 
>>> > > > Hello, 
>>> > > >  I'm finding this message in a thread from February... 
>>> > 
>>> > > >  I thought that autoincremented field would guaranty unicity in 
>>> the 
>>> > > > table. 
>>> > > >  I'm afraid the provided solution would allow two record to have 
>>> the 
>>> > > > same autonumber field (think about an access from two users at the 
>>> > > > same time). 
>>> > > >  I guess the autoincrement should be done on the DAL or database 
>>> side, 
>>> > > > inside a transaction.... 
>>> > 
>>> > > >  What do you think about it ? 
>>> > 
>>> > > > On 19 jan, 21:38, Thadeus Burgess <thade...@thadeusb.com> wrote: 
>>> > 
>>> > > > > max_id=   db(db.table.autonumber>1).select(db.table.autonumber, 
>>>  # 
>>> > > > > select all records, and only pull the autonumber column 
>>> > > > >                                 orderby=~db.table.autonumber, # 
>>> > > > > descending sort on the autonumber, (highest first) 
>>> > > > >                                 limitby=(0,1) # limit the query 
>>> and 
>>> > > > > only select the first record 
>>> > > > >                         ).first().autonumber # pull the first 
>>> record 
>>> > > > > from the web2py rows object, and get its autonumber member 
>>> > 
>>> > > > > db.table.autonumber.default = max_id + 1 # Set the table default 
>>> as 
>>> > > > > the last autonumber and incremented by one. 
>>> > > > > db.table.autonumber.writable = False 
>>> > 
>>> > > > > form = crud.create(db.table) 
>>> > 
>>> > > > > -Thadeus 
>>> > 
>>> > > > > On Tue, Jan 19, 2010 at 4:32 AM, ceriox <cer...@gmail.com> 
>>> wrote: 
>>> > > > > > thanks for the reply but i'm not a good web2py programmer ... 
>>> i 
>>> > > > > > writing my first real app 
>>> > > > > > you can write the code for my request? (i can't understand the 
>>> post 
>>> > > of 
>>> > > > > > your link) 
>>> > 
>>> > > > > > -- 
>>> > > > > > You received this message because you are subscribed to the 
>>> Google 
>>> > > Groups "web2py-users" group. 
>>> > > > > > To post to this group, send email to web...@googlegroups.com. 
>>> > > > > > To unsubscribe from this group, send email to 
>>> > > web2py+un...@googlegroups.com<web2py%2bunsubscr...@googlegroups.com> 
>>>
>>> > > . 
>>> > > > > > For more options, visit this group athttp:// 
>>> > > groups.google.com/group/web2py?hl=en.
>>
>>

-- 

--- 
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/groups/opt_out.


Reply via email to