This env can only live within a request because:
- it is not serializable
- we do not want it shared, for security
- there is no overhead in creating the environment
Anyway, I am not sure I understand the question.
> --
> 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/
This is certainly over my head. Did you see the new features in trunk where you can put your models in folders in order to minimize how many models are executed on each request?
>
> May be I'm the only one who think performance is a requirement?
>
Not at all. I am on the road with limited ability to check emails and code. I will look at your proposal closer during the week end.
Just one question @nihil on the porposed code. It is common to use
models as equivalent of jee filters or interceptors, so that
the incoming request is manipulated before it arrives to the handling
function in the controller. For instance I could
put the following in db.py (just a stupid example never use it!):
superuser = False
if auth.user.id < 100 and (session.login_time -
datetime.datetime.now()).seconds < 3600:
superuser = True
Would something like the above still work?
mic
2011/5/20 Stifan Kristi <steve.van...@gmail.com>:
I think don't run models for every request is a good improvement, (why
redefine data models in every request?
IMHO that's the java way: you would end up putting decorators all over
the code ;-)
You cannot put a decorator for the whole controller, but having
dynamic models you
can do the following:
if request.controller=='mycontroller':
do stuff
MVC as intended in most jee frameworks have a static model hence limited.
Of course 90% of the code in /models under web2py is made of constants so
it is silly to run that code each time. For instance table definition
can be skipped under "normal"
conditions...
So the question is: how do we split constant from dynamic environment?
Could we add a new dir contaning constant models?
mic
2011/5/20 nihil <nihi...@gmail.com>:
MVC as intended in most jee frameworks have a static model hence limited.--
hi Pierre can i ask you what your custom importer do?
--
web2py application code is executed on every request, so you want to minimize this amount of code. Here is what you can do:
migrate=True then set all your tables to migrate=False.cache.ram as much as you can but make sure to use a finite set of keys, or else the amount of cache used will grow arbitrarily.session.forget(response) in all controllers and/or functions that do not change the session.Mind that DAL already does connection pooling. The issue is what triggers the pooling. Right now a call to DAL(...).
Even without pooling if db=DAL(...) is executed only once there are two problems:
- if there are no requests for a long period of time, the db engine closes the connection. Who restarts it?
- if there are two concurrent connections and there is one db connection the requests have to be serialized. This would move the handling of concurrent database requests from the database to web2py. Not a good idea. db=DAL(...) and table definitions should not in the pre-defined environment.
How about having a folder called models/static and everything in there is executed once and only one? ... db=DAL(...) and table definitions should not in the pre-defined environment.
2011/5/22 Massimo Di Pierro <massimo....@gmail.com>:
> Even without pooling if db=DAL(...) is executed only once there are two problems:
> - if there are no requests for a long period of time, the db engine closes the connection. Who restarts it?
I solved this some time ago, I sent the patch. If you can take time
to look into it. It does not add overhead in case the connection
is already up (i.e. it does not add extra sql instructions). It also
manages postgresql better...
mic
The pool manager must be called to action when:
1) tables are created/migrated
2) transaction is opened
3) transaction is closed
1,2,3 are not care of average application code.
mic
2011/5/22 Anthony <abas...@gmail.com>:
Talking about WSGI... IMHO part of DAL work (pooling + transaction
management) would fit nicely as a WSGI shell around web2py
mic
2011/5/21 Pierre Thibault <pierre.t...@gmail.com>:
Massimo
On May 22, 2011, at 8:19 AM, nihil wrote:
Do you have any benchmark numbers?
I would like to see a test case and some benchmarks. I am not convinced yet this is worth the trouble but could just be I do not fully understand what you propose.
Massimo
massimo
I once benchmarked this. I did not see any improvement. Do you have data?
> - request,response, and session will be proxied to current thread
request,response, session (a little slower but for compatibility
reasons)
How is this different then current.request which is already in trunk?
> - session object lives in RAM(no marshaling ,file read and write
needed)
This is not a good idea. web2py must be able to handle multiple concurrent processes and they cannot share objects in ram.
As should allow sessions in cookies eventually (digitally signed, like Flask) but not in ram.
- static and application-wide models (no table definition needed)
This is the part I do not fully understand because I would not know how to make it work myself without breaking lots of stuff, including connection pooling, and dealing with database timeouts and I am not convinced there is a real benefit. There is the part that needs a working proof of concept, perhaps with bottle.
i think you're right but i didn't undertand how.
please suggest.
On 23 Mag, 22:37, Pierre Thibault <pierre.thibau...@gmail.com> wrote:
> I hope you are not forgetting the concerns about having an interceptor
> mechanism or a hook for aspects oriented programming.
> --
>
Massimo
i undertand behavior i undestand what is AOP, but not understand how
you can put it into web2py.
baybe a sort of supermodel (a model that acts in each applications)?
You can write a WSGI layer that logs incoming connections. Easier than Java bloat ...
Mic
You can write a WSGI layer that logs incoming connections. Easier than Java bloat ...
Mic