On 28 February 2012 00:25, Anthony <[email protected]> wrote:
> Also, keep in mind that "model-less" can mean many things. It doesn't
> necessarily entail the highly class-based approach you see in Bruno's
> Movuca. It could mean simply moving some standard table definitions from
> model files into functions in modules. In fact, I think Bruno's class-based
> design and the notion of "model-less" are largely orthogonal -- you can
> define classes in model files, and you can use a non-classed-based approach
> in modules.
I do not particularly like the OO-approach in programming and would prefer
to use classes only when it is clearly the best (or easiest) option.
Here is a very simple example of defining a table in a module without using
classes explicitly:
In the model (db.py):
from gluon import current
current.db = db
In the module(tabelle.py):
from gluon import *
import re
def tabel1():
db = current.db
db.define_table('toets',
Field('veld1'),
Field('veld2')
)
print db.tables
return db
Controller:
from applications.toets.modules.tabelle import *
def index():
db = tabel1()
print "in controller"
print db.tables
vorm = crud.create(db.toets)
return dict(vorm = vorm)
And in appadmin.py do the same import as above and
def get_databases(request):
db = tabel1()
dbs = {}
...
Regards
Johann
--
Because experiencing your loyal love is better than life itself,
my lips will praise you. (Psalm 63:3)
: