--
mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
db.Field('created_by_ip',readable=False,writable=False,default=request.client),
db.Field('created_on','datetime',readable=False,writable=False,default=request.now),
That would not work anymore, would it?
With care, runtime definitions could be left in models:
db.auth_user.reviewer.writable=db.auth_user.reviewer.readable=auth.has_membership('manager')
db.auth_user.speaker.writable=db.auth_user.speaker.readable=auth.has_membership('manager')
so the first two would become:
db.auth_user.created_by_ip.default = request.client
db.auth_user.created_on.default = now
Field default keyword should be banned or warned?
Best regards
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
from tables import dbdb._adapter.reconnect()
I think we should not change the way people use web2py today. At least
not by default. There are certain advantages in not having to worry
about this aspect.
The new feature will allow re-factoring of code to increase speed in
those cases when this is a critical issue.
The new feature may open the road to a web3py that is not backward
compatible and has similar syntax but different rules.
Massimo
default=lambda: current.request.now
Anyway, I think reconnect looks nice, knowing its caveats, is the best
approach so far.
BTW, db._adapter.reconnect() could be simplified to just db.reconnect()?
what happens if I call recoonect twice?
Best regards,
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
> lambdas will not help on i.e. readable and writable (and in general,
> it would be a big refactory, not only DAL)...
Here is a big problem now that you make me think about it. There is
only one db object shared by all threads.
If one thread sets
db.table.field.readable = True #
whit will affect the field attribute (in the example readable) for all
concurrent and subsequence requests. As usual there is a reason web2py
does what it does how it does it.
>
> Anyway, I think reconnect looks nice, knowing its caveats, is the best
> approach so far.
>
> BTW, db._adapter.reconnect() could be simplified to just
> db.reconnect()?
yes.
> what happens if I call recoonect twice?
nothing bad happens.
>
> Best regards,
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
>
>
>
> On Thu, Apr 12, 2012 at 12:24 PM, Massimo Di Pierro
> <massimo....@gmail.com> wrote:
>> yes for default:
>>
>> default=lambda: current.request.now
>>
>>
>>
>> we could make lambdas for for every field attribute but is it worth
>> it? It
>> will make everyhing slower compared to setting defaults in models
>> anyway.
>>
>> On Apr 12, 2012, at 10:21 AM, Bruno Rocha wrote:
>>
>> lambdas can solve this problem?
>>
>> default=lambda: request.now
>>
>> On Thu, Apr 12, 2012 at 12:13 PM, Mariano Reingart <rein...@gmail.com
>> >
>> wrote:
>>>
>>> It looks promising, but what about:
>>>
>>>
>>> db
>>> .Field
>>> ('created_by_ip
>>> ',readable=False,writable=False,default=request.client),
>>>
>>> db
>>> .Field
>>> ('created_on
>>> ','datetime',readable=False,writable=False,default=request.now),
>>>
>>> That would not work anymore, would it?
>>>
>>> With care, runtime definitions could be left in models:
>>>
>>>
>>> db
>>> .auth_user
>>> .reviewer
>>> .writable
>>> =db.auth_user.reviewer.readable=auth.has_membership('manager')
>>>
>>> db
>>> .auth_user
>>> .speaker
>>> .writable
db.table.field.readable = True #
from tables import db
db = db.connect()
This will bind a new db object (assuming connect create a new copy of
the database object).
Best regards,
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
On Thu, Apr 12, 2012 at 1:51 PM, Massimo Di Pierro
Anyway, copying should be faster than executing models.
Best regards,
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
On Thu, Apr 12, 2012 at 2:54 PM, Massimo Di Pierro
Why not use an extended Storage class? This storage can cope with two
values for each properties one value is thread local and the other is
not.
Behind the extended Storage object two bucket (dicts?) contain the
properties. One bucket is thread local the other is a singleton.
* Request start
The thread local bucket is instantiated at each request empty.
* Writing
When writing directly to the property the value is written in the
thread local bucket.
When the Field constructor is called the value is written in the
singleton bucket.
* Reading
A value corressponding to requested property in thread local bucket
overrides always singleton bucket.
* End of request
Thread local bucket reference is thrown away.
Could this work?
mic
Il 12 aprile 2012 20:49, Massimo Di Pierro
<massimo....@gmail.com> ha scritto:
Have you made performance measurements of DAL initialization? How expensive is it, and where does the time go?