Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Thadeus Burgess
I like the idea of an execmodels.py file, it could create a list of model names to execute.. Not yaml or cfg because that means web2py would require yet another library Massimo, tell me where this code *should* go and I will work on it since this is a very important feature to me. Lets draft up a

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Doug Warren
One thing I thought about was to have the models loading wrap around an exception holder in run_models_in something like delay_process = [] for model in models: ... try: restricted() except RequirementMissing: delay_process.append(model) while 1: new_delay_process

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
Here is my proposal: define the following: request.models=( ('*','db.py'), ('*','model1.py'), ('*','model2.py'), ('default','model3.py'), ('default/a,default/b','model4.py'), ) it specifies the order in which models should be executed. For each row, the first item specifies whether the model

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
one we agree with the syntax, this is easy. The main issue is making sure it works with bytecode compiled models. On Jun 10, 11:20 am, mdipierro mdipie...@cs.depaul.edu wrote: Here is my proposal: define the following: request.models=( ('*','db.py'), ('*','model1.py'), ('*','model2.py'),

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Thadeus Burgess
What if I needed two controllers to share the same model? Would I then place two definitions in request.models? Not 0.py that is not a valid python filename. Python modules/variables cannot start with numbers. how about just a simple exec.py that gets loaded before everything? -- Thadeus

[web2py] Re: Separating models into their own files

2010-06-10 Thread Yarko Tymciurak
On Jun 10, 11:20 am, mdipierro mdipie...@cs.depaul.edu wrote: Here is my proposal: define the following: request.models=( ('*','db.py'), ('*','model1.py'), ('*','model2.py'), ('default','model3.py'), ('default/a,default/b','model4.py'), ) it specifies the order in which models should

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Thadeus Burgess
How will the exec_models.py be formatted Could it potentially be executed in an environment given a list, and append or overwrite this list with the model definitions exec_models = [ 'settings.py', 'db.py', 'auth.py', 'tag.py', 'post.py', 'comments.py', 'menu.py', 'other.py', ]

[web2py] Re: Separating models into their own files

2010-06-10 Thread Yarko Tymciurak
... this all _sounds_ great, but for one thing: It places a dependency (an import or setup list) FAR AWAY from where it should be declared!!! This _will_ (sooner or later) become a problem. Why not have something _less global_ (why _one_ config file???), and more component / containment

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Doug Warren
That's kind of what i was getting at with my suggestion listed above in some pseudocode. Let the model try to grab it's required modules if it can't find one it'll just raise an exception and it'll be tried again later. Eventually all dependencies that are solvable will work themselves out...

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
If we are going to work on this we may as well solve a different problem. Executing models take time. If you have 500 tables each defined it its own file, it takes lots of time. Yet not all actions need all tables so we may want to implement a dependency not just among models but among actions

[web2py] Re: Separating models into their own files

2010-06-10 Thread Christopher Steel
You need to pay attention to order, but you can always use variables... For more examples see Massimo's auditing slice at web2py slices and make sure to check out the comments... you can var out fields, table headers and probably more stuff as well like auditing fields... Here is a working

[web2py] Re: Separating models into their own files

2010-06-10 Thread Yarko Tymciurak
On Jun 10, 3:44 pm, Doug Warren doug.war...@gmail.com wrote: On Thu, Jun 10, 2010 at 10:53 AM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: More discussion, thoughts? (maybe this should move to the web2py developer's thread?) As my request is still 'pending' I'd ask to keep the

[web2py] Re: Separating models into their own files

2010-06-10 Thread Yarko Tymciurak
On Jun 10, 3:44 pm, Thadeus Burgess thade...@thadeusb.com wrote: This is what I desire from this Web2py applications to be importable python modules Along with [A] your models immediately become python modules that you can import. This solves my need to share models between web2py apps.'

[web2py] Re: Separating models into their own files

2010-06-10 Thread Yarko Tymciurak
On Jun 10, 1:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: If we are going to work on this we may as well solve a different problem. Executing models take time. If you have 500 tables each defined it its own file, it takes lots of time. Yet not all actions need all tables so we may want to

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Doug Warren
On Thu, Jun 10, 2010 at 10:53 AM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: More discussion, thoughts? (maybe this should move to the web2py developer's thread?) As my request is still 'pending' I'd ask to keep the discussion here so I can contribute.

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
The conclusion is right but it is more complicated than that. This is not a syntactical issue. Let' say in a model we have: db.define_table('a',Field('b',default=request.client)) This code MUST be executed. There is no way to import it because request.client only exist when the request

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Thadeus Burgess
This is what I desire from this Web2py applications to be importable python modules Along with [A] your models immediately become python modules that you can import. This solves my need to share models between web2py apps.' Web2py has a Top down approach, where other frameworks use a down-up

Re: [web2py] Re: Separating models into their own files

2010-06-10 Thread Thadeus Burgess
This code MUST be executed. There is no way to import it because request.client only exist when the request arrives and we do not want to re import modules on every request. Flask accomplishes this perfectly by placing the request in a context thread local. It only exists the the thread local

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
Flask has a clever mechanism that web2py also uses internally in DAL. It partially addresses the problem: Consider this example: http://github.com/mitsuhiko/flask/blob/master/examples/flaskr/flaskr.py Consider the action login. request is a global object that acts as a proxy. Any attribute of

[web2py] Re: Separating models into their own files

2010-06-10 Thread Anthony
From the Flask documentation: For example Flask uses thread local objects internally so that you don’t have to pass objects around from function to function within a request in order to stay threadsafe. While this is a really easy approach and saves you a lot of time, it also does not scale well

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
This is a false problem. Flask and web2py are not asynchronous like Tornado. This is not a problem nor a limitation but a difference in design that determine the way one program web applications. Scalability and speed have to do with database bottleneck more than everything else. About the

[web2py] Re: Separating models into their own files

2010-06-10 Thread mdipierro
from the Tornado page Tornado comes with limited support for WSGI. However, since WSGI does not support non-blocking requests, you cannot use any of the asynchronous/non-blocking features of Tornado in your application if you choose to use WSGI instead of Tornado's HTTP server. On Jun 10, 11:33 

[web2py] Re: Separating models into their own files

2010-06-10 Thread Anthony
Thanks for the (quick) clarification. On Jun 11, 12:33 am, mdipierro mdipie...@cs.depaul.edu wrote: This is a false problem. Flask and web2py are not asynchronous like Tornado. This is not a problem nor a limitation but a difference in design that determine the way one program web

[web2py] Re: Separating models into their own files

2010-06-09 Thread mdipierro
No. This the main issue with web2py design. This is the price we pay for not having imports of models. On Jun 9, 4:21 pm, Binh btbinht...@gmail.com wrote: Hi, I am trying to create an orm setup like in ruby on rails with the DAL. I have a user, post, and tag model. A user has many posts. A

Re: [web2py] Re: Separating models into their own files

2010-06-09 Thread Thadeus Burgess
There are some things you can do to alleviate the situation. First, you can name you models so that they execute in the correct order. A_db.py B_user.py C_post.py E_tag.py That said, I usually try to keep all related models in the same file. In your case you might have B_user.py C_weblog.py

[web2py] Re: Separating models into their own files

2010-06-09 Thread mdipierro
My approach is to use db_blablabla1.py db_blablabla2.py db_blablabla3.py where db_blablabla.py defiles all tables that link each other for a specific purpose. The different files are independent and therefore the order of execution is not important. On Jun 9, 9:20 pm, Thadeus Burgess

[web2py] Re: Separating models into their own files

2010-06-09 Thread Salvor Hardin
I'm new to python and web2py, so this might sound crazy but...here goes. Noob idea #1 Why not provide an optional exec_models.cfg file? If it doesn't exist, execute *.py files in alphabetical order found in the models folder. This will maintain backward compatibility and give web2py more

[web2py] Re: Separating models into their own files

2010-06-09 Thread mdipierro
They both make a lot of sense. The former would be much easier to implement and would result in faster code. What do other people think? On Jun 9, 11:32 pm, Salvor Hardin salvor.pub...@gmail.com wrote: I'm new to python and web2py, so this might sound crazy but...here goes. Noob idea #1 Why