[web2py] Quick reCaptcha question

2010-12-06 Thread Bernardo
Hi all,

as said in the book, the following line

auth.settings.captcha = Recaptcha(request, 'PUBLIC_KEY',
'PRIVATE_KEY')

activates the reCaptcha feature for registration. But it shows also
the captcha box when a user logs in.

The question is, is there any way to show the recaptcha box just in
the registration form, and not in the login form?

Thanks,
Bernardo


[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread DenesL

See http://groups.google.com/group/web2py/msg/4a9e84fb5ceb2e4f
It only works if there are no common field names.
I have added this to the book.

On Dec 5, 5:07 pm, tomt  wrote:
> Hi,
>
> I'm unfamiliar with _filter_fields. I couldn't find it in the manual
> but eventually found it in the source in gluon/tools.py.
> Am I correct in assuming it is intended to return everything but the
> id field from a record? (I've just started to learn python)
>
> Is there some documentation available for this? I've tried some of the
> urls in the help and resources post:
>  http://web2py.com/examples/default/dal
>  http://web2py.com/examples/default/api
>  http://web2py.com/examples/default/tools
>
> But I just get "invalid function"
>
> Thanks in advance,
>   - Tom
>
> On Dec 5, 7:00 am, villas  wrote:
>
> > Hi Nathan
>
> > Just a small point, I tried your code example and it seems you have to
> > set id==None otherwise it tries to add a duplicate row with the same
> > id.
>
> > Anyway, I thought you also might like this alternative using
> > _filter_fields, just because it's shorter. Maybe it's got other
> > issues,  but it seems to work!
>
> > def things():
> >     form = SQLFORM(db.things)
> >     if form.accepts(request.vars,session):
> >         response.flash = 'Added a thing'
> >     if request.vars.dupe:
>
> > db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
> >     things = db(db.things.id>0).select()
> >     return dict(form=form,things=things)
>
> > Best regards,
> > -D
>
> > On Dec 4, 3:30 am, "mr.freeze"  wrote:
>
> > > Here is an example:
>
> > > Model
> > > -
> > > db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
> > >                 Field('age','integer'),Field('weight','double'))
> > > db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
> > >                                      _onclick='return confirm("Copy
> > > %s?")' % v)
>
> > > Controller
> > > --
> > > def index():
> > >     form = SQLFORM(db.things)
> > >     if form.accepts(request.vars,session):
> > >         response.flash = 'Added a thing'
> > >     if request.vars.dupe:
> > >         record = db.things(request.vars.dupe)
> > >         vals = {}
> > >         for k,v in record.items():
> > >             if k in db.things.fields:
> > >                 vals[k] = v
> > >         db.things.insert(**vals)
> > >     things = db(db.things.id>0).select()
> > >     return dict(form=form,things=things)
>
> > > On Dec 3, 6:12 pm, tomt  wrote:
>
> > > > Hi,
>
> > > > I've started to write a simple application to learn web2py. I am using
> > > > SQLFORM to insert, modify and delete records. So far everything is
> > > > working as planned.
>
> > > > I would like to give the user the ability add a new record as a copy
> > > > of an existing one.  The idea is that the user would view an existing
> > > > record, modify a couple fields, and select 'copy' which result in
> > > > adding a new record.
>
> > > > I assume that this requires additional code, and I was hoping that
> > > > someone would suggest an example, or let me know if SQLFORM can do
> > > > this automatically.
>
> > > > Thanks in advance,
>
> > > > - Tom
>
>


[web2py] Re: Tip of the day

2010-12-06 Thread DenesL

True, only restriction is no common field names.
I have added this to the book.


On Dec 5, 11:05 pm, mdipierro  wrote:
> No field names in comment yes. References between them is not a
> problem as long the reference fields are not writable and readable
> when generating the form.
>
> On Dec 5, 9:41 pm, DenesL  wrote:
>
> > This only works for tables that do not have field names in common
> > and have no references between them.
>
> > On Oct 16, 9:57 am, mdipierro  wrote:
>
> > > It often happens that you have two tables (for example 'client' and
> > > 'address' which are linked together by a reference and you want to
> > > create a single form that allows to insert info about one client and
> > > its default address. Here is how:
>
> > > model:
>
> > > db.define_table('client',
> > >      Field('name'))
> > > db.define_table('address',
> > >     Field('client',db.client,writable=False,readable=False),
> > >     Field('street'),Field('city'))
>
> > > controller:
>
> > > def register():
> > >     form=SQLFORM.factory(db.client,db.address)
> > >     if form.accepts(request.vars):
> > >         id = db.client.insert(**db.client._filter_fields(form.vars))
> > >         form.vars.client=id
> > >         id = db.address.insert(**db.address._filter_fields(form.vars))
> > >         response.flash='Thanks for filling the form'
> > >     return dict(form=form)
>
> > > Notice the SQLFORM.factory (it makes ONE form using public fields from
> > > both tables and inherits their validators too).
> > > On form accepts this does two inserts (some data in one table and some
> > > data in the other).
>
> > > Massimo
>
>


[web2py] Re: disable insertion for crud.create/update on DEMO_MODE

2010-12-06 Thread selecta
on the idea of changing things in the dal - it may be a good idea for
me to add an abstraction layer for create/update ... i have to think
about it an test what is the best/simplest solution for me
thanks

On Dec 2, 8:20 pm, mdipierro  wrote:
> I could easily add this feature but should it be done only for crud?
> Perhaps the demo mode should be done at the dal layer.
>
> Massimo
>
> On Dec 2, 12:37 pm, selecta  wrote:
>
>
>
> > I want to create a demo mode for my application where everything
> > should look like it works nomally but the actual insertion of data
> > should be prevented. Is it possible to do that if I use crud.create/
> > update?? Or should I replace all forms with form_factory forms?


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Branko Vukelic
On Mon, Dec 6, 2010 at 6:24 AM, Phyo Arkar  wrote:
> I use features as needed in each pages. If i can figure out  a way to
> put jqgrid to work hell , i will use full qxd !

That might be tricky. qxd doesn't set any usable attributes on HTML
elements it creates, since all references are maintained internally.
I'm not aware of a mechanism for adding the ID. I guess it's possible
to build a simple custom widget that sets a usable ID and nothing
else, and then attach the jqgrid using that ID.

Of the features you've mentioned:

Local Filtering, Multi select (interleaved or sequential), Sorting
(d'oh!), inplace editing, Dynamic Dataloading on any event (that's
what qxd is about after all), Custom everything... those are supported
to my knowledge. afaik, all table examples are created from one of two
table classes: qx.ui.table.Simple, and qx.ui.table.Remote. The latter
handles remote data, obviously. So I guess you can imagine the level
of customization possible.

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Quick reCaptcha question

2010-12-06 Thread mr.freeze
You can toggle it individually with:
auth.settings.register_captcha = Recaptcha(request, 'PUBLIC_KEY',
'PRIVATE_KEY')

On Dec 6, 3:59 am, Bernardo  wrote:
> Hi all,
>
> as said in the book, the following line
>
> auth.settings.captcha = Recaptcha(request, 'PUBLIC_KEY',
> 'PRIVATE_KEY')
>
> activates the reCaptcha feature for registration. But it shows also
> the captcha box when a user logs in.
>
> The question is, is there any way to show the recaptcha box just in
> the registration form, and not in the login form?
>
> Thanks,
> Bernardo


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Branko Vukelic
I've posted a question on qxd list about this, so I'll ping you when I
get an answer.

On Mon, Dec 6, 2010 at 2:56 PM, Branko Vukelic  wrote:
> On Mon, Dec 6, 2010 at 6:24 AM, Phyo Arkar  wrote:
>> I use features as needed in each pages. If i can figure out  a way to
>> put jqgrid to work hell , i will use full qxd !
>
> That might be tricky. qxd doesn't set any usable attributes on HTML
> elements it creates, since all references are maintained internally.
> I'm not aware of a mechanism for adding the ID. I guess it's possible
> to build a simple custom widget that sets a usable ID and nothing
> else, and then attach the jqgrid using that ID.
>
> Of the features you've mentioned:
>
> Local Filtering, Multi select (interleaved or sequential), Sorting
> (d'oh!), inplace editing, Dynamic Dataloading on any event (that's
> what qxd is about after all), Custom everything... those are supported
> to my knowledge. afaik, all table examples are created from one of two
> table classes: qx.ui.table.Simple, and qx.ui.table.Remote. The latter
> handles remote data, obviously. So I guess you can imagine the level
> of customization possible.
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] disable insertion for crud.create/update on DEMO_MODE

2010-12-06 Thread ramsñí££í
Its esy. . Dear.

On 03/12/2010, selecta  wrote:
> I want to create a demo mode for my application where everything
> should look like it works nomally but the actual insertion of data
> should be prevented. Is it possible to do that if I use crud.create/
> update?? Or should I replace all forms with form_factory forms?


[web2py] list:integer X list:reference for auth_user table

2010-12-06 Thread Bruno Rocha
Is there any important difference?

1.
Field('assigned_to','list:integer',requires=IS_IN_DB(db,db.auth_user.id
,'db.auth_user.first_name',multiple=True)),

2.
Field('assigned_to','list:reference auth_user'),


In the case of 2, how to represent as 'db.auth_user.first_name' for multiple
users?

-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] translation dict name?

2010-12-06 Thread Richard Vézina
Hello,

I would like to know in wich var name is store the differents language
dict??

I would automating the translation of somes entries with key:value that are
stored in database table... So I want to get the value that is store in
database table for a key of the dict...

I just don't know in wich var are stored the {key:value} present in language
files.

Regards

Richard


[web2py] Interesting fights

2010-12-06 Thread Branko Vukelic
http://www.googlefight.com/index.php?lang=en_GB&word1=python+programming&word2=ruby+programming
http://www.googlefight.com/index.php?lang=en_GB&word1=python+programming&word2=php+programming
http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=web.py+web+framewok
http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=werkzeug+web+framewok
http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=flask+web+framework
http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=django+web+framework
http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=nagare+web+framework

:)



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Branko Vukelic
On Mon, Dec 6, 2010 at 6:24 AM, Phyo Arkar  wrote:
> I use features as needed in each pages. If i can figure out  a way to
> put jqgrid to work hell , i will use full qxd !

http://qx/api/#qx.ui.embed.Html

This allows you to create an HTML element you need in order to attach jqgrid.

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Branko Vukelic
Sry, the API docs link was from my home server. :P Here's the correct url:

http://demo.qooxdoo.org/1.2.x/apiviewer/#qx.ui.embed.Html

On Mon, Dec 6, 2010 at 5:59 PM, Branko Vukelic  wrote:
> On Mon, Dec 6, 2010 at 6:24 AM, Phyo Arkar  wrote:
>> I use features as needed in each pages. If i can figure out  a way to
>> put jqgrid to work hell , i will use full qxd !
>
> http://qx/api/#qx.ui.embed.Html
>
> This allows you to create an HTML element you need in order to attach jqgrid.
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Interesting fights

2010-12-06 Thread Richard Vézina
Funny!

Richard

On Mon, Dec 6, 2010 at 11:57 AM, Branko Vukelic  wrote:

>
> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programming&word2=ruby+programming
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programming&word2=php+programming
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=web.py+web+framewok
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=werkzeug+web+framewok
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=flask+web+framework
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=django+web+framework
>
> http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+framework&word2=nagare+web+framework
>
> :)
>
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>


[web2py] Re: new dal

2010-12-06 Thread ron_m
I did an update of trunk using hg and copied dal.py over sql.py in
gluon and start the web2py.py server and still get

Traceback (most recent call last):
  File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
wsgibase
BaseAdapter.close_all_instances(BaseAdapter.commit)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
close_all_instances
self.connection.close()
NameError: global name 'self' is not defined

main is calling BaseAdapter.close_all_instances() as a class method so
the self reference at line 276 blows up because there is no instance
of a class. I see from the latest post we can test dal.py standalone,
are we not to be testing as part of web2py yet because of integration
issues?

Ron

On Dec 5, 7:11 pm, mdipierro  wrote:
> started work integrating with gluon/contrib/gql.py do
>
> please keep testing dal.py
>
> now it no longer requires web2py and you can do
>
> % python>>> from dal import DAL, Field
> >>> db=DAL('sqlite://file.sqlite')
> >>> db.define_table('person',Field('name'))
>
> etc etc.
>
> you ONLY need dal.py
>
> On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > in trunk!
>
> > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > Auth.define_tables doesn't have a fake_migrate attribute so I added
> > > one (want a patch?). Once I did, my .table files were re-created when
> > > migrate=True and fake_migrate=True. It still works once I set
> > > fake_migrate to False. I will test it against the new DAL now.
>
> > > On Dec 5, 1:24 pm, mdipierro  wrote:
>
> > > > can you try migrate=True, fake_migrate=True?
>
> > > > On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>
> > > > > I tried and the file modification times of the .table files do not
> > > > > change. I deleted them (safely backed up) and they are not re-created.
>
> > > > > On Dec 5, 12:56 pm, mdipierro  wrote:
>
> > > > > > It is the same. try without delete them.
>
> > > > > > On Dec 5, 12:53 pm, "mr.freeze"  wrote:
>
> > > > > > > I reverted to the old DAL and did the steps you outlined. Same 
> > > > > > > result.
> > > > > > > Should I delete the .table files first?
>
> > > > > > > On Dec 5, 12:41 pm, mdipierro  wrote:
>
> > > > > > > > for the troublesome table (auth_user) set migrate=False,
> > > > > > > > fake_migrate=True reload, then migrate=True and remove 
> > > > > > > > fake_migrate.
> > > > > > > > It should fix your broken .table.
>
> > > > > > > > Should work with old and with new dal.
>
> > > > > > > > On Dec 5, 11:47 am, "mr.freeze"  wrote:
>
> > > > > > > > > I seem to remember this failing before though. Something about
> > > > > > > > > my .TABLE files being out of sync. What is the procedure to 
> > > > > > > > > re-sync
> > > > > > > > > them?
>
> > > > > > > > > On Dec 5, 10:45 am, "mr.freeze"  wrote:
>
> > > > > > > > > > I have a global variable migrate_db which is passed to all
> > > > > > > > > > define_table functions. I switched it to false and get this:
> > > > > > > > > > Traceback (most recent call last):
> > > > > > > > > >   File "C:\web2py\gluon\restricted.py", line 188, in 
> > > > > > > > > > restricted
> > > > > > > > > >     exec ccode in environment
> > > > > > > > > >   File "C:/web2py/applications/main/models/db.py", line 34, 
> > > > > > > > > > in
> > > > > > > > >  
> > > > > > > > > >     readable=False, default=""),migrate=migrate_db)
> > > > > > > > > >   File "C:\web2py\gluon\sql.py", line 1406, in define_table
> > > > > > > > > >     obj = str(obj)
> > > > > > > > > >   File "C:\web2py\gluon\sql.py", line 1858, in _create
> > > > > > > > > >     'boolean': 'CHAR(1)',
> > > > > > > > > >   File "C:\web2py\gluon\sql.py", line 1024, in 
> > > > > > > > > >     'string': 'CHAR(%(length)s)',
> > > > > > > > > >   File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", 
> > > > > > > > > > line 166,
> > > > > > > > > > in execute
> > > > > > > > > >     self.errorhandler(self, exc, value)
> > > > > > > > > >   File 
> > > > > > > > > > "C:\Python26\lib\site-packages\MySQLdb\connections.py", line
> > > > > > > > > > 35, in defaulterrorhandler
> > > > > > > > > >     raise errorclass, errorvalue
> > > > > > > > > > OperationalError: (1050, "Table 'auth_user' already exists")
>
> > > > > > > > > > On Dec 5, 10:37 am, "mr.freeze"  
> > > > > > > > > > wrote:
>
> > > > > > > > > > > Let me backup the web2pyslice.com database and I will try.
>
> > > > > > > > > > > On Dec 5, 10:36 am, mdipierro  
> > > > > > > > > > > wrote:
>
> > > > > > > > > > > > can you try migrate=True (add a dummy field and the 
> > > > > > > > > > > > remove it) with
> > > > > > > > > > > > mysql?
>
> > > > > > > > > > > > On Dec 5, 10:20 am, "mr.freeze"  
> > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > Working with mysql also. I tested with migrate=False. 
> > > > > > > > > > > > > Nice work!
>
> > > > > > > > > > > > > On Dec 5, 10:12 am, "mr.freeze" 
> > > > > > > > > > > > >  wrote:
>
> > > > > > > > > > > > > > Okay, web2pyslices.com source runs against it with 
> > > > > > > > > > > > 

[web2py] Re: new dal

2010-12-06 Thread mdipierro
please try replace

@staticmethod
def close_all_instances(action):
""" to close cleanly databases in a multithreaded environment
"""
if not hasattr(thread,'instances'):
return
while thread.instances:
instance = thread.instances.pop()
action(instance)
# ## if you want pools, recycle this
connection
really = True
if instance.pool_size:
sql_locker.acquire()
pool = ConnectionPool.pools[self.uri]
if len(pool) < instance.pool_size:
pool.append(self.connection)
really = False
sql_locker.release()
if really:
self.connection.close()
return

with

@staticmethod
def close_all_instances(action):
""" to close cleanly databases in a multithreaded environment
"""
if not hasattr(thread,'instances'):
return
while thread.instances:
instance = thread.instances.pop()
action(instance)
# ## if you want pools, recycle this
connection
really = True
if instance.pool_size:
sql_locker.acquire()
pool = ConnectionPool.pools[self.uri]
if len(pool) < instance.pool_size:
pool.append(instance.connection)
really = False
sql_locker.release()
if really:
instance.connection.close()
return

I think this is global replace error.


On Dec 6, 11:13 am, ron_m  wrote:
> I did an update of trunk using hg and copied dal.py over sql.py in
> gluon and start the web2py.py server and still get
>
> Traceback (most recent call last):
>   File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> wsgibase
>     BaseAdapter.close_all_instances(BaseAdapter.commit)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> close_all_instances
>     self.connection.close()
> NameError: global name 'self' is not defined
>
> main is calling BaseAdapter.close_all_instances() as a class method so
> the self reference at line 276 blows up because there is no instance
> of a class. I see from the latest post we can test dal.py standalone,
> are we not to be testing as part of web2py yet because of integration
> issues?
>
> Ron
>
> On Dec 5, 7:11 pm, mdipierro  wrote:
>
> > started work integrating with gluon/contrib/gql.py do
>
> > please keep testing dal.py
>
> > now it no longer requires web2py and you can do
>
> > % python>>> from dal import DAL, Field
> > >>> db=DAL('sqlite://file.sqlite')
> > >>> db.define_table('person',Field('name'))
>
> > etc etc.
>
> > you ONLY need dal.py
>
> > On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > > in trunk!
>
> > > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > > Auth.define_tables doesn't have a fake_migrate attribute so I added
> > > > one (want a patch?). Once I did, my .table files were re-created when
> > > > migrate=True and fake_migrate=True. It still works once I set
> > > > fake_migrate to False. I will test it against the new DAL now.
>
> > > > On Dec 5, 1:24 pm, mdipierro  wrote:
>
> > > > > can you try migrate=True, fake_migrate=True?
>
> > > > > On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>
> > > > > > I tried and the file modification times of the .table files do not
> > > > > > change. I deleted them (safely backed up) and they are not 
> > > > > > re-created.
>
> > > > > > On Dec 5, 12:56 pm, mdipierro  wrote:
>
> > > > > > > It is the same. try without delete them.
>
> > > > > > > On Dec 5, 12:53 pm, "mr.freeze"  wrote:
>
> > > > > > > > I reverted to the old DAL and did the steps you outlined. Same 
> > > > > > > > result.
> > > > > > > > Should I delete the .table files first?
>
> > > > > > > > On Dec 5, 12:41 pm, mdipierro  wrote:
>
> > > > > > > > > for the troublesome table (auth_user) set migrate=False,
> > > > > > > > > fake_migrate=True reload, then migrate=True and remove 
> > > > > > > > > fake_migrate.
> > > > > > > > > It should fix your broken .table.
>
> > > > > > > > > Should work with old and with new dal.
>
> > > > > > > > > On Dec 5, 11:47 am, "mr.freeze"  wrote:
>
> > > > > > > > > > I seem to remember this failing before though. Something 
> > > > > > > > > > about
> > > > > > > > > > my .TABLE files being out of sync. What is the procedure to 
> > > > > > > > > > re-sync
> > > > > > > > > > them?
>
> > > > > > > > > > On Dec 5, 10:45 am, "mr.freeze"  
> > > > > > > > > > wrote:
>
> > > > > > > > > > > I have a global variable migrate_db which is passed to all
> > > > > > > > > > > define_table functions. I switched it to false and get 
> > > > > > > > > > > this:
> > > > > > > > > > > Traceback (most recent call last):
> > > > > > > > > > >   File "C:\web2py\gluon\restricted.py", line 188, in 
> > > > > > > > > > > restricted
> > > > > > > > > > >     exec ccode in environment
> > > > > > > > > > >   

Re: [web2py] Re: new dal

2010-12-06 Thread Jonathan Lundell
On Dec 6, 2010, at 9:13 AM, ron_m wrote:
> 
> I did an update of trunk using hg and copied dal.py over sql.py in
> gluon and start the web2py.py server and still get
> 
> Traceback (most recent call last):
>  File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> wsgibase
>BaseAdapter.close_all_instances(BaseAdapter.commit)
>  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> close_all_instances
>self.connection.close()
> NameError: global name 'self' is not defined
> 
> main is calling BaseAdapter.close_all_instances() as a class method so
> the self reference at line 276 blows up because there is no instance
> of a class. I see from the latest post we can test dal.py standalone,
> are we not to be testing as part of web2py yet because of integration
> issues?

Judging from the parallel code in sql.py, you might try replacing 'self' with 
'instance' in dal.ConnectionPool.close_all_instances (3 places).

> 
> Ron
> 
> On Dec 5, 7:11 pm, mdipierro  wrote:
>> started work integrating with gluon/contrib/gql.py do
>> 
>> please keep testing dal.py
>> 
>> now it no longer requires web2py and you can do
>> 
>> % python>>> from dal import DAL, Field
> db=DAL('sqlite://file.sqlite')
> db.define_table('person',Field('name'))
>> 
>> etc etc.
>> 
>> you ONLY need dal.py
>> 
>> On Dec 5, 1:56 pm, mdipierro  wrote:
>> 
>>> in trunk!
>> 
>>> On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>> 
 Auth.define_tables doesn't have a fake_migrate attribute so I added
 one (want a patch?). Once I did, my .table files were re-created when
 migrate=True and fake_migrate=True. It still works once I set
 fake_migrate to False. I will test it against the new DAL now.
>> 
 On Dec 5, 1:24 pm, mdipierro  wrote:
>> 
> can you try migrate=True, fake_migrate=True?
>> 
> On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>> 
>> I tried and the file modification times of the .table files do not
>> change. I deleted them (safely backed up) and they are not re-created.
>> 
>> On Dec 5, 12:56 pm, mdipierro  wrote:
>> 
>>> It is the same. try without delete them.
>> 
>>> On Dec 5, 12:53 pm, "mr.freeze"  wrote:
>> 
 I reverted to the old DAL and did the steps you outlined. Same result.
 Should I delete the .table files first?
>> 
 On Dec 5, 12:41 pm, mdipierro  wrote:
>> 
> for the troublesome table (auth_user) set migrate=False,
> fake_migrate=True reload, then migrate=True and remove fake_migrate.
> It should fix your broken .table.
>> 
> Should work with old and with new dal.
>> 
> On Dec 5, 11:47 am, "mr.freeze"  wrote:
>> 
>> I seem to remember this failing before though. Something about
>> my .TABLE files being out of sync. What is the procedure to re-sync
>> them?
>> 
>> On Dec 5, 10:45 am, "mr.freeze"  wrote:
>> 
>>> I have a global variable migrate_db which is passed to all
>>> define_table functions. I switched it to false and get this:
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 188, in restricted
>>> exec ccode in environment
>>>   File "C:/web2py/applications/main/models/db.py", line 34, in
>>  
>>> readable=False, default=""),migrate=migrate_db)
>>>   File "C:\web2py\gluon\sql.py", line 1406, in define_table
>>> obj = str(obj)
>>>   File "C:\web2py\gluon\sql.py", line 1858, in _create
>>> 'boolean': 'CHAR(1)',
>>>   File "C:\web2py\gluon\sql.py", line 1024, in 
>>> 'string': 'CHAR(%(length)s)',
>>>   File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", line 166,
>>> in execute
>>> self.errorhandler(self, exc, value)
>>>   File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line
>>> 35, in defaulterrorhandler
>>> raise errorclass, errorvalue
>>> OperationalError: (1050, "Table 'auth_user' already exists")
>> 
>>> On Dec 5, 10:37 am, "mr.freeze"  wrote:
>> 
 Let me backup the web2pyslice.com database and I will try.
>> 
 On Dec 5, 10:36 am, mdipierro  wrote:
>> 
> can you try migrate=True (add a dummy field and the remove it) 
> with
> mysql?
>> 
> On Dec 5, 10:20 am, "mr.freeze"  wrote:
>> 
>> Working with mysql also. I tested with migrate=False. Nice work!
>> 
>> On Dec 5, 10:12 am, "mr.freeze"  wrote:
>> 
>>> Okay, web2pyslices.com source runs against it with a sqlite 
>>> database.
>>> I will test with mysql.
>> 
>>> On Dec 4, 11:02 pm, mdipierro  wrote:
>> 
 One more test please. I do not have mysql installed here so I 
 did not
 test pooling. This helps a lot. thanks.
>> 
 On Dec 4, 10:33 pm, "mr.freez

[web2py] translation dict name? + my solution

2010-12-06 Thread Richard Vézina
Hello,

I come with that solution... I would have comment...


I get my translations like this :

translate_ui_tables_names=dict((r.table_name_en_ui,r.table_name_fr_ui)\
for r in db().select(db.dict_database.ALL))

Then I just have to :

language translation dict*.append(translate_ui_tables_names)

* Still searching for the name of the dict of the differents language file
(ex.: fr-ca.py or fr-fr.py)

;-)

Richard


[web2py] Basic models question

2010-12-06 Thread Lorin Rivers
If a model is defined in db.py, everything in that application has access to 
it, correct?

The only reason to define a model in a different file is if you only need to 
access that particular model in a similarly named controller, correct?

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] routes conundrum

2010-12-06 Thread Lorin Rivers
We've encountered a bug where our app behaves differently if you access it via 
/AppName/ than it does if you access it via /AppName/default/index

What would likely explain that and how should I go about ensuring identical 
behavior in either case?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




Re: [web2py] Basic models question

2010-12-06 Thread Richard Vézina
The model defined in

model1.py or in db.py

will be available in any controllers...

I not sure but I think the only reason to devide your model in differents
model file is for keep the file clean and understandable...

For the controllers it is differents if you define a function in a
particular controller it will be accessible only if you specify this
controller in your URL.

Richard

On Mon, Dec 6, 2010 at 12:32 PM, Lorin Rivers  wrote:

> If a model is defined in db.py, everything in that application has access
> to it, correct?
>
> The only reason to define a model in a different file is if you only need
> to access that particular model in a similarly named controller, correct?
>
> Thanks!
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)
>
>
>


Re: [web2py] routes conundrum

2010-12-06 Thread Richard Vézina
By default http://YOURDOMAIN/AppName should redirect to
http://YOURDOMAIN/AppName*/default/index*
*
*
*Richard
*
On Mon, Dec 6, 2010 at 12:35 PM, Lorin Rivers  wrote:

> We've encountered a bug where our app behaves differently if you access it
> via /AppName/ than it does if you access it via /AppName/default/index
>
> What would likely explain that and how should I go about ensuring identical
> behavior in either case?
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)
>
>
>


Re: [web2py] routes conundrum

2010-12-06 Thread Lorin Rivers
Richard,

Hence my confusion about it working differently depending on which url you 
access it with.

On Dec 6, 2010, at 11:40 , Richard Vézina wrote:

> By default http://YOURDOMAIN/AppName should redirect to
> http://YOURDOMAIN/AppName*/default/index*
> *
> *
> *Richard
> *
> On Mon, Dec 6, 2010 at 12:35 PM, Lorin Rivers  wrote:
> 
>> We've encountered a bug where our app behaves differently if you access it
>> via /AppName/ than it does if you access it via /AppName/default/index
>> 
>> What would likely explain that and how should I go about ensuring identical
>> behavior in either case?
>> --
>> Lorin Rivers
>> Mosasaur: Killer Technical Marketing 
>> 
>> 512/203.3198 (m)
>> 
>> 
>> 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




Re: [web2py] routes conundrum

2010-12-06 Thread Jonathan Lundell
On Dec 6, 2010, at 9:35 AM, Lorin Rivers wrote:
> 
> We've encountered a bug where our app behaves differently if you access it 
> via /AppName/ than it does if you access it via /AppName/default/index
> 
> What would likely explain that and how should I go about ensuring identical 
> behavior in either case?

Aside from posting your routes.py here and getting feedback, I suggest two 
approaches.

One is to edit the doctest at the end of routes.py to reflect your own routes, 
and add tests as necessary. (To run the doctest, just execute the file: python 
routes.py)

You'll want a doctest for /AppName/ and another for /AppName/default/index, 
with (presumably) identical expected output. If the doctest fails, you'll know 
in advance that your routes.py needs work.


Another approach is to use logging.conf to turn on rewrite logging.

[web2py] Re: routes conundrum

2010-12-06 Thread mr.freeze
Can you explain how it acts differently?

On Dec 6, 11:41 am, Lorin Rivers  wrote:
> Richard,
>
> Hence my confusion about it working differently depending on which url you 
> access it with.
>
> On Dec 6, 2010, at 11:40 , Richard Vézina wrote:
>
>
>
> > By defaulthttp://YOURDOMAIN/AppNameshould redirect to
> >http://YOURDOMAIN/AppName*/default/index*
> > *
> > *
> > *Richard
> > *
> > On Mon, Dec 6, 2010 at 12:35 PM, Lorin Rivers  wrote:
>
> >> We've encountered a bug where our app behaves differently if you access it
> >> via /AppName/ than it does if you access it via /AppName/default/index
>
> >> What would likely explain that and how should I go about ensuring identical
> >> behavior in either case?
> >> --
> >> Lorin Rivers
> >> Mosasaur: Killer Technical Marketing 
> >> 
> >> 512/203.3198 (m)
>
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


[web2py] Re: Basic models question

2010-12-06 Thread Anthony
Also, the model files are executed in alphabetical order, so
model_1.py will have access to things defined in model_0.py, but not
the other way around.

Anthony

On Dec 6, 12:37 pm, Richard Vézina 
wrote:
> The model defined in
>
> model1.py or in db.py
>
> will be available in any controllers...
>
> I not sure but I think the only reason to devide your model in differents
> model file is for keep the file clean and understandable...
>
> For the controllers it is differents if you define a function in a
> particular controller it will be accessible only if you specify this
> controller in your URL.
>
> Richard
>
>
>
> On Mon, Dec 6, 2010 at 12:32 PM, Lorin Rivers  wrote:
> > If a model is defined in db.py, everything in that application has access
> > to it, correct?
>
> > The only reason to define a model in a different file is if you only need
> > to access that particular model in a similarly named controller, correct?
>
> > Thanks!
> > --
> > Lorin Rivers
> > Mosasaur: Killer Technical Marketing 
> > 
> > 512/203.3198 (m)- Hide quoted text -
>
> - Show quoted text -


[web2py] Re: Interesting fights

2010-12-06 Thread mdipierro
based on what?

On Dec 6, 10:57 am, Branko Vukelic  wrote:
> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...
>
> :)
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


Re: [web2py] Re: Interesting fights

2010-12-06 Thread Jonathan Lundell
On Dec 6, 2010, at 9:58 AM, mdipierro wrote:
> 
> based on what?

Just Ghits, I suppose. Which means that "python programming sucks bigtime" 
counts toward Python, etc.

> 
> On Dec 6, 10:57 am, Branko Vukelic  wrote:
>> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...
>> 
>> :)
>> 
>> --
>> Branko Vukelić
>> 
>> bg.bra...@gmail.com
>> stu...@brankovukelic.com
>> 
>> Check out my blog:http://www.brankovukelic.com/
>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> Registered Linux user #438078 (http://counter.li.org/)
>> I hang out on identi.ca:http://identi.ca/foxbunny
>> 
>> Gimp Brushmakers Guildhttp://bit.ly/gbg-group




Re: [web2py] Re: Interesting fights

2010-12-06 Thread Branko Vukelic
Nothing scientific. It's just you know... a 'haha' thing. ;)

On Mon, Dec 6, 2010 at 6:58 PM, mdipierro  wrote:
> based on what?
>
> On Dec 6, 10:57 am, Branko Vukelic  wrote:
>> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...
>>
>> :)
>>
>> --
>> Branko Vukelić
>>
>> bg.bra...@gmail.com
>> stu...@brankovukelic.com
>>
>> Check out my blog:http://www.brankovukelic.com/
>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> Registered Linux user #438078 (http://counter.li.org/)
>> I hang out on identi.ca:http://identi.ca/foxbunny
>>
>> Gimp Brushmakers Guildhttp://bit.ly/gbg-group



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


Re: [web2py] Re: Interesting fights

2010-12-06 Thread Tiago Castro Henriques
I'm fascinated by the Google Trends for web2py:

http://www.google.com/trends?q=web2py

Russian is the most popular language for web2py mentions, followed closely
by Chinese.

Beijing seems to be the world capital of web2py mentions, with Shanghai in
4th place.

In terms of regions, Taiwan is 1st, with Russia in 2nd place and China in
3rd place.

Where are all those users? I see few Chinese or Russian names in the Google
group (I'm supposing Branko is Serb or Croat :-)

On Mon, Dec 6, 2010 at 6:14 PM, Branko Vukelic  wrote:

> Nothing scientific. It's just you know... a 'haha' thing. ;)
>
> On Mon, Dec 6, 2010 at 6:58 PM, mdipierro  wrote:
> > based on what?
> >
> > On Dec 6, 10:57 am, Branko Vukelic  wrote:
> >>
> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram.
> ..
> >>
> >> :)
> >>
> >> --
> >> Branko Vukelić
> >>
> >> bg.bra...@gmail.com
> >> stu...@brankovukelic.com
> >>
> >> Check out my blog:http://www.brankovukelic.com/
> >> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> >> Registered Linux user #438078 (http://counter.li.org/)
> >> I hang out on identi.ca:http://identi.ca/foxbunny
> >>
> >> Gimp Brushmakers Guildhttp://bit.ly/gbg-group
>
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 
Olifante's Lair
http://olifante.blogs.com/covil


[web2py] LIKE case sensitivity: Postgres differs to MySQL => DAL not portable

2010-12-06 Thread Fran
I see that Postgres defaults to a case-sensitive LIKE whereas MySQL &
sqlite default to case-insensitive:
http://www.postgresql.org/docs/8.0/interactive/functions-matching.html
- ILIKE for case-insensitive
http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
http://www.sqlite.org/lang_expr.html

This makes DAL applications not properly portable across DB back-
ends :/

>From reading the book, it seems that the recommendation to guarantee
case-insensitive would be to use .lower() [or .upper()]:
http://web2py.com/book/default/chapter/06#like,-startswith,-contains,-upper,-lower

However this then precludes the ability force a case-insensitive
search on MySQL/sqlite.

I've no idea whether ILIKE is more or less efficient than LOWER() LIKE
within pgsql.

For now I have started making all my .like() lookups use .lower() but
I thought I'd throw this out there
- minimally it should be in a FAQ (ideally in the next Book) & ideally
we could have a case_sensitive=True option for the DAL like()
operator...to ensure that both pgsql & mysql/sqlite existing apps
didn't break, it could default differently depending on the db type?

Cheers,
Fran.


Re: [web2py] Re: Apply CSS class to form Generated from DAL?

2010-12-06 Thread Andrew Evans
hey ty very much for that worked great :D



On Sun, Dec 5, 2010 at 7:15 PM, mdipierro  wrote:

> db.define_table('thing',Field('color'))
> form = SQLFORM(db.thing)
> form.element('input[name=color]')['_class']='myclass'
> ^ you can use jQuery notation to select elements
> (serverside)
>
>
> On Dec 5, 9:02 pm, Andrew Evans  wrote:
> > hmm ty that applied the class to the form I guess thats what I wrote
> But
> > I mean applying it to an element of the form like an input text tag
> >
> > On Sun, Dec 5, 2010 at 6:49 PM, mr.freeze  wrote:
> > > Like this?:
> > > form = SQLFORM(db.thing, _class='myclass')
> >
> > > On Dec 5, 8:45 pm, Andrew Evans  wrote:
> > > > hello I am trying to do a few things apply a css class and some
> > > javascript
> > > > code to a form generated by DAL ( I believe DAL is the right
> terminology)
> >
> > > > Basically I want to apply a CSS class to a form generated by web2pys
> > > SQLFORM
> > > > or CRUD
> >
> > > > Any ideas
> >
> > > > *cheers
> >
> >
>


[web2py] Re: translation dict name? + my solution

2010-12-06 Thread Richard Vézina
language translation dict*.update(translate_ui_tables_names)

I am reading gluon/languages.py

I can't just do :

in the language file (ex.: fr-fr.py)

{key:vaule}.update(translate_ui_tables_names)

Because the file is updated automatically...

Where could I add my update to the regular process of web2py?

Or trigger a function...

Richard

On Mon, Dec 6, 2010 at 12:30 PM, Richard Vézina  wrote:

> Hello,
>
> I come with that solution... I would have comment...
>
>
> I get my translations like this :
>
> translate_ui_tables_names=dict((r.table_name_en_ui,r.table_name_fr_ui)\
> for r in db().select(db.dict_database.ALL))
>
> Then I just have to :
>
> language translation dict*.append(translate_ui_tables_names)
>
> * Still searching for the name of the dict of the differents language file
> (ex.: fr-ca.py or fr-fr.py)
>
> ;-)
>
> Richard
>
>
>


[web2py] Limit Upload size and File type

2010-12-06 Thread Andrew Evans
Hello I am wondering if there is a way to limit the File type and upload
size in web2py

I have my db field named images and I want to specify just gif, jpg, png for
example :D

As well as a File Size any ideas

*cheers

PS Sorry if this question has been asked before but I couldn't find any info
on this

Thank you


[web2py] Re: Limit Upload size and File type

2010-12-06 Thread Andrew Evans
Nvm I found what I needed :-)

On Mon, Dec 6, 2010 at 10:37 AM, Andrew Evans  wrote:

> Hello I am wondering if there is a way to limit the File type and upload
> size in web2py
>
> I have my db field named images and I want to specify just gif, jpg, png
> for example :D
>
> As well as a File Size any ideas
>
> *cheers
>
> PS Sorry if this question has been asked before but I couldn't find any
> info on this
>
> Thank you
>
>
>


[web2py] Re: new dal

2010-12-06 Thread ron_m
Ok that worked for starting the welcome app. As Jonathan suggests the
self.uri in ConnectionPool.pools[self.uri] needs to be instance.uri as
well.

I will look to see why the application I am working on won't connect
to postgresql - timeout after 5 tries and get back if I find the
cause.

Thanks
Ron

On Dec 6, 9:25 am, mdipierro  wrote:
> please try replace
>
>     @staticmethod
>     def close_all_instances(action):
>         """ to close cleanly databases in a multithreaded environment
> """
>         if not hasattr(thread,'instances'):
>             return
>         while thread.instances:
>             instance = thread.instances.pop()
>             action(instance)
>             # ## if you want pools, recycle this
> connection
>             really = True
>             if instance.pool_size:
>                 sql_locker.acquire()
>                 pool = ConnectionPool.pools[self.uri]
>                 if len(pool) < instance.pool_size:
>                     pool.append(self.connection)
>                     really = False
>                 sql_locker.release()
>             if really:
>                 self.connection.close()
>         return
>
> with
>
>     @staticmethod
>     def close_all_instances(action):
>         """ to close cleanly databases in a multithreaded environment
> """
>         if not hasattr(thread,'instances'):
>             return
>         while thread.instances:
>             instance = thread.instances.pop()
>             action(instance)
>             # ## if you want pools, recycle this
> connection
>             really = True
>             if instance.pool_size:
>                 sql_locker.acquire()
>                 pool = ConnectionPool.pools[self.uri]
>                 if len(pool) < instance.pool_size:
>                     pool.append(instance.connection)
>                     really = False
>                 sql_locker.release()
>             if really:
>                 instance.connection.close()
>         return
>
> I think this is global replace error.
>
> On Dec 6, 11:13 am, ron_m  wrote:
>
> > I did an update of trunk using hg and copied dal.py over sql.py in
> > gluon and start the web2py.py server and still get
>
> > Traceback (most recent call last):
> >   File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> > wsgibase
> >     BaseAdapter.close_all_instances(BaseAdapter.commit)
> >   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> > close_all_instances
> >     self.connection.close()
> > NameError: global name 'self' is not defined
>
> > main is calling BaseAdapter.close_all_instances() as a class method so
> > the self reference at line 276 blows up because there is no instance
> > of a class. I see from the latest post we can test dal.py standalone,
> > are we not to be testing as part of web2py yet because of integration
> > issues?
>
> > Ron
>
> > On Dec 5, 7:11 pm, mdipierro  wrote:
>
> > > started work integrating with gluon/contrib/gql.py do
>
> > > please keep testing dal.py
>
> > > now it no longer requires web2py and you can do
>
> > > % python>>> from dal import DAL, Field
> > > >>> db=DAL('sqlite://file.sqlite')
> > > >>> db.define_table('person',Field('name'))
>
> > > etc etc.
>
> > > you ONLY need dal.py
>
> > > On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > > > in trunk!
>
> > > > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > > > Auth.define_tables doesn't have a fake_migrate attribute so I added
> > > > > one (want a patch?). Once I did, my .table files were re-created when
> > > > > migrate=True and fake_migrate=True. It still works once I set
> > > > > fake_migrate to False. I will test it against the new DAL now.
>
> > > > > On Dec 5, 1:24 pm, mdipierro  wrote:
>
> > > > > > can you try migrate=True, fake_migrate=True?
>
> > > > > > On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>
> > > > > > > I tried and the file modification times of the .table files do not
> > > > > > > change. I deleted them (safely backed up) and they are not 
> > > > > > > re-created.
>
> > > > > > > On Dec 5, 12:56 pm, mdipierro  wrote:
>
> > > > > > > > It is the same. try without delete them.
>
> > > > > > > > On Dec 5, 12:53 pm, "mr.freeze"  wrote:
>
> > > > > > > > > I reverted to the old DAL and did the steps you outlined. 
> > > > > > > > > Same result.
> > > > > > > > > Should I delete the .table files first?
>
> > > > > > > > > On Dec 5, 12:41 pm, mdipierro  wrote:
>
> > > > > > > > > > for the troublesome table (auth_user) set migrate=False,
> > > > > > > > > > fake_migrate=True reload, then migrate=True and remove 
> > > > > > > > > > fake_migrate.
> > > > > > > > > > It should fix your broken .table.
>
> > > > > > > > > > Should work with old and with new dal.
>
> > > > > > > > > > On Dec 5, 11:47 am, "mr.freeze"  
> > > > > > > > > > wrote:
>
> > > > > > > > > > > I seem to remember this failing before though. Something 
> > > > > > > > > > > about
> > > > > > > > > > > my .TABLE files being out of sync. What is the procedure 
>

Re: [web2py] list:integer X list:reference for auth_user table

2010-12-06 Thread Kuba Kucharski
> Field('assigned_to','list:reference auth_user'),
>
> In the case of 2, how to represent as 'db.auth_user.first_name' for multiple
> users

requires=IS_IN_DB(db,'auth_user.id','%(first_name)s',multiple=True)


Re: [web2py] list:integer X list:reference for auth_user table

2010-12-06 Thread Bruno Rocha
So I understand that there are no difference between the two forms, right?

as list:reference and list:integer will store the same in db.

-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: new dal

2010-12-06 Thread mdipierro
Important news!

1) The new DAL (dal.py) passes all the tests I have.
2) The new DAL has integrated GAE support (datastore) without need for
contrib/gql.py
3) The new DAL is better because more customizable, smaller (10%), and
more readable
4) The new DAL is one single file and it does not depend on web2py.
You can use it with other frameworks out of the box without tweaking.

TODO:
- test test test and more tests
- benckmark old dal vs new dal
- replace old dal with new dal in stable web2py

I may keep working on this make more corrections/improvements.

Massimo


On Dec 6, 1:12 pm, ron_m  wrote:
> Ok that worked for starting the welcome app. As Jonathan suggests the
> self.uri in ConnectionPool.pools[self.uri] needs to be instance.uri as
> well.
>
> I will look to see why the application I am working on won't connect
> to postgresql - timeout after 5 tries and get back if I find the
> cause.
>
> Thanks
> Ron
>
> On Dec 6, 9:25 am, mdipierro  wrote:
>
> > please try replace
>
> >     @staticmethod
> >     def close_all_instances(action):
> >         """ to close cleanly databases in a multithreaded environment
> > """
> >         if not hasattr(thread,'instances'):
> >             return
> >         while thread.instances:
> >             instance = thread.instances.pop()
> >             action(instance)
> >             # ## if you want pools, recycle this
> > connection
> >             really = True
> >             if instance.pool_size:
> >                 sql_locker.acquire()
> >                 pool = ConnectionPool.pools[self.uri]
> >                 if len(pool) < instance.pool_size:
> >                     pool.append(self.connection)
> >                     really = False
> >                 sql_locker.release()
> >             if really:
> >                 self.connection.close()
> >         return
>
> > with
>
> >     @staticmethod
> >     def close_all_instances(action):
> >         """ to close cleanly databases in a multithreaded environment
> > """
> >         if not hasattr(thread,'instances'):
> >             return
> >         while thread.instances:
> >             instance = thread.instances.pop()
> >             action(instance)
> >             # ## if you want pools, recycle this
> > connection
> >             really = True
> >             if instance.pool_size:
> >                 sql_locker.acquire()
> >                 pool = ConnectionPool.pools[self.uri]
> >                 if len(pool) < instance.pool_size:
> >                     pool.append(instance.connection)
> >                     really = False
> >                 sql_locker.release()
> >             if really:
> >                 instance.connection.close()
> >         return
>
> > I think this is global replace error.
>
> > On Dec 6, 11:13 am, ron_m  wrote:
>
> > > I did an update of trunk using hg and copied dal.py over sql.py in
> > > gluon and start the web2py.py server and still get
>
> > > Traceback (most recent call last):
> > >   File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> > > wsgibase
> > >     BaseAdapter.close_all_instances(BaseAdapter.commit)
> > >   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> > > close_all_instances
> > >     self.connection.close()
> > > NameError: global name 'self' is not defined
>
> > > main is calling BaseAdapter.close_all_instances() as a class method so
> > > the self reference at line 276 blows up because there is no instance
> > > of a class. I see from the latest post we can test dal.py standalone,
> > > are we not to be testing as part of web2py yet because of integration
> > > issues?
>
> > > Ron
>
> > > On Dec 5, 7:11 pm, mdipierro  wrote:
>
> > > > started work integrating with gluon/contrib/gql.py do
>
> > > > please keep testing dal.py
>
> > > > now it no longer requires web2py and you can do
>
> > > > % python>>> from dal import DAL, Field
> > > > >>> db=DAL('sqlite://file.sqlite')
> > > > >>> db.define_table('person',Field('name'))
>
> > > > etc etc.
>
> > > > you ONLY need dal.py
>
> > > > On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > > > > in trunk!
>
> > > > > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > > > > Auth.define_tables doesn't have a fake_migrate attribute so I added
> > > > > > one (want a patch?). Once I did, my .table files were re-created 
> > > > > > when
> > > > > > migrate=True and fake_migrate=True. It still works once I set
> > > > > > fake_migrate to False. I will test it against the new DAL now.
>
> > > > > > On Dec 5, 1:24 pm, mdipierro  wrote:
>
> > > > > > > can you try migrate=True, fake_migrate=True?
>
> > > > > > > On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>
> > > > > > > > I tried and the file modification times of the .table files do 
> > > > > > > > not
> > > > > > > > change. I deleted them (safely backed up) and they are not 
> > > > > > > > re-created.
>
> > > > > > > > On Dec 5, 12:56 pm, mdipierro  wrote:
>
> > > > > > > > > It is the same. try without delete them.
>
> > > > > > > > > On Dec 5

[web2py] GAE issue with !=

2010-12-06 Thread mdipierro
has anybody been able to use != on GAE? It does not seem to work for
me (always returns False).

Massimo


[web2py] Re: list:integer X list:reference for auth_user table

2010-12-06 Thread mdipierro
yes. the difference is only in the default validator.

On Dec 6, 2:27 pm, Bruno Rocha  wrote:
> So I understand that there are no difference between the two forms, right?
>
> as list:reference and list:integer will store the same in db.
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Limit Upload size and File type

2010-12-06 Thread mdipierro
Yes.

IS_LENGTH(...) works for file size upload
IS_UPLOAD_FILENAME and IS_IMAGE can be used to filter by extension and
content respectively.

On Dec 6, 12:37 pm, Andrew Evans  wrote:
> Hello I am wondering if there is a way to limit the File type and upload
> size in web2py
>
> I have my db field named images and I want to specify just gif, jpg, png for
> example :D
>
> As well as a File Size any ideas
>
> *cheers
>
> PS Sorry if this question has been asked before but I couldn't find any info
> on this
>
> Thank you


Re: [web2py] Re: new dal

2010-12-06 Thread Jonathan Lundell
On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
> 
> 1) The new DAL (dal.py) passes all the tests I have.
> 2) The new DAL has integrated GAE support (datastore) without need for
> contrib/gql.py
> 3) The new DAL is better because more customizable, smaller (10%), and
> more readable
> 4) The new DAL is one single file and it does not depend on web2py.

Have you decided to keep it as a single file, or break it into a package?


[web2py] Registration form

2010-12-06 Thread appydev
Greetings.

I disable the registration form that generated auth:
auth.settings.actions_disabled = ['register']
I made a new registration form that stores information in two tables
(auth_user and teacher), with the help of this recipe:
http://www.web2pyslices.com/main/slices/take_slice/102
But I realized that to do it myself, my form loses functionality when
compared to that generated by default for auth.

To be more specific, I realized that I do not think the "unique group" for
each user (that's no problem because they can easily solve it.)

The question is: Am I missing some other functionality? Am I doing my
registration form less safe?

Thanks.


[web2py] Re: new dal

2010-12-06 Thread mdipierro
I am not sure. There are pros and cons in both cases.

What do you think.

For me it is easier to manage to this way. I tried to break it but it
would require even more re-factoring and I was not sure it was worth
it.

Massimo



On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
> On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
>
>
> > 1) The new DAL (dal.py) passes all the tests I have.
> > 2) The new DAL has integrated GAE support (datastore) without need for
> > contrib/gql.py
> > 3) The new DAL is better because more customizable, smaller (10%), and
> > more readable
> > 4) The new DAL is one single file and it does not depend on web2py.
>
> Have you decided to keep it as a single file, or break it into a package?


[web2py] typo in the book

2010-12-06 Thread Richard Vézina
Hello,

There is a little typo in the book :

http://www.web2py.com/book/default/chapter/04#T-and-Internationalization

Example 5 :


T("blah %(name)s blah") % dict(name='Tim')

I think it should :

T("blah %(name)s blah") % dict(name='Tim'))


Richard


Re: [web2py] typo in the book

2010-12-06 Thread Richard Vézina
No! Forget it... My error!

On Mon, Dec 6, 2010 at 4:40 PM, Richard Vézina
wrote:

> Hello,
>
> There is a little typo in the book :
>
> http://www.web2py.com/book/default/chapter/04#T-and-Internationalization
>
> Example 5 :
>
>
> T("blah %(name)s blah") % dict(name='Tim')
>
> I think it should :
>
> T("blah %(name)s blah") % dict(name='Tim'))
>
>
> Richard
>


Fwd: [web2py] Re: new dal

2010-12-06 Thread Jonathan Lundell

(sent from wrong address)

Begin forwarded message:

> From: Jonathan Lundell 
> Date: December 6, 2010 2:03:54 PM PST
> To: "web2py@googlegroups.com" 
> Subject: Re: [web2py] Re: new dal
> 

> On Dec 6, 2010, at 1:15 PM, mdipierro  wrote:
> 
>> I am not sure. There are pros and cons in both cases.
>> 
>> What do you think.
> 
> On balance, I think I'd break it up, but I don't feel strongly about it. It's 
> a big file, and the extra factoring might help modularity and thus (maybe) 
> readability. 
> 
> It can be useful for a web2py user to read the dal code, since it'll never be 
> practical to squeeze all its functionality into the book(s). So readability 
> is important.
> 
> OTOH there's not a constant need for new adapters and such. So
> 
>> 
>> For me it is easier to manage to this way. I tried to break it but it
>> would require even more re-factoring and I was not sure it was worth
>> it.
>> 
>> Massimo
>> 
>> 
>> 
>> On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>>> On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>>> 
>>> 
>>> 
 1) The new DAL (dal.py) passes all the tests I have.
 2) The new DAL has integrated GAE support (datastore) without need for
 contrib/gql.py
 3) The new DAL is better because more customizable, smaller (10%), and
 more readable
 4) The new DAL is one single file and it does not depend on web2py.
>>> 
>>> Have you decided to keep it as a single file, or break it into a package?


[web2py] orderby='' on Google App Engine

2010-12-06 Thread Albert Abril
Hi!

As said on the book, in a DAL select, orderby='' is not supported on
GAE.
http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-distinct

Someone knows the best way to randomize a Rows dictionary?
(thinking in GAE deployment of course)

Thanks in advance.


[web2py] Re: new dal

2010-12-06 Thread ron_m
Ok I found the cannot connect to PostgreSQL database problem. I have a
password on the user id to access the db in my application so in

class PostgreSQLAdapter(BaseAdapter): function __init__(...)

The re.compile line element for the database password is 'passwd'
which does not match the

password = m.group('password') line for the extraction of this
element of the uri.

The SyntaxError exception is raised but covered up by the 5 times try
for loop in DAL.__init__() higher up the call stack and after 5 1
second sleeps DAL says it cannot connect.

Looking around at the other drivers the m = re.compile line should
have the 'passwd' element of the RE changed to 'password' to be
consistent.

I tested the app after changing and get a lot further into the app but
now see a new fault - will work on that.

Ron



On Dec 6, 11:12 am, ron_m  wrote:
> Ok that worked for starting the welcome app. As Jonathan suggests the
> self.uri in ConnectionPool.pools[self.uri] needs to be instance.uri as
> well.
>
> I will look to see why the application I am working on won't connect
> to postgresql - timeout after 5 tries and get back if I find the
> cause.
>
> Thanks
> Ron
>
> On Dec 6, 9:25 am, mdipierro  wrote:
>
> > please try replace
>
> >     @staticmethod
> >     def close_all_instances(action):
> >         """ to close cleanly databases in a multithreaded environment
> > """
> >         if not hasattr(thread,'instances'):
> >             return
> >         while thread.instances:
> >             instance = thread.instances.pop()
> >             action(instance)
> >             # ## if you want pools, recycle this
> > connection
> >             really = True
> >             if instance.pool_size:
> >                 sql_locker.acquire()
> >                 pool = ConnectionPool.pools[self.uri]
> >                 if len(pool) < instance.pool_size:
> >                     pool.append(self.connection)
> >                     really = False
> >                 sql_locker.release()
> >             if really:
> >                 self.connection.close()
> >         return
>
> > with
>
> >     @staticmethod
> >     def close_all_instances(action):
> >         """ to close cleanly databases in a multithreaded environment
> > """
> >         if not hasattr(thread,'instances'):
> >             return
> >         while thread.instances:
> >             instance = thread.instances.pop()
> >             action(instance)
> >             # ## if you want pools, recycle this
> > connection
> >             really = True
> >             if instance.pool_size:
> >                 sql_locker.acquire()
> >                 pool = ConnectionPool.pools[self.uri]
> >                 if len(pool) < instance.pool_size:
> >                     pool.append(instance.connection)
> >                     really = False
> >                 sql_locker.release()
> >             if really:
> >                 instance.connection.close()
> >         return
>
> > I think this is global replace error.
>
> > On Dec 6, 11:13 am, ron_m  wrote:
>
> > > I did an update of trunk using hg and copied dal.py over sql.py in
> > > gluon and start the web2py.py server and still get
>
> > > Traceback (most recent call last):
> > >   File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> > > wsgibase
> > >     BaseAdapter.close_all_instances(BaseAdapter.commit)
> > >   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> > > close_all_instances
> > >     self.connection.close()
> > > NameError: global name 'self' is not defined
>
> > > main is calling BaseAdapter.close_all_instances() as a class method so
> > > the self reference at line 276 blows up because there is no instance
> > > of a class. I see from the latest post we can test dal.py standalone,
> > > are we not to be testing as part of web2py yet because of integration
> > > issues?
>
> > > Ron
>
> > > On Dec 5, 7:11 pm, mdipierro  wrote:
>
> > > > started work integrating with gluon/contrib/gql.py do
>
> > > > please keep testing dal.py
>
> > > > now it no longer requires web2py and you can do
>
> > > > % python>>> from dal import DAL, Field
> > > > >>> db=DAL('sqlite://file.sqlite')
> > > > >>> db.define_table('person',Field('name'))
>
> > > > etc etc.
>
> > > > you ONLY need dal.py
>
> > > > On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > > > > in trunk!
>
> > > > > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > > > > Auth.define_tables doesn't have a fake_migrate attribute so I added
> > > > > > one (want a patch?). Once I did, my .table files were re-created 
> > > > > > when
> > > > > > migrate=True and fake_migrate=True. It still works once I set
> > > > > > fake_migrate to False. I will test it against the new DAL now.
>
> > > > > > On Dec 5, 1:24 pm, mdipierro  wrote:
>
> > > > > > > can you try migrate=True, fake_migrate=True?
>
> > > > > > > On Dec 5, 1:05 pm, "mr.freeze"  wrote:
>
> > > > > > > > I tried and the file modification times of the .table files do 
> > > > > > > 

[web2py] Re: new dal

2010-12-06 Thread mdipierro
Fixed in trunk. Thanks for testing

On Dec 6, 4:19 pm, ron_m  wrote:
> Ok I found the cannot connect to PostgreSQL database problem. I have a
> password on the user id to access the db in my application so in
>
> class PostgreSQLAdapter(BaseAdapter): function __init__(...)
>
> The re.compile line element for the database password is 'passwd'
> which does not match the
>
>         password = m.group('password') line for the extraction of this
> element of the uri.
>
> The SyntaxError exception is raised but covered up by the 5 times try
> for loop in DAL.__init__() higher up the call stack and after 5 1
> second sleeps DAL says it cannot connect.
>
> Looking around at the other drivers the m = re.compile line should
> have the 'passwd' element of the RE changed to 'password' to be
> consistent.
>
> I tested the app after changing and get a lot further into the app but
> now see a new fault - will work on that.
>
> Ron
>
> On Dec 6, 11:12 am, ron_m  wrote:
>
> > Ok that worked for starting the welcome app. As Jonathan suggests the
> > self.uri in ConnectionPool.pools[self.uri] needs to be instance.uri as
> > well.
>
> > I will look to see why the application I am working on won't connect
> > to postgresql - timeout after 5 tries and get back if I find the
> > cause.
>
> > Thanks
> > Ron
>
> > On Dec 6, 9:25 am, mdipierro  wrote:
>
> > > please try replace
>
> > >     @staticmethod
> > >     def close_all_instances(action):
> > >         """ to close cleanly databases in a multithreaded environment
> > > """
> > >         if not hasattr(thread,'instances'):
> > >             return
> > >         while thread.instances:
> > >             instance = thread.instances.pop()
> > >             action(instance)
> > >             # ## if you want pools, recycle this
> > > connection
> > >             really = True
> > >             if instance.pool_size:
> > >                 sql_locker.acquire()
> > >                 pool = ConnectionPool.pools[self.uri]
> > >                 if len(pool) < instance.pool_size:
> > >                     pool.append(self.connection)
> > >                     really = False
> > >                 sql_locker.release()
> > >             if really:
> > >                 self.connection.close()
> > >         return
>
> > > with
>
> > >     @staticmethod
> > >     def close_all_instances(action):
> > >         """ to close cleanly databases in a multithreaded environment
> > > """
> > >         if not hasattr(thread,'instances'):
> > >             return
> > >         while thread.instances:
> > >             instance = thread.instances.pop()
> > >             action(instance)
> > >             # ## if you want pools, recycle this
> > > connection
> > >             really = True
> > >             if instance.pool_size:
> > >                 sql_locker.acquire()
> > >                 pool = ConnectionPool.pools[self.uri]
> > >                 if len(pool) < instance.pool_size:
> > >                     pool.append(instance.connection)
> > >                     really = False
> > >                 sql_locker.release()
> > >             if really:
> > >                 instance.connection.close()
> > >         return
>
> > > I think this is global replace error.
>
> > > On Dec 6, 11:13 am, ron_m  wrote:
>
> > > > I did an update of trunk using hg and copied dal.py over sql.py in
> > > > gluon and start the web2py.py server and still get
>
> > > > Traceback (most recent call last):
> > > >   File "/home/camcentral/Dev/web2py_hg/gluon/main.py", line 446, in
> > > > wsgibase
> > > >     BaseAdapter.close_all_instances(BaseAdapter.commit)
> > > >   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 276, in
> > > > close_all_instances
> > > >     self.connection.close()
> > > > NameError: global name 'self' is not defined
>
> > > > main is calling BaseAdapter.close_all_instances() as a class method so
> > > > the self reference at line 276 blows up because there is no instance
> > > > of a class. I see from the latest post we can test dal.py standalone,
> > > > are we not to be testing as part of web2py yet because of integration
> > > > issues?
>
> > > > Ron
>
> > > > On Dec 5, 7:11 pm, mdipierro  wrote:
>
> > > > > started work integrating with gluon/contrib/gql.py do
>
> > > > > please keep testing dal.py
>
> > > > > now it no longer requires web2py and you can do
>
> > > > > % python>>> from dal import DAL, Field
> > > > > >>> db=DAL('sqlite://file.sqlite')
> > > > > >>> db.define_table('person',Field('name'))
>
> > > > > etc etc.
>
> > > > > you ONLY need dal.py
>
> > > > > On Dec 5, 1:56 pm, mdipierro  wrote:
>
> > > > > > in trunk!
>
> > > > > > On Dec 5, 1:38 pm, "mr.freeze"  wrote:
>
> > > > > > > Auth.define_tables doesn't have a fake_migrate attribute so I 
> > > > > > > added
> > > > > > > one (want a patch?). Once I did, my .table files were re-created 
> > > > > > > when
> > > > > > > migrate=True and fake_migrate=True. It still works once I set
> > > > > > > fake_migrate to Fals

[web2py] Re: new dal

2010-12-06 Thread ron_m
Put dal.py over sql.py in trunk
Start server python web2py.py
Get welcome app in browser
Hit login link get ticket.

I also get this in my own application trying to login.

Field does not have attribute _tablename

Ron

Traceback (most recent call last):
  File "/home/camcentral/Dev/web2py_hg/gluon/restricted.py", line 188,
in restricted
exec ccode in environment
  File "/home/camcentral/Dev/web2py_hg/applications/welcome/
controllers/default.py", line 56, in 
  File "/home/camcentral/Dev/web2py_hg/gluon/globals.py", line 95, in

self._caller = lambda f: f()
  File "/home/camcentral/Dev/web2py_hg/applications/welcome/
controllers/default.py", line 33, in user
return dict(form=auth())
  File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1025, in
__call__
return self.login()
  File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1395, in
login
formstyle=self.settings.formstyle
  File "/home/camcentral/Dev/web2py_hg/gluon/sqlhtml.py", line 810, in
__init__
inp = self.widgets.string.widget(field, default)
  File "/home/camcentral/Dev/web2py_hg/gluon/sqlhtml.py", line 103, in
widget
attr = StringWidget._attributes(field, default, **attributes)
  File "/home/camcentral/Dev/web2py_hg/gluon/sqlhtml.py", line 62, in
_attributes
_id = '%s_%s' % (field._tablename, field.name),
AttributeError: 'Field' object has no attribute '_tablename'


[web2py] Re: new dal

2010-12-06 Thread mdipierro
With the new DAL it should take very little to create a DAL interface
to mongodb, couchdb, etc.

I can work on this if
- you help me prioritize
- you can give me access to a machine that already has your favorite
nosql db installed ready for testing

Massimo


On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
> On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
>
>
> > 1) The new DAL (dal.py) passes all the tests I have.
> > 2) The new DAL has integrated GAE support (datastore) without need for
> > contrib/gql.py
> > 3) The new DAL is better because more customizable, smaller (10%), and
> > more readable
> > 4) The new DAL is one single file and it does not depend on web2py.
>
> Have you decided to keep it as a single file, or break it into a package?


[web2py] How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
HI,

I have a 'category' table:

db.define_table('category',
Field('name',label=T('Name')),
signature,
format='%(name)s'
)

which I defined a label for the field 'name'

I need to create something like:

list = plugin_datatable(db(db.category.id>0).select(db.category.id,
db.category.name),
_class='datatable',
headers = {'category.name':T('Name')},
)

Is there a way to pass my previously defined labels to the SQLTABLE?

where the 'labels' are stored? I tried db.category.labels,
db.category['labels'] ?

Thanks

-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: orderby='' on Google App Engine

2010-12-06 Thread mdipierro
import random
...
rows=db(...).select().sort(lambda row: random.random())

On Dec 6, 4:09 pm, Albert Abril  wrote:
> Hi!
>
> As said on the book, in a DAL select, orderby='' is not supported on
> GAE.http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-...
>
> Someone knows the best way to randomize a Rows dictionary?
> (thinking in GAE deployment of course)
>
> Thanks in advance.


[web2py] Re: Interesting fights

2010-12-06 Thread villas
'fat and ugly' is 3 times more popular than 'slim and sexy'

Does that give the 'django' vs 'web2py' fight a different perspective?

-D


Re: [web2py] Re: orderby='' on Google App Engine

2010-12-06 Thread Albert Abril
I didn't know i could use imports in GAE
Thank you Massimo.


On Mon, Dec 6, 2010 at 11:53 PM, mdipierro  wrote:

> import random
> ...
> rows=db(...).select().sort(lambda row: random.random())
>
> On Dec 6, 4:09 pm, Albert Abril  wrote:
> > Hi!
> >
> > As said on the book, in a DAL select, orderby='' is not supported
> on
> > GAE.
> http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-...
> >
> > Someone knows the best way to randomize a Rows dictionary?
> > (thinking in GAE deployment of course)
> >
> > Thanks in advance.
>


[web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
OK, I found that labels are in db.fieldname.label, now I just have to create
a dict.

2010/12/6 Bruno Rocha 

> HI,
>
> I have a 'category' table:
>
> db.define_table('category',
> Field('name',label=T('Name')),
> signature,
> format='%(name)s'
> )
>
> which I defined a label for the field 'name'
>
> I need to create something like:
>
> list = plugin_datatable(db(db.category.id>0).select(db.category.id,
> db.category.name),
> _class='datatable',
> headers = {'category.name':T('Name')},
> )
>
> Is there a way to pass my previously defined labels to the SQLTABLE?
>
> where the 'labels' are stored? I tried db.category.labels,
> db.category['labels'] ?
>
> Thanks
>
> --
>
> Bruno Rocha
> http://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: Interesting fights

2010-12-06 Thread mdipierro
LOL

On Dec 6, 5:15 pm, villas  wrote:
> 'fat and ugly' is 3 times more popular than 'slim and sexy'
>
> Does that give the 'django' vs 'web2py' fight a different perspective?
>
> -D


[web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
The problem is solved in this way:

>>> headers = {}
>>> for field in db['category'].fields:
... headers['category.'+field] =db['category'][field].label
...
>>> headers
{'category.created_on': 'Created On', 'updated_by': 'Updated By',
'category.updated_on': 'Updated On', 'category.created_by': 'Created By',
'created_by': 'Created By', 'category.name': , 'created_on':
'Created On', 'category.updated_by': 'Updated By', 'category.id': 'Id',
'updated_on': 'Updated On', 'id': 'Id', 'name': }


So I think it is easy to have an headers='fieldlabel:capitalize' in the same
form we have 'fieldname:capitalize'


2010/12/6 Bruno Rocha 

> OK, I found that labels are in db.fieldname.label, now I just have to
> create a dict.
>
> 2010/12/6 Bruno Rocha 
>
> HI,
>>
>> I have a 'category' table:
>>
>> db.define_table('category',
>> Field('name',label=T('Name')),
>> signature,
>> format='%(name)s'
>> )
>>
>> which I defined a label for the field 'name'
>>
>> I need to create something like:
>>
>> list = plugin_datatable(db(db.category.id>0).select(db.category.id,
>> db.category.name),
>> _class='datatable',
>> headers = {'category.name':T('Name')},
>> )
>>
>> Is there a way to pass my previously defined labels to the SQLTABLE?
>>
>> where the 'labels' are stored? I tried db.category.labels,
>> db.category['labels'] ?
>>
>> Thanks
>>
>> --
>>
>> Bruno Rocha
>> http://about.me/rochacbruno/bio
>>
>
>
>
> --
>
> Bruno Rocha
> http://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread mdipierro
if you make a form there is a dict in form.custom.label[fielname] or
form.custom.label.fielname

On Dec 6, 5:19 pm, Bruno Rocha  wrote:
> OK, I found that labels are in db.fieldname.label, now I just have to create
> a dict.
>
> 2010/12/6 Bruno Rocha 
>
>
>
>
>
>
>
> > HI,
>
> > I have a 'category' table:
>
> > db.define_table('category',
> >                 Field('name',label=T('Name')),
> >                 signature,
> >                 format='%(name)s'
> >                 )
>
> > which I defined a label for the field 'name'
>
> > I need to create something like:
>
> > list = plugin_datatable(db(db.category.id>0).select(db.category.id,
> > db.category.name),
> >                             _class='datatable',
> >                             headers = {'category.name':T('Name')},
> >                             )
>
> > Is there a way to pass my previously defined labels to the SQLTABLE?
>
> > where the 'labels' are stored? I tried db.category.labels,
> > db.category['labels'] ?
>
> > Thanks
>
> > --
>
> > Bruno Rocha
> >http://about.me/rochacbruno/bio
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio


Re: [web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
I do not want a form, a need to use the plugin_datatable.

Finally what I did:

# In models
def get_header_labels(table=None):
headers = {}
for field in db[table].fields:
headers[table+'.'+field] = db[table][field].label
return headers


# in My view/controller

list = SQLTABLE(db(db.category.id>0). select(db.category.id,db.category.name
),
headers = get_header_labels('category'))






2010/12/6 mdipierro 

> if you make a form there is a dict in form.custom.label[fielname] or
> form.custom.label.fielname
>
> On Dec 6, 5:19 pm, Bruno Rocha  wrote:
> > OK, I found that labels are in db.fieldname.label, now I just have to
> create
> > a dict.
> >
> > 2010/12/6 Bruno Rocha 
> >
> >
> >
> >
> >
> >
> >
> > > HI,
> >
> > > I have a 'category' table:
> >
> > > db.define_table('category',
> > > Field('name',label=T('Name')),
> > > signature,
> > > format='%(name)s'
> > > )
> >
> > > which I defined a label for the field 'name'
> >
> > > I need to create something like:
> >
> > > list = plugin_datatable(db(db.category.id>0).select(db.category.id,
> > > db.category.name),
> > > _class='datatable',
> > > headers = {'category.name':T('Name')},
> > > )
> >
> > > Is there a way to pass my previously defined labels to the SQLTABLE?
> >
> > > where the 'labels' are stored? I tried db.category.labels,
> > > db.category['labels'] ?
> >
> > > Thanks
> >
> > > --
> >
> > > Bruno Rocha
> > >http://about.me/rochacbruno/bio
> >
> > --
> >
> > Bruno Rochahttp://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: orderby='' on Google App Engine

2010-12-06 Thread mdipierro
and you can put your own modules in web2py/site-packages and they will
be deployed with your app.

On Dec 6, 5:16 pm, Albert Abril  wrote:
> I didn't know i could use imports in GAE
> Thank you Massimo.
>
> On Mon, Dec 6, 2010 at 11:53 PM, mdipierro  wrote:
> > import random
> > ...
> > rows=db(...).select().sort(lambda row: random.random())
>
> > On Dec 6, 4:09 pm, Albert Abril  wrote:
> > > Hi!
>
> > > As said on the book, in a DAL select, orderby='' is not supported
> > on
> > > GAE.
> >http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-...
>
> > > Someone knows the best way to randomize a Rows dictionary?
> > > (thinking in GAE deployment of course)
>
> > > Thanks in advance.
>
>


[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread villas
Hi tomt

I believe it takes the fields from the specified source table and
lines them up with a target table.  Any fields which don't match and
the id are discarded.

What Denes means is that it wouldn't work when for example you use
form.vars from multiple tables which have some identical field names.
In that case, when it filters through the form.vars it doesn't know
which field comes from which table.

Hope that's right :)

-D

On Dec 5, 10:07 pm, tomt  wrote:
> Hi,
>
> I'm unfamiliar with _filter_fields. I couldn't find it in the manual
> but eventually found it in the source in gluon/tools.py.
> Am I correct in assuming it is intended to return everything but the
> id field from a record? (I've just started to learn python)
>
> Is there some documentation available for this? I've tried some of the
> urls in the help and resources post:
>  http://web2py.com/examples/default/dal
>  http://web2py.com/examples/default/api
>  http://web2py.com/examples/default/tools
>
> But I just get "invalid function"
>
> Thanks in advance,
>   - Tom
>
> On Dec 5, 7:00 am, villas  wrote:
>
>
>
>
>
> > Hi Nathan
>
> > Just a small point, I tried your code example and it seems you have to
> > set id==None otherwise it tries to add a duplicate row with the same
> > id.
>
> > Anyway, I thought you also might like this alternative using
> > _filter_fields, just because it's shorter. Maybe it's got other
> > issues,  but it seems to work!
>
> > def things():
> >     form = SQLFORM(db.things)
> >     if form.accepts(request.vars,session):
> >         response.flash = 'Added a thing'
> >     if request.vars.dupe:
>
> > db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
> >     things = db(db.things.id>0).select()
> >     return dict(form=form,things=things)
>
> > Best regards,
> > -D
>
> > On Dec 4, 3:30 am, "mr.freeze"  wrote:
>
> > > Here is an example:
>
> > > Model
> > > -
> > > db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
> > >                 Field('age','integer'),Field('weight','double'))
> > > db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
> > >                                      _onclick='return confirm("Copy
> > > %s?")' % v)
>
> > > Controller
> > > --
> > > def index():
> > >     form = SQLFORM(db.things)
> > >     if form.accepts(request.vars,session):
> > >         response.flash = 'Added a thing'
> > >     if request.vars.dupe:
> > >         record = db.things(request.vars.dupe)
> > >         vals = {}
> > >         for k,v in record.items():
> > >             if k in db.things.fields:
> > >                 vals[k] = v
> > >         db.things.insert(**vals)
> > >     things = db(db.things.id>0).select()
> > >     return dict(form=form,things=things)
>
> > > On Dec 3, 6:12 pm, tomt  wrote:
>
> > > > Hi,
>
> > > > I've started to write a simple application to learn web2py. I am using
> > > > SQLFORM to insert, modify and delete records. So far everything is
> > > > working as planned.
>
> > > > I would like to give the user the ability add a new record as a copy
> > > > of an existing one.  The idea is that the user would view an existing
> > > > record, modify a couple fields, and select 'copy' which result in
> > > > adding a new record.
>
> > > > I assume that this requires additional code, and I was hoping that
> > > > someone would suggest an example, or let me know if SQLFORM can do
> > > > this automatically.
>
> > > > Thanks in advance,
>
> > > > - Tom
>
>


[web2py] Re: Interesting fights

2010-12-06 Thread Anthony
Awkward timing. Don't let Reddit[1] find out about these "fights". :)

[1] 
http://www.reddit.com/r/Python/comments/edvws/an_often_asked_question_to_which_i_still_dont/c17mxpx



On Dec 6, 11:57 am, Branko Vukelic  wrote:
> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...
>
> :)
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


[web2py] Re: new dal

2010-12-06 Thread mdipierro
For now, for testing purposes I am going to copy dal.py over sql.py
and post a nightly build using the new dal.

Long term, is this ia good solution. I would like to keep both sql.py
and dal.py and import DAL, Field from the latter but this would break
existing "from gluon.sql import *". In order not to break it, the
current approach is the only approach (replace the old dal with the
new dal and call it sql.py).

Any opinion on this matter?

Massimo

On Dec 6, 4:38 pm, mdipierro  wrote:
> With the new DAL it should take very little to create a DAL interface
> to mongodb, couchdb, etc.
>
> I can work on this if
> - you help me prioritize
> - you can give me access to a machine that already has your favorite
> nosql db installed ready for testing
>
> Massimo
>
> On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>
> > On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
> > > 1) The new DAL (dal.py) passes all the tests I have.
> > > 2) The new DAL has integrated GAE support (datastore) without need for
> > > contrib/gql.py
> > > 3) The new DAL is better because more customizable, smaller (10%), and
> > > more readable
> > > 4) The new DAL is one single file and it does not depend on web2py.
>
> > Have you decided to keep it as a single file, or break it into a package?
>
>


[web2py] Re: new dal

2010-12-06 Thread mdipierro
both trunk and the nightly built in the web2py download page use the
new dal as opposed to the old one.
Please give it a try. Specifically if you are using something other
than sqlite.
please report any test you make. It is critical to know if this works
fine because I am planning to remove completely the old dal as soon as
possible.

Massimo

On Dec 6, 6:08 pm, mdipierro  wrote:
> For now, for testing purposes I am going to copy dal.py over sql.py
> and post a nightly build using the new dal.
>
> Long term, is this ia good solution. I would like to keep both sql.py
> and dal.py and import DAL, Field from the latter but this would break
> existing "from gluon.sql import *". In order not to break it, the
> current approach is the only approach (replace the old dal with the
> new dal and call it sql.py).
>
> Any opinion on this matter?
>
> Massimo
>
> On Dec 6, 4:38 pm, mdipierro  wrote:
>
> > With the new DAL it should take very little to create a DAL interface
> > to mongodb, couchdb, etc.
>
> > I can work on this if
> > - you help me prioritize
> > - you can give me access to a machine that already has your favorite
> > nosql db installed ready for testing
>
> > Massimo
>
> > On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>
> > > On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
> > > > 1) The new DAL (dal.py) passes all the tests I have.
> > > > 2) The new DAL has integrated GAE support (datastore) without need for
> > > > contrib/gql.py
> > > > 3) The new DAL is better because more customizable, smaller (10%), and
> > > > more readable
> > > > 4) The new DAL is one single file and it does not depend on web2py.
>
> > > Have you decided to keep it as a single file, or break it into a package?
>
>


[web2py] Re: new dal

2010-12-06 Thread villas
Providing that it's backwards compatible, you don't need to ask.
IMO test, upgrade, then never look back!
-D

On Dec 7, 12:08 am, mdipierro  wrote:
> For now, for testing purposes I am going to copy dal.py over sql.py
> and post a nightly build using the new dal.
>
> Long term, is this ia good solution. I would like to keep both sql.py
> and dal.py and import DAL, Field from the latter but this would break
> existing "from gluon.sql import *". In order not to break it, the
> current approach is the only approach (replace the old dal with the
> new dal and call it sql.py).
>
> Any opinion on this matter?
>
> Massimo
>
> On Dec 6, 4:38 pm, mdipierro  wrote:
>
> > With the new DAL it should take very little to create a DAL interface
> > to mongodb, couchdb, etc.
>
> > I can work on this if
> > - you help me prioritize
> > - you can give me access to a machine that already has your favorite
> > nosql db installed ready for testing
>
> > Massimo
>
> > On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>
> > > On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
> > > > 1) The new DAL (dal.py) passes all the tests I have.
> > > > 2) The new DAL has integrated GAE support (datastore) without need for
> > > > contrib/gql.py
> > > > 3) The new DAL is better because more customizable, smaller (10%), and
> > > > more readable
> > > > 4) The new DAL is one single file and it does not depend on web2py.
>
> > > Have you decided to keep it as a single file, or break it into a package?
>
>


Re: [web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
One more time:

in sqlhtml.py we have:

if headers=='fieldname:capitalize':headers = {}
for c in columns:headers[c] = ' '.join([w.capitalize()
for w in c.split('.')[-1].split('_')])


so what about including the peace of code I mentioned?


if headers=='labels':
headers = {}
for c in columns:
tablename = ' '.join([w for w in c.split('.')[0].split('_')])
fieldname = ' '.join([w for w in c.split('.')[-1].split('_')])
headers[c] = sqlrows.db[tablename][fieldname].label





2010/12/6 Bruno Rocha 

> I do not want a form, a need to use the plugin_datatable.
>
> Finally what I did:
>
> # In models
> def get_header_labels(table=None):
> headers = {}
> for field in db[table].fields:
> headers[table+'.'+field] = db[table][field].label
> return headers
>
>
> # in My view/controller
>
> list = SQLTABLE(db(db.category.id>0). select(db.category.id,
> db.category.name),
> headers = get_header_labels('category'))
>
>
>
>
>
>
> 2010/12/6 mdipierro 
>
> if you make a form there is a dict in form.custom.label[fielname] or
>> form.custom.label.fielname
>>
>> On Dec 6, 5:19 pm, Bruno Rocha  wrote:
>> > OK, I found that labels are in db.fieldname.label, now I just have to
>> create
>> > a dict.
>> >
>> > 2010/12/6 Bruno Rocha 
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > HI,
>> >
>> > > I have a 'category' table:
>> >
>> > > db.define_table('category',
>> > > Field('name',label=T('Name')),
>> > > signature,
>> > > format='%(name)s'
>> > > )
>> >
>> > > which I defined a label for the field 'name'
>> >
>> > > I need to create something like:
>> >
>> > > list = plugin_datatable(db(db.category.id>0).select(db.category.id,
>> > > db.category.name),
>> > > _class='datatable',
>> > > headers = {'category.name':T('Name')},
>> > > )
>> >
>> > > Is there a way to pass my previously defined labels to the SQLTABLE?
>> >
>> > > where the 'labels' are stored? I tried db.category.labels,
>> > > db.category['labels'] ?
>> >
>> > > Thanks
>> >
>> > > --
>> >
>> > > Bruno Rocha
>> > >http://about.me/rochacbruno/bio
>> >
>> > --
>> >
>> > Bruno Rochahttp://about.me/rochacbruno/bio
>>
>
>
>
> --
>
> Bruno Rocha
> http://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


Re: [web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
This is how I changed SQLTABLE class

http://snipt.net/rochacbruno/sqltable



2010/12/6 Bruno Rocha 

> One more time:
>
> in sqlhtml.py we have:
>
> if headers=='fieldname:capitalize':headers = {}for c 
> in columns:headers[c] = ' '.join([w.capitalize() for w in 
> c.split('.')[-1].split('_')])
>
>
> so what about including the peace of code I mentioned?
>
>
> if headers=='labels':
> headers = {}
> for c in columns:
> tablename = ' '.join([w for w in c.split('.')[0].split('_')])
> fieldname = ' '.join([w for w in c.split('.')[-1].split('_')])
> headers[c] = sqlrows.db[tablename][fieldname].label
>
>
>
>
>
> 2010/12/6 Bruno Rocha 
>
> I do not want a form, a need to use the plugin_datatable.
>>
>> Finally what I did:
>>
>> # In models
>> def get_header_labels(table=None):
>> headers = {}
>> for field in db[table].fields:
>> headers[table+'.'+field] = db[table][field].label
>> return headers
>>
>>
>> # in My view/controller
>>
>> list = SQLTABLE(db(db.category.id>0). select(db.category.id,
>> db.category.name),
>> headers = get_header_labels('category'))
>>
>>
>>
>>
>>
>>
>> 2010/12/6 mdipierro 
>>
>> if you make a form there is a dict in form.custom.label[fielname] or
>>> form.custom.label.fielname
>>>
>>> On Dec 6, 5:19 pm, Bruno Rocha  wrote:
>>> > OK, I found that labels are in db.fieldname.label, now I just have to
>>> create
>>> > a dict.
>>> >
>>> > 2010/12/6 Bruno Rocha 
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > HI,
>>> >
>>> > > I have a 'category' table:
>>> >
>>> > > db.define_table('category',
>>> > > Field('name',label=T('Name')),
>>> > > signature,
>>> > > format='%(name)s'
>>> > > )
>>> >
>>> > > which I defined a label for the field 'name'
>>> >
>>> > > I need to create something like:
>>> >
>>> > > list = plugin_datatable(db(db.category.id>0).select(db.category.id,
>>> > > db.category.name),
>>> > > _class='datatable',
>>> > > headers = {'category.name':T('Name')},
>>> > > )
>>> >
>>> > > Is there a way to pass my previously defined labels to the SQLTABLE?
>>> >
>>> > > where the 'labels' are stored? I tried db.category.labels,
>>> > > db.category['labels'] ?
>>> >
>>> > > Thanks
>>> >
>>> > > --
>>> >
>>> > > Bruno Rocha
>>> > >http://about.me/rochacbruno/bio
>>> >
>>> > --
>>> >
>>> > Bruno Rochahttp://about.me/rochacbruno/bio
>>>
>>
>>
>>
>> --
>>
>> Bruno Rocha
>> http://about.me/rochacbruno/bio
>>
>
>
>
> --
>
> Bruno Rocha
> http://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: new dal

2010-12-06 Thread mdipierro
Here is some more info about the new DAL

http://web2py.com/examples/static/new_dal_help.pdf

hope it helps read the source code.

Massimo

On Dec 6, 6:08 pm, mdipierro  wrote:
> For now, for testing purposes I am going to copy dal.py over sql.py
> and post a nightly build using the new dal.
>
> Long term, is this ia good solution. I would like to keep both sql.py
> and dal.py and import DAL, Field from the latter but this would break
> existing "from gluon.sql import *". In order not to break it, the
> current approach is the only approach (replace the old dal with the
> new dal and call it sql.py).
>
> Any opinion on this matter?
>
> Massimo
>
> On Dec 6, 4:38 pm, mdipierro  wrote:
>
> > With the new DAL it should take very little to create a DAL interface
> > to mongodb, couchdb, etc.
>
> > I can work on this if
> > - you help me prioritize
> > - you can give me access to a machine that already has your favorite
> > nosql db installed ready for testing
>
> > Massimo
>
> > On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>
> > > On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
> > > > 1) The new DAL (dal.py) passes all the tests I have.
> > > > 2) The new DAL has integrated GAE support (datastore) without need for
> > > > contrib/gql.py
> > > > 3) The new DAL is better because more customizable, smaller (10%), and
> > > > more readable
> > > > 4) The new DAL is one single file and it does not depend on web2py.
>
> > > Have you decided to keep it as a single file, or break it into a package?
>
>


Re: [web2py] Re: new dal

2010-12-06 Thread Vasile Ermicioi
I am testing new dal (alone, without web2py) and also tested one old idea -
I use pymysql instead of MySQLdb, and it works fine with python (2.7) and
jython (2.5rc2)

why not integrating it on web2py, I think that makes web2py what it claims
to be "requires no installation"
also it seems to have a good performance
http://code.google.com/p/pymysql/wiki/Performance

just replace 2 lines:

import MySQLdb
with
import pymysql

and

charset=charset: MySQLdb.Connection(db=db,
with
charset=charset: pymysql.connect(db=db,


[web2py] Re: new dal

2010-12-06 Thread mdipierro
That is the point. I think it is fully backward compatible but the
source is so different that it is possible something breaks. Nothing
that cannot be fixed but I'd rather fix it sooner than later.

On Dec 6, 6:24 pm, villas  wrote:
> Providing that it's backwards compatible, you don't need to ask.
> IMO test, upgrade, then never look back!
> -D
>
> On Dec 7, 12:08 am, mdipierro  wrote:
>
> > For now, for testing purposes I am going to copy dal.py over sql.py
> > and post a nightly build using the new dal.
>
> > Long term, is this ia good solution. I would like to keep both sql.py
> > and dal.py and import DAL, Field from the latter but this would break
> > existing "from gluon.sql import *". In order not to break it, the
> > current approach is the only approach (replace the old dal with the
> > new dal and call it sql.py).
>
> > Any opinion on this matter?
>
> > Massimo
>
> > On Dec 6, 4:38 pm, mdipierro  wrote:
>
> > > With the new DAL it should take very little to create a DAL interface
> > > to mongodb, couchdb, etc.
>
> > > I can work on this if
> > > - you help me prioritize
> > > - you can give me access to a machine that already has your favorite
> > > nosql db installed ready for testing
>
> > > Massimo
>
> > > On Dec 6, 3:10 pm, Jonathan Lundell  wrote:
>
> > > > On Dec 6, 2010, at 12:55 PM, mdipierro wrote:
>
> > > > > 1) The new DAL (dal.py) passes all the tests I have.
> > > > > 2) The new DAL has integrated GAE support (datastore) without need for
> > > > > contrib/gql.py
> > > > > 3) The new DAL is better because more customizable, smaller (10%), and
> > > > > more readable
> > > > > 4) The new DAL is one single file and it does not depend on web2py.
>
> > > > Have you decided to keep it as a single file, or break it into a 
> > > > package?
>
>


[web2py] Re: new dal

2010-12-06 Thread mdipierro
No objection. We will default to the new one if it is installed of the
latter otherwise


On Dec 6, 6:36 pm, Vasile Ermicioi  wrote:
> I am testing new dal (alone, without web2py) and also tested one old idea -
> I use pymysql instead of MySQLdb, and it works fine with python (2.7) and
> jython (2.5rc2)
>
> why not integrating it on web2py, I think that makes web2py what it claims
> to be "requires no installation"
> also it seems to have a good 
> performancehttp://code.google.com/p/pymysql/wiki/Performance
>
> just replace 2 lines:
>
> import MySQLdb
> with
> import pymysql
>
> and
>
> charset=charset: MySQLdb.Connection(db=db,
> with
> charset=charset: pymysql.connect(db=db,


[web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread mdipierro
send me a patch.

On Dec 6, 6:29 pm, Bruno Rocha  wrote:
> One more time:
>
> in sqlhtml.py we have:
>
> if headers=='fieldname:capitalize':            headers = {}
> for c in columns:                headers[c] = ' '.join([w.capitalize()
> for w in c.split('.')[-1].split('_')])
>
> so what about including the peace of code I mentioned?
>
> if headers=='labels':
>             headers = {}
>             for c in columns:
>                 tablename = ' '.join([w for w in c.split('.')[0].split('_')])
>                 fieldname = ' '.join([w for w in c.split('.')[-1].split('_')])
>                 headers[c] = sqlrows.db[tablename][fieldname].label
>
> 2010/12/6 Bruno Rocha 
>
>
>
> > I do not want a form, a need to use the plugin_datatable.
>
> > Finally what I did:
>
> > # In models
> > def get_header_labels(table=None):
> >     headers = {}
> >     for field in db[table].fields:
> >         headers[table+'.'+field] = db[table][field].label
> >     return headers
>
> > # in My view/controller
>
> > list = SQLTABLE(db(db.category.id>0). select(db.category.id,
> > db.category.name),
> >                             headers = get_header_labels('category'))
>
> > 2010/12/6 mdipierro 
>
> > if you make a form there is a dict in form.custom.label[fielname] or
> >> form.custom.label.fielname
>
> >> On Dec 6, 5:19 pm, Bruno Rocha  wrote:
> >> > OK, I found that labels are in db.fieldname.label, now I just have to
> >> create
> >> > a dict.
>
> >> > 2010/12/6 Bruno Rocha 
>
> >> > > HI,
>
> >> > > I have a 'category' table:
>
> >> > > db.define_table('category',
> >> > >                 Field('name',label=T('Name')),
> >> > >                 signature,
> >> > >                 format='%(name)s'
> >> > >                 )
>
> >> > > which I defined a label for the field 'name'
>
> >> > > I need to create something like:
>
> >> > > list = plugin_datatable(db(db.category.id>0).select(db.category.id,
> >> > > db.category.name),
> >> > >                             _class='datatable',
> >> > >                             headers = {'category.name':T('Name')},
> >> > >                             )
>
> >> > > Is there a way to pass my previously defined labels to the SQLTABLE?
>
> >> > > where the 'labels' are stored? I tried db.category.labels,
> >> > > db.category['labels'] ?
>
> >> > > Thanks
>
> >> > > --
>
> >> > > Bruno Rocha
> >> > >http://about.me/rochacbruno/bio
>
> >> > --
>
> >> > Bruno Rochahttp://about.me/rochacbruno/bio
>
> > --
>
> > Bruno Rocha
> >http://about.me/rochacbruno/bio
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio


Re: [web2py] Re: new dal

2010-12-06 Thread Vasile Ermicioi
I propose to include a copy in site-packages and distribute it with web2py,
so no installation will be required, it is quite small  < 100kb


Re: [web2py] Re: Interesting fights

2010-12-06 Thread Branko Vukelic
Oooh, someone's going legal:

"For example suing pyjamas." -- Massimo

But watch out, the opponent is rich (Internet application). ;)

On Tue, Dec 7, 2010 at 1:04 AM, Anthony  wrote:
> Awkward timing. Don't let Reddit[1] find out about these "fights". :)
>
> [1] 
> http://www.reddit.com/r/Python/comments/edvws/an_often_asked_question_to_which_i_still_dont/c17mxpx
>
>
>
> On Dec 6, 11:57 am, Branko Vukelic  wrote:
>> http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...http://www.googlefight.com/index.php?lang=en_GB&word1=web2py+web+fram...
>>
>> :)
>>
>> --
>> Branko Vukelić
>>
>> bg.bra...@gmail.com
>> stu...@brankovukelic.com
>>
>> Check out my blog:http://www.brankovukelic.com/
>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> Registered Linux user #438078 (http://counter.li.org/)
>> I hang out on identi.ca:http://identi.ca/foxbunny
>>
>> Gimp Brushmakers Guildhttp://bit.ly/gbg-group



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Interesting fights

2010-12-06 Thread mdipierro
oops. where is the typo?

On Dec 6, 6:51 pm, Branko Vukelic  wrote:
> Oooh, someone's going legal:
>
> "For example suing pyjamas." -- Massimo
>
> But watch out, the opponent is rich (Internet application). ;)
>
>
>
> On Tue, Dec 7, 2010 at 1:04 AM, Anthony  wrote:
> > Awkward timing. Don't let Reddit[1] find out about these "fights". :)
>
> > [1]http://www.reddit.com/r/Python/comments/edvws/an_often_asked_question...
>
> > On Dec 6, 11:57 am, Branko Vukelic  wrote:
> >>http://www.googlefight.com/index.php?lang=en_GB&word1=python+programm..
>
> >> :)
>
> >> --
> >> Branko Vukelić
>
> >> bg.bra...@gmail.com
> >> stu...@brankovukelic.com
>
> >> Check out my blog:http://www.brankovukelic.com/
> >> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> >> Registered Linux user #438078 (http://counter.li.org/)
> >> I hang out on identi.ca:http://identi.ca/foxbunny
>
> >> Gimp Brushmakers Guildhttp://bit.ly/gbg-group
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


[web2py] Re: Interesting fights

2010-12-06 Thread Anthony
On Dec 6, 7:51 pm, Branko Vukelic  wrote:
> Oooh, someone's going legal:
>
> "For example suing pyjamas." -- Massimo

For the record, Redditors, just a typo ("suing" --> "using") -- no one
is suing pyjamas. ;)


[web2py] Re: Interesting fights

2010-12-06 Thread Anthony
On Dec 6, 8:01 pm, mdipierro  wrote:
> oops. where is the typo?

Point #4 in your original comment:
http://www.reddit.com/r/Python/comments/edvws/an_often_asked_question_to_which_i_still_dont/c17dny3


Re: [web2py] Re: Interesting fights

2010-12-06 Thread Branko Vukelic
On Tue, Dec 7, 2010 at 2:06 AM, Anthony  wrote:
> On Dec 6, 7:51 pm, Branko Vukelic  wrote:
>> Oooh, someone's going legal:
>>
>> "For example suing pyjamas." -- Massimo
>
> For the record, Redditors, just a typo ("suing" --> "using") -- no one
> is suing pyjamas. ;)

Really? :D

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: new dal

2010-12-06 Thread mdipierro
I like that it is pure python. It would go in contrib not in site-
packages.

Anybody opposes?

Can you help us keep it in sync with the official repo?



On Dec 6, 6:45 pm, Vasile Ermicioi  wrote:
> I propose to include a copy in site-packages and distribute it with web2py,
> so no installation will be required, it is quite small  < 100kb


[web2py] Re: Interesting fights

2010-12-06 Thread Anthony
> > On Dec 6, 7:51 pm, Branko Vukelic  wrote:
> >> Oooh, someone's going legal:
>
> >> "For example suing pyjamas." -- Massimo
>
> > For the record, Redditors, just a typo ("suing" --> "using") -- no one
> > is suing pyjamas. ;)
>
> Really? :D

Well, I did wink. Actually, there are a few questionable characters on
reddit who actively disparage/downvote web2py and Massimo and will
happily take things like this out of context.


[web2py] Re: new dal

2010-12-06 Thread ron_m
Another patch

Hit login form getting a ticket.

sqlhtml.py

line 62 and line 216

field._tablename should be field.tablename

Ron


Re: [web2py] Re: Interesting fights

2010-12-06 Thread Branko Vukelic
On Tue, Dec 7, 2010 at 2:27 AM, Anthony  wrote:
>> > On Dec 6, 7:51 pm, Branko Vukelic  wrote:
>> >> Oooh, someone's going legal:
>>
>> >> "For example suing pyjamas." -- Massimo
>>
>> > For the record, Redditors, just a typo ("suing" --> "using") -- no one
>> > is suing pyjamas. ;)
>>
>> Really? :D
>
> Well, I did wink. Actually, there are a few questionable characters on
> reddit who actively disparage/downvote web2py and Massimo and will
> happily take things like this out of context.

No wonder they attack Massimo. He wanted to sue Pyjamas! (j/k of
course, in case someone's sense of humor took a day off)

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread tomt
Thanks for the example and the reference.   - Tom

On Dec 6, 5:58 pm, villas  wrote:
> Hi tomt
>
> I believe it takes the fields from the specified source table and
> lines them up with a target table.  Any fields which don't match and
> the id are discarded.
>
> What Denes means is that it wouldn't work when for example you use
> form.vars from multiple tables which have some identical field names.
> In that case, when it filters through the form.vars it doesn't know
> which field comes from which table.
>
> Hope that's right :)
>
> -D
>
> On Dec 5, 10:07 pm, tomt  wrote:
>
> > Hi,
>
> > I'm unfamiliar with _filter_fields. I couldn't find it in the manual
> > but eventually found it in the source in gluon/tools.py.
> > Am I correct in assuming it is intended to return everything but the
> > id field from a record? (I've just started to learn python)
>
> > Is there some documentation available for this? I've tried some of the
> > urls in the help and resources post:
> >  http://web2py.com/examples/default/dal
> >  http://web2py.com/examples/default/api
> >  http://web2py.com/examples/default/tools
>
> > But I just get "invalid function"
>
> > Thanks in advance,
> >   - Tom
>
> > On Dec 5, 7:00 am, villas  wrote:
>
> > > Hi Nathan
>
> > > Just a small point, I tried your code example and it seems you have to
> > > set id==None otherwise it tries to add a duplicate row with the same
> > > id.
>
> > > Anyway, I thought you also might like this alternative using
> > > _filter_fields, just because it's shorter. Maybe it's got other
> > > issues,  but it seems to work!
>
> > > def things():
> > >     form = SQLFORM(db.things)
> > >     if form.accepts(request.vars,session):
> > >         response.flash = 'Added a thing'
> > >     if request.vars.dupe:
>
> > > db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
> > >     things = db(db.things.id>0).select()
> > >     return dict(form=form,things=things)
>
> > > Best regards,
> > > -D
>
> > > On Dec 4, 3:30 am, "mr.freeze"  wrote:
>
> > > > Here is an example:
>
> > > > Model
> > > > -
> > > > db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
> > > >                 Field('age','integer'),Field('weight','double'))
> > > > db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
> > > >                                      _onclick='return confirm("Copy
> > > > %s?")' % v)
>
> > > > Controller
> > > > --
> > > > def index():
> > > >     form = SQLFORM(db.things)
> > > >     if form.accepts(request.vars,session):
> > > >         response.flash = 'Added a thing'
> > > >     if request.vars.dupe:
> > > >         record = db.things(request.vars.dupe)
> > > >         vals = {}
> > > >         for k,v in record.items():
> > > >             if k in db.things.fields:
> > > >                 vals[k] = v
> > > >         db.things.insert(**vals)
> > > >     things = db(db.things.id>0).select()
> > > >     return dict(form=form,things=things)
>
> > > > On Dec 3, 6:12 pm, tomt  wrote:
>
> > > > > Hi,
>
> > > > > I've started to write a simple application to learn web2py. I am using
> > > > > SQLFORM to insert, modify and delete records. So far everything is
> > > > > working as planned.
>
> > > > > I would like to give the user the ability add a new record as a copy
> > > > > of an existing one.  The idea is that the user would view an existing
> > > > > record, modify a couple fields, and select 'copy' which result in
> > > > > adding a new record.
>
> > > > > I assume that this requires additional code, and I was hoping that
> > > > > someone would suggest an example, or let me know if SQLFORM can do
> > > > > this automatically.
>
> > > > > Thanks in advance,
>
> > > > > - Tom
>
>


Re: [web2py] Re: How to pass table labels to SQLTABLE headers param?

2010-12-06 Thread Bruno Rocha
a minor fix:

 if headers=='labels':
headers = {}
for c in columns:
tablename = ' '.join([w for w in
c.split('.')[0].split('_')])
fieldname = ''.join([w for w in c.split('.')[-1]])
headers[c] = sqlrows.db[tablename][fieldname].label

I will make a patch as soon as I can.

2010/12/6 mdipierro 

> send me a patch.
>
> On Dec 6, 6:29 pm, Bruno Rocha  wrote:
> > One more time:
> >
> > in sqlhtml.py we have:
> >
> > if headers=='fieldname:capitalize':headers = {}
> > for c in columns:headers[c] = ' '.join([w.capitalize()
> > for w in c.split('.')[-1].split('_')])
> >
> > so what about including the peace of code I mentioned?
> >
> > if headers=='labels':
> > headers = {}
> > for c in columns:
> > tablename = ' '.join([w for w in
> c.split('.')[0].split('_')])
> > fieldname = ' '.join([w for w in
> c.split('.')[-1].split('_')])
> > headers[c] = sqlrows.db[tablename][fieldname].label
> >
> > 2010/12/6 Bruno Rocha 
> >
> >
> >
> > > I do not want a form, a need to use the plugin_datatable.
> >
> > > Finally what I did:
> >
> > > # In models
> > > def get_header_labels(table=None):
> > > headers = {}
> > > for field in db[table].fields:
> > > headers[table+'.'+field] = db[table][field].label
> > > return headers
> >
> > > # in My view/controller
> >
> > > list = SQLTABLE(db(db.category.id>0). select(db.category.id,
> > > db.category.name),
> > > headers = get_header_labels('category'))
> >
> > > 2010/12/6 mdipierro 
> >
> > > if you make a form there is a dict in form.custom.label[fielname] or
> > >> form.custom.label.fielname
> >
> > >> On Dec 6, 5:19 pm, Bruno Rocha  wrote:
> > >> > OK, I found that labels are in db.fieldname.label, now I just have
> to
> > >> create
> > >> > a dict.
> >
> > >> > 2010/12/6 Bruno Rocha 
> >
> > >> > > HI,
> >
> > >> > > I have a 'category' table:
> >
> > >> > > db.define_table('category',
> > >> > > Field('name',label=T('Name')),
> > >> > > signature,
> > >> > > format='%(name)s'
> > >> > > )
> >
> > >> > > which I defined a label for the field 'name'
> >
> > >> > > I need to create something like:
> >
> > >> > > list = plugin_datatable(db(db.category.id>0).select(
> db.category.id,
> > >> > > db.category.name),
> > >> > > _class='datatable',
> > >> > > headers = {'category.name
> ':T('Name')},
> > >> > > )
> >
> > >> > > Is there a way to pass my previously defined labels to the
> SQLTABLE?
> >
> > >> > > where the 'labels' are stored? I tried db.category.labels,
> > >> > > db.category['labels'] ?
> >
> > >> > > Thanks
> >
> > >> > > --
> >
> > >> > > Bruno Rocha
> > >> > >http://about.me/rochacbruno/bio
> >
> > >> > --
> >
> > >> > Bruno Rochahttp://about.me/rochacbruno/bio
> >
> > > --
> >
> > > Bruno Rocha
> > >http://about.me/rochacbruno/bio
> >
> > --
> >
> > Bruno Rochahttp://about.me/rochacbruno/bio
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: new dal

2010-12-06 Thread mdipierro
fixed in trunk. Thanks.

On Dec 6, 7:31 pm, ron_m  wrote:
> Another patch
>
> Hit login form getting a ticket.
>
> sqlhtml.py
>
> line 62 and line 216
>
> field._tablename should be field.tablename
>
> Ron


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Phyo Arkar
Thanks man!

i am now going to build a mockup of my app using it!

On Mon, Dec 6, 2010 at 11:31 PM, Branko Vukelic  wrote:

> Sry, the API docs link was from my home server. :P Here's the correct url:
>
> http://demo.qooxdoo.org/1.2.x/apiviewer/#qx.ui.embed.Html
>
> On Mon, Dec 6, 2010 at 5:59 PM, Branko Vukelic 
> wrote:
> > On Mon, Dec 6, 2010 at 6:24 AM, Phyo Arkar 
> wrote:
> >> I use features as needed in each pages. If i can figure out  a way to
> >> put jqgrid to work hell , i will use full qxd !
> >
> > http://qx/api/#qx.ui.embed.Html
> >
> > This allows you to create an HTML element you need in order to attach
> jqgrid.
> >
> > --
> > Branko Vukelić
> >
> > bg.bra...@gmail.com
> > stu...@brankovukelic.com
> >
> > Check out my blog: http://www.brankovukelic.com/
> > Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> > Registered Linux user #438078 (http://counter.li.org/)
> > I hang out on identi.ca: http://identi.ca/foxbunny
> >
> > Gimp Brushmakers Guild
> > http://bit.ly/gbg-group
> >
>
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>


Re: [web2py] Re: when to use ajax

2010-12-06 Thread Branko Vukelic
On Tue, Dec 7, 2010 at 3:26 AM, Phyo Arkar  wrote:
> Thanks man!
>
> i am now going to build a mockup of my app using it!

No problem. Good luck!

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: new dal

2010-12-06 Thread ron_m
That above patch prevents the old sql.py DAL from working with
sqlhtml.py  because old dal does have a field attribute
field._tablename which sqlhtml.py was looking for before the patch.

I get the login form posted, fill it in but submit on the form to
complete the login gets a ticket. I tried to follow it but got lost, I
need a multi-threaded debugger such as winpdb. The one on Komodo IDE
6.0 doesn't seem to follow spawned threads OR I don't know how to use
it properly yet, Here is the traceback after the login form submit
(PostgreSQL database). It is inserting into the auth_event table the
fact that I logged in when it fails.

I went back to 1.89.5 and the application runs fine so the database
isn't damaged.

Traceback (most recent call last):
  File "/home/camcentral/Dev/web2py_hg/gluon/restricted.py", line 188,
in restricted
exec ccode in environment
  File "/home/camcentral/Dev/web2py_hg/applications/ccims/controllers/
default.py", line 70, in 
  File "/home/camcentral/Dev/web2py_hg/gluon/globals.py", line 95, in

self._caller = lambda f: f()
  File "/home/camcentral/Dev/web2py_hg/applications/ccims/controllers/
default.py", line 44, in user
return dict(form=auth())
  File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1025, in
__call__
return self.login()
  File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1516, in
login
self.log_event(log % self.user)
  File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1268, in
log_event
origin=origin, user_id=user_id)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 3540, in
insert
return self._db._adapter.insert(self, fields)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 673, in
insert
id = self.lastrowid(table)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1500, in
lastrowid
self.execute("select currval('%s')" % table._sequence_name)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1017, in
execute
return self.log_execute(*a, **b)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1014, in
log_execute
return self.cursor.execute(*a,**b)
ProgrammingError: relation "none" does not exist
LINE 1: select currval('None')


On Dec 6, 6:04 pm, mdipierro  wrote:
> fixed in trunk. Thanks.
>
> On Dec 6, 7:31 pm, ron_m  wrote:
>
> > Another patch
>
> > Hit login form getting a ticket.
>
> > sqlhtml.py
>
> > line 62 and line 216
>
> > field._tablename should be field.tablename
>
> > Ron
>
>


[web2py] Re: new dal

2010-12-06 Thread ron_m
I pulled in the latest trunk version of sqlhtml.py and there was an
additional change at line 973 over and above the 2 lines I mentioned
before at 62 and 216

self.table._tablename became self.table.tablename which now causes a
new ticket rendering the login form.

I guess that line needs to be put back to use table._tablename unless
you are planning something else. :-)


On Dec 6, 6:04 pm, mdipierro  wrote:
> fixed in trunk. Thanks.
>
> On Dec 6, 7:31 pm, ron_m  wrote:
>
> > Another patch
>
> > Hit login form getting a ticket.
>
> > sqlhtml.py
>
> > line 62 and line 216
>
> > field._tablename should be field.tablename
>
> > Ron
>
>


[web2py] Re: new dal

2010-12-06 Thread mdipierro
I think I fixed the problem with sequence name. Please check.


On Dec 6, 8:45 pm, ron_m  wrote:
> That above patch prevents the old sql.py DAL from working with
> sqlhtml.py  because old dal does have a field attribute
> field._tablename which sqlhtml.py was looking for before the patch.
>
> I get the login form posted, fill it in but submit on the form to
> complete the login gets a ticket. I tried to follow it but got lost, I
> need a multi-threaded debugger such as winpdb. The one on Komodo IDE
> 6.0 doesn't seem to follow spawned threads OR I don't know how to use
> it properly yet, Here is the traceback after the login form submit
> (PostgreSQL database). It is inserting into the auth_event table the
> fact that I logged in when it fails.
>
> I went back to 1.89.5 and the application runs fine so the database
> isn't damaged.
>
> Traceback (most recent call last):
>   File "/home/camcentral/Dev/web2py_hg/gluon/restricted.py", line 188,
> in restricted
>     exec ccode in environment
>   File "/home/camcentral/Dev/web2py_hg/applications/ccims/controllers/
> default.py", line 70, in 
>   File "/home/camcentral/Dev/web2py_hg/gluon/globals.py", line 95, in
> 
>     self._caller = lambda f: f()
>   File "/home/camcentral/Dev/web2py_hg/applications/ccims/controllers/
> default.py", line 44, in user
>     return dict(form=auth())
>   File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1025, in
> __call__
>     return self.login()
>   File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1516, in
> login
>     self.log_event(log % self.user)
>   File "/home/camcentral/Dev/web2py_hg/gluon/tools.py", line 1268, in
> log_event
>     origin=origin, user_id=user_id)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 3540, in
> insert
>     return self._db._adapter.insert(self, fields)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 673, in
> insert
>     id = self.lastrowid(table)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1500, in
> lastrowid
>     self.execute("select currval('%s')" % table._sequence_name)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1017, in
> execute
>     return self.log_execute(*a, **b)
>   File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 1014, in
> log_execute
>     return self.cursor.execute(*a,**b)
> ProgrammingError: relation "none" does not exist
> LINE 1: select currval('None')
>
> On Dec 6, 6:04 pm, mdipierro  wrote:
>
> > fixed in trunk. Thanks.
>
> > On Dec 6, 7:31 pm, ron_m  wrote:
>
> > > Another patch
>
> > > Hit login form getting a ticket.
>
> > > sqlhtml.py
>
> > > line 62 and line 216
>
> > > field._tablename should be field.tablename
>
> > > Ron
>
>


[web2py] Re: new dal

2010-12-06 Thread ron_m
Massimo, you nailed it for the sequence name problems. I tested almost
all of my app and got one more ticket.

Traceback (most recent call last):
  File "/home/camcentral/Dev/web2py_hg/gluon/restricted.py", line 188,
in restricted
exec ccode in environment
  File "/home/camcentral/Dev/web2py_hg/applications/ccims/views/live/
menu.html", line 118, in 
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 4171, in
select
return self.db._adapter.select(self.query,fields,attributes)
  File "/home/camcentral/Dev/web2py_hg/gluon/sql.py", line 951, in
select
key = self._uri + '/' + query
AttributeError: 'PostgreSQLAdapter' object has no attribute '_uri'

Changed line 951 self._uri to self.uri and I can't make the
application break any more so far. I believe it was my one cached item
in the application.

Ron

On Dec 6, 7:08 pm, mdipierro  wrote:
> I think I fixed the problem with sequence name. Please check.
>
> On Dec 6, 8:45 pm, ron_m  wrote:
>


[web2py] Re: new dal

2010-12-06 Thread VP


On Dec 6, 6:35 pm, mdipierro  wrote:
> Here is some more info about the new DAL
> http://web2py.com/examples/static/new_dal_help.pdf
>
Should class Query have been called class Filter?
just curious.


[web2py] ajax return nothing

2010-12-06 Thread weheh
Is it possible to write a web2py ajax call where the server returns
nothing? If so, how to do it? So far, I figure I *must* return at
least a jQuery command targeted at a dummy id. But I would very much
prefer to return nothing at all for simplicity sake, since I don't
want to update the browser window in any way.


[web2py] Re: new dal

2010-12-06 Thread ron_m

I still have MySQL installed so copied the app, changed database URL,
deleted all files under the applications databases directory, created
empty db, let app create empty tables by running it once to login
screen. I then did the all data from tables at once export from
PostgreSQL (db.export_to_csv_file()) and imported the data to MySQL
using db.import_from_csv_file().

Happy to say it all just worked.

Ron




[web2py] couchdb anybody?

2010-12-06 Thread mdipierro
I just added a partial and experiment support for couch in the new
DAL.

I have a problem and perhaps some of you may help me.

1) am running couchdbx on mac (download and click, starts couchdb, no
questions asked)

2) I am running the following python script

from sql import DAL, Field
db=DAL('couchdb://127.0.0.1:5984')
db.define_table('person',Field('name'))
id=db.person.insert(name='Jim')
print id
row=db.person(id)
print row #0
print db(db.person.id==id).update(name="john") #1
print db.person(id) #2
print row
del db.person[id]
print db.person(id)

It works, except that #1 returns 1 (update done) but #2 returns Jim,
not John.
What am I doing wrong?

You can only for one record by id.
Once this works fine, extending to more complex queries should be
easy.

I have not tried it with web2py sqlforms but it should work fine.

Notice the code of the adapter (ChouchDBAdapter) is very small. It can
be easily be extended to other NoSQL.


[web2py] Re: ajax return nothing

2010-12-06 Thread mdipierro
return ''

On Dec 6, 10:01 pm, weheh  wrote:
> Is it possible to write a web2py ajax call where the server returns
> nothing? If so, how to do it? So far, I figure I *must* return at
> least a jQuery command targeted at a dummy id. But I would very much
> prefer to return nothing at all for simplicity sake, since I don't
> want to update the browser window in any way.


[web2py] Re: couchdb anybody?

2010-12-06 Thread mdipierro
forget it. it works. The mistake is in what I am printing. This now
runs fine!

from sql import DAL, Field
db=DAL('couchdb://127.0.0.1:5984')
db.define_table('person',Field('name'))
id=db.person.insert(name='Jim')
print id
row=db.person(id)
print row
print db(db.person.id==id).update(name="john")
print db.person(id)
del db.person[id]

On Dec 6, 11:19 pm, mdipierro  wrote:
> I just added a partial and experiment support for couch in the new
> DAL.
>
> I have a problem and perhaps some of you may help me.
>
> 1) am running couchdbx on mac (download and click, starts couchdb, no
> questions asked)
>
> 2) I am running the following python script
>
> from sql import DAL, Field
> db=DAL('couchdb://127.0.0.1:5984')
> db.define_table('person',Field('name'))
> id=db.person.insert(name='Jim')
> print id
> row=db.person(id)
> print row #0
> print db(db.person.id==id).update(name="john") #1
> print db.person(id) #2
> print row
> del db.person[id]
> print db.person(id)
>
> It works, except that #1 returns 1 (update done) but #2 returns Jim,
> not John.
> What am I doing wrong?
>
> You can only for one record by id.
> Once this works fine, extending to more complex queries should be
> easy.
>
> I have not tried it with web2py sqlforms but it should work fine.
>
> Notice the code of the adapter (ChouchDBAdapter) is very small. It can
> be easily be extended to other NoSQL.


  1   2   >