1.55rc2 and Happy New Year.

14 views
Skip to first unread message

mdipierro

unread,
Dec 31, 2008, 10:53:37 AM12/31/08
to web2py Web Framework
Please check out

http://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_src.zip
http://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_osx.zip
http://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_win.zip

New features:

0) support for many2many (sort of) via IS_IN_DB(...,multiple=True).
Read more below:

http://groups.google.com/group/web2py/browse_thread/thread/a234895207097f60

1) complete database backup/restore with db.export_to_csv_file(..),
db.import_from_csv_file(...), reimporting optionally fixes references
without need for uuid. read more below:

http://groups.google.com/group/web2py/browse_thread/thread/55d923a51eca2c90/30753d8a58e0fdd1?lnk=gst&q=export_to_csv_file#30753d8a58e0fdd1
http://groups.google.com/group/web2py/browse_thread/thread/c08d1b05ddda672c/8b1a7c522e21e494?lnk=gst&q=export_to_csv_file#8b1a7c522e21e494

2) db(...).delete, db(...).update return number of affected rows.
3) better unittests
4) you can nest cache calls (like cache a controller that caches a
select). Thanks Iceberg
5) db(....id==None).select() no longer returns an error but an empty
SQLRows on GAE
6) db(...).delete(delete_uploads=True) and SQLFORM.accepts
(....delete_uploads=True) will delete all referenced uploaded files.
SHOULD THIS BE THE DEFAULT?
7) now you can do form.element(_name='fieldname').update
(_class='myclass')
8) db(....).select(...).json() will serialize in json in a database
independent way. Thanks Tim.
9) URL(r=request,args=0) instead of URL(r=request,args=[0])
10) In URL(...,f) f is url encoded. Thanks Sandro
11) In routes_in=[['a/b/c/','a/b/c/?var=value']]
12) db(...).select(...,limitby(min,max)) works on mssql (but still
inefficient)
13) ... always backward compatible (I think, please check)

Thanks to all of those who have contributed and HAPPY NEW YEAR!!!!

Massimo

mdipierro

unread,
Jan 1, 2009, 6:00:43 AM1/1/09
to web2py Web Framework
reposted. to fix a change that could have broken backward
compatibility.

Massimo

On Dec 31 2008, 9:53 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Please check out
>
> http://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_src.ziphttp://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_osx.ziphttp://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_win.zip
>
> New features:
>
> 0) support for many2many (sort of) via IS_IN_DB(...,multiple=True).
> Read more below:
>
> http://groups.google.com/group/web2py/browse_thread/thread/a234895207...
>
> 1) complete database backup/restore with db.export_to_csv_file(..),
> db.import_from_csv_file(...), reimporting optionally fixes references
> without need for uuid. read more below:
>
> http://groups.google.com/group/web2py/browse_thread/thread/55d923a51e...http://groups.google.com/group/web2py/browse_thread/thread/c08d1b05dd...

pmate

unread,
Jan 2, 2009, 2:21:53 AM1/2/09
to web2py Web Framework
Always working to web2py, even on holidays, eh? :-)
Happy new year to all!

Paolo

On 1 Gen, 12:00, mdipierro <mdipie...@cs.depaul.edu> wrote:
> reposted. to fix a change that could have broken backward
> compatibility.
>
> Massimo
>
> On Dec 31 2008, 9:53 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Please check out
>
> >http://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_src.ziphttp:...
>
> > New features:
>
> > 0) support for many2many (sort of) via IS_IN_DB(...,multiple=True).
> > Read more below:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/a234895207...
>
> > 1) complete database backup/restore with db.export_to_csv_file(..),
> > db.import_from_csv_file(...), reimporting optionally fixes references
> > without need for uuid. read more below:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/55d923a51e......

annet

unread,
Jan 2, 2009, 4:00:25 AM1/2/09
to web2py Web Framework
Massimo,

Happy new year to you too.

Getting started with web2py was the best thing that happened to me in
2008, compared to JSP/Servlets, ASP/VBScript and PHP, web2py works
like a dream.

I went through the new features of 1.55rc2 and wondered whether there
is an overview of features added to previous features of web2py.


Best regards,

Annet.

mdipierro

unread,
Jan 2, 2009, 4:02:58 AM1/2/09
to web2py Web Framework
there is a README file although it is not very accurate.

Massimo

annet

unread,
Jan 5, 2009, 2:08:59 PM1/5/09
to web2py Web Framework
Massimo,

Indeed, the READMe file isn't very accurate ;-)

When will multi column unique constraint functionality be added to
web2py.


Best regards,

Annet.

Timothy Farrell

unread,
Jan 5, 2009, 2:35:22 PM1/5/09
to web...@googlegroups.com
Annet,

I'm not sure multi-column unique constraints will happen soon.  The changes that need to happen to make this happen are deadlocked on design philosophy.

See these threads:
http://groups.google.com/group/web2py/browse_frm/thread/133644f67efdc217/92b2ec48c387965e
http://groups.google.com/group/web2py/browse_frm/thread/ce7d452b0666c34f/f2da4473d7f3e844

In the meantime, Massimo allowed me to patch in the ability to use a different DAL/ORM if you so choose.  Just note that if you do, the admin app can't use non-web2py DAL models.

The API for this is to specify the function to run when the database should be committed or rolled back...like so:

response.custom_commit=lambda: do_commit()
response.custom_rollback=lambda: do_rollback()

This was put in trunk on 12/18 but hasn't made it to a release yet.

Cheers,
  tim
-- 
Timothy Farrell <tfar...@swgen.com>
Computer Guy
Statewide General Insurance Agency (www.swgen.com)

mdipierro

unread,
Jan 5, 2009, 3:01:40 PM1/5/09
to web2py Web Framework
Tim is right. This will not happen soon BUT, you can use raw SQL to
define multicolumn unique contraints and/or you can use IS_NOT_IN_DB
to enforce multicolumn unique constraints at the web2py level.

Massimo

Fran

unread,
Jan 5, 2009, 4:31:08 PM1/5/09
to web2py Web Framework
On Jan 5, 7:35 pm, Timothy Farrell <tfarr...@swgen.com> wrote:
> In the meantime, Massimo allowed me to patch in the ability to use a different DAL/ORM if you so choose.  Just note that if you do, the admin app can't use non-web2py DAL models.
> The API for this is to specify the function to run when the database should be committed or rolled back...like so:
> response.custom_commit=lambda: do_commit()
> response.custom_rollback=lambda: do_rollback()

Could this same approach be taken to do Spatial queries in PostGIS?

I'm not ready to do this yet in my app, but I see it as a very useful
feature later to speed up such queries enormously.
Of course having the DAL spaitally aware would be awesome.
I'm assuming that to get this done, I'd need to be prepared to put in
some work to get suitable patches preapred but then those patches
would be likely to be accepted?

Am planning to store geographic features as WKT for portability, but
want to be able to do spatial queries where this is DB support for
such:
http://postgis.refractions.net/documentation/manual-1.3/ch04.html#id2742021

F

annet

unread,
Jan 6, 2009, 6:28:21 AM1/6/09
to web2py Web Framework
Massimo,

In my case enforcing a multi column unique constraint at web2py level
will do.

What does the IS_NOT_IN_DB statement look like for a two column unique
constraint?


Best regards,

Annet.

mdipierro

unread,
Jan 6, 2009, 9:06:32 AM1/6/09
to web2py Web Framework
IS_NOT_IN_DB(db(db.table.field1==request.field1),'table.field2')

Massimo

annet

unread,
Jan 6, 2009, 10:41:29 AM1/6/09
to web2py Web Framework
Massimo,

Thanks for your instant reply, I am afraid I am missing some line of
code to get the multi column constraint to work properly.

In my model I have got the following tables:

db.define_table('company',
SQLField('name', length=50, default='', notnull=True),
SQLField('coc_number', length=8, default='', notnull=True),
SQLField('subdossiernumber', length=4, default='0000', notnull=True),
SQLField('legalform', db.rechtsvorm, ondelete='RESTRICT'),
SQLField('status', length=1, default='0', notnull=True),
SQLField('ranking', length=3, default='999', notnull=True),
migrate='company.table')


db.define_table('training',
SQLField('number', type='integer', length=6, default='', notnull=True,
unique=True),
SQLField('name', length=40, default='', notnull=True, unique=True),
migrate='training.table')


Since the relationship between company and training is of type n-to-m
I added a third table:

db.define_table('companytraining',
SQLField('company', db.company, default='', notnull=True),
SQLField('training', length=40, default='', notnull=True),
migrate='companytraining.table')

db.companytraining.training.requires=IS_IN_DB(db, 'training.name','%
(name)s')


The multi column unique constraint should prevent users from entering
a training more than once for the same company. The

IS_NOT_IN_DB(db(db.table.field1==request.field1),'table.field2')

statement contains a request variable, which in my case doesn't exist,
furthermore, validators start with
db.companytraining.company.requires= .... expresion which in case of a
two column unique constraint doesn't seem to make sense. I thought the
third table definition would read something like:


db.define_table('companytraining',
SQLField('company', db.company, default='', notnull=True),
SQLField('training', length=40, default='', notnull=True),
migrate='companytraining.table')

db.companytraining.training.requires=IS_IN_DB(db, 'training.name','%
(name)s')
IS_NOT_IN_DB(db
(db.companytraining.company,db.companytraining.training))

However, neither this line nor IS_NOT_IN_DB(db
(db.companytraining.company==request.company),'companytraining.training')
enforce a two column unique constraint at web2py level. I my
illustration is helpful in solving this problem.


Best regards,

Annet.




mdipierro

unread,
Jan 6, 2009, 10:53:46 AM1/6/09
to web2py Web Framework
I think this is what you want:

db.companytraining.training.requires=[IS_IN_DB(db, 'training.name','%
(name)s'),
IS_NOT_IN_DB(db
(db.companytraining.company==request.company),'companytraining.training')]

Massimo

annet

unread,
Jan 6, 2009, 12:10:55 PM1/6/09
to web2py Web Framework
Massimo,

I don't get the two column unique constraint in my application to
work. Therefore I created the following table:

db=SQLDB('sqlite://annet.db')

db.define_table('shape',
SQLField('name'),
SQLField('color'),
migrate='shape.table')

db.shape.name.requires=IS_NOT_IN_DB(db
(db.shape.name==request.shape),'shape.color')


The IS_NOT_IN_DB validator should prevent the user from entering two
shapes with the same color, I inserted the following shapes and
colors:

triangle red
cone green

when I enter a second green cone, the application doesn't protest and
inserts a second green cone. How do I get this simple application to
work properly.


Best regards,

Annet.

annet

unread,
Jan 6, 2009, 12:21:57 PM1/6/09
to web2py Web Framework
I replaced the constraint with:

db.shape.name.requires=IS_NOT_IN_DB(db
(db.shape.name==request.name),'shape.color')

So, request.name instead of request.shape, but that didn't make any
difference.


Annet.

mdipierro

unread,
Jan 6, 2009, 12:30:14 PM1/6/09
to web2py Web Framework
This works:

db=SQLDB('sqlite://annet.db')
db.define_table('shape',
SQLField('name'),
SQLField('color'),
migrate='shape.table')
db.shape.color.requires=IS_NOT_IN_DB(db
(db.shape.name==request.vars.name),'shape.color')

I had forgotted the .vars in request.vars.name.

Notice that (highlighted in uppercase)

1) you are validating shape.color:
db.SHAPE.COLOR.requires=IS_NOT_IN_DB(db
(db.shape.name==request.vars.name),'SHAPE.COLOR')
2) with a condition that depends on another request.vars:
db.shape.color.requires=IS_NOT_IN_DB(db
(db.SHAPE.NAME==request.vars.NAME),'shape.color')

Massimo

annet

unread,
Jan 6, 2009, 12:45:22 PM1/6/09
to web2py Web Framework
Massimo,

Thank you very much for your patience, adding vars in
request.vars.name solved the problem.


Best regards,

Annet

Phyo Arkar

unread,
Jan 6, 2009, 3:39:34 PM1/6/09
to web...@googlegroups.com
Massimo;

Happy new year and you working even on newyear holidays for web2py! Thats Awesome!

I am Sorry i was so busy and even forget to wish newyear here.

I am at a project which uses web2py as server side for  p2p webcam system :)

Warmest Regards,
And Happy new Year All!

2009 Will Be The Year of Web2py!.

Phyo.

mdipierro

unread,
Jan 6, 2009, 4:29:51 PM1/6/09
to web2py Web Framework
what happened to the web2py os?

Massimo

On Jan 6, 2:39 pm, "Phyo Arkar" <phyo.arkarl...@gmail.com> wrote:
> Massimo;
>
> Happy new year and you working even on newyear holidays for web2py! Thats
> Awesome!
>
> I am Sorry i was so busy and even forget to wish newyear here.
>
> I am at a project which uses web2py as server side for p2p webcam system :)
>
> Warmest Regards,
> And Happy new Year All!
>
> 2009 Will Be The Year of Web2py!.
>
> Phyo.
>

annet

unread,
Jan 7, 2009, 5:02:26 AM1/7/09
to web2py Web Framework
Massimo,

I added two lookup table to my application:

db=SQLDB('sqlite://annet.db')

db.define_table('shape',
SQLField('name'),
migrate='shape.table')

db.define_table('color',
SQLField('name'),
migrate='color.table')

db.define_table('shapecolor',
SQLField('shapename'),
SQLField('colorname'),
migrate='shapecolor.table')

db.shapecolor.shapename.requires=IS_IN_DB(db,db.shape.name,'%(name)s')
db.shapecolor.colorname.requires=IS_IN_DB(db,db.color.name,'%(name)s')

db.shapecolor.colorname.requires=IS_NOT_IN_DB(db
(db.shapecolor.shapename==request.vars.shapename),'shapecolor.colorname')


Doing so raised the following problem: when I comment out the last
validator, I have two drop boxes in the admin from which I can choose
a shape and a color and insert them into the database. However, when I
uncomment the two column unique constraint, the color drop box breaks,
it becomes a text field. When I insert a shape and color combination
that's already in the database I get an error, so the constraint
works, but loosing the drop box functionality on color is rather
awkward.

Best regards,

Annet.

Fran

unread,
Jan 7, 2009, 5:07:04 AM1/7/09
to web2py Web Framework
On Jan 7, 10:02 am, annet <jmverm...@planet.nl> wrote:
> when I comment out the last
> validator, I have two drop boxes in the admin from which I can choose
> a shape and a color and insert them into the database. However, when I
> uncomment the two column unique constraint, the color drop box breaks,
> it becomes a text field. When I insert a shape and color combination
> that's already in the database I get an error, so the constraint
> works, but loosing the drop box functionality on color is rather
> awkward.

Could you add the dropbox back via a widget?

Although a framework-level solution would be better than this
workaround hack...

F

mdipierro

unread,
Jan 7, 2009, 8:51:39 AM1/7/09
to web2py Web Framework
yes:

def mywidget(field,value,options):
id='%s_%s' % (field._tablename,field.name)
else: raise SyntaxError, "widget cannot determine options"
opts+=[OPTION(v,_value=k) for k,v in options]
return SELECT(*opts,**dict(_id=id,_class=field.type,

_name=field.name,value=value,requires=field.requires))

db.table.field.widget=lambda f,v: mywidget(f,v,IS_IN_DB
(...).options())

mdipierro

unread,
Jan 7, 2009, 8:52:49 AM1/7/09
to web2py Web Framework
yes:

def mywidget(field,value,options):
id='%s_%s' % (field._tablename,field.name)
else: raise SyntaxError, "widget cannot determine options"
opts+=[OPTION(v,_value=k) for k,v in options]
return SELECT(*opts,**dict(_id=id,_class=field.type,

_name=field.name,value=value,requires=field.requires))

db.table.field.widget=lambda f,v: mywidget(f,v,IS_IN_DB
(...).options())

On Jan 7, 4:07 am, Fran <francisb...@googlemail.com> wrote:

achipa

unread,
Jan 7, 2009, 9:04:27 AM1/7/09
to web2py Web Framework
Fran, if you start working on a spatially aware DAL, please let me
know so we could join forces or at least avoid code duplication. I
have some spatial projects (none of them web2py at the moment) that
I'm considering on migrating, but more serious spatial support would
be needed for that, maybe even an additional module (like what
geodjango is to django) to avoid bloating the base of web2py
unnecessarily for the majority of users who don't need spatial
functionality.
> such:http://postgis.refractions.net/documentation/manual-1.3/ch04.html#id2...
>
> F

annet

unread,
Jan 7, 2009, 10:32:29 AM1/7/09
to web2py Web Framework
Massimo and Fran,

Thanks for your replies. I have used a widget only once, I'll give
implementing it a try.


Best regards,

Annet.

Phyo Arkar

unread,
Jan 7, 2009, 12:20:34 PM1/7/09
to web...@googlegroups.com
Dear Massimo;

Dont worry  , after this project done , (in 2 weeks) i will release web2py OS too. I had made a VM to use for this project , its with web2py and sliming it down , i can present you people with first release of web2py-vm.
I will also need community help to make it evolve!.

Regards,

Phyo.
Reply all
Reply to author
Forward
0 new messages