[web2py] Re: Agree on some terms before registration

2012-03-30 Thread Hassan Alnatour
it works but its not showing any text next to the check box  , how can i 
show some text next to the check box ?

Re: [web2py] SQLFORM.grid not doing what I want :)

2012-03-30 Thread Mike Veltman

I guessed it was something like that :-)

Thanks Massimo I am going to test it.


On 03/30/2012 10:51 AM, Massimo Di Pierro wrote:

You have to pass it

SQLFORM.grid(...,field_id=db.lvdisksetup.id,)

else it does not know what table to use.

On Thursday, 29 March 2012 19:58:52 UTC-5, Gwayne aka Mike Veltman wrote:

On 03/30/2012 12:01 AM, Massimo Di Pierro wrote:

When you say "I want to manipulate db.lvdisksetup but in stead it
manipulates db.lvdisk" what do you mean by "manipulates"?



That when I delete a record or do add a record it gives me the
db.lvdisk table and not the db.lvdisksetup table.

So I delete or add a record that is supposed to be a reverence.




On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike
Veltman wrote:

Gentle people,

I have the following grid:

query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup)
& (db.lvgroupname.id  ==
usedlvdisksetup) & (db.lvdisksetup.lvdisk_id == db.lvdisk.id
) )
fields = [db.lvdisksetup.id ,
db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc,
db.lvdisksetup.lunid]

form = SQLFORM.grid(query,
fields=fields,
orderby=['lvdisksetup.lunid'],
csv=False,
create = False,
maxtextlength=45
)

I want to manipulate db.lvdisksetup but in stead it
manipulates db.lvdisk :-)

What causes havoc by deleting essential table data :)

Part of the db models :)

# All the LV sizes will be collected in here in bytes, like
30GB, 10GB, 2GB etc
db.define_table('lvsize',

Field('sizename', type='string',
  unique=True,
  label=T('Lun Size')),
Field('size', type='string',
  label=T('LV Size in bytes')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# The LV Disk groups
db.define_table('lvgroupname',

Field('lvgroupnamedesc', type='string',
   unique=True,
  label=T('LV Disk Groupname ')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY()

# Logical volume on storage
db.define_table('lvdisk',

Field('lvdiskdesc', type='string',
   unique=True,
  label=T('LV Disk description ')),
Field('lvsize_id', db.lvsize,
  default=2,
  label=T('Size ID')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id
', 'lvsize.sizename')
db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY()


# lvdisksetup
db.define_table('lvdisksetup',

Field('lvdisk_id', db.lvdisk,
  default=1,
  label=T('Logical volume to be added')),
Field('lvgroupname_id', db.lvgroupname,
  default=1,
  label=T('Member of Logical volume group name')),
Field('lunid', type='integer',
  default=2,
  label=T('Lun ID')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvdisksetup.lvdisk_id.requires = IS_IN_DB(db, 'lvdisk.id
', 'lvdisk.lvdiskdesc')
db.lvdisksetup.lvgroupname_id.requires = IS_IN_DB(db,
'lvgroupname.id ',
'lvgroupname.lvgroupnamedesc')


# hbahostgroupsetup (to add the right disks to a hba or a
 

Re: [web2py] SQLFORM.grid not doing what I want :)

2012-03-30 Thread Mike Veltman

After testing

  form = SQLFORM.grid(query,
fields=fields,
field_id=db.lvdisksetup.id, 
<---

orderby=['lvdisksetup.lunid'],
csv=False,
create = True,
maxtextlength=45
)

It worked like a charm, its really great Massimo. Thanks


On 03/30/2012 03:55 PM, Mike Veltman wrote:

I guessed it was something like that :-)

Thanks Massimo I am going to test it.


On 03/30/2012 10:51 AM, Massimo Di Pierro wrote:

You have to pass it

SQLFORM.grid(...,field_id=db.lvdisksetup.id,)

else it does not know what table to use.

On Thursday, 29 March 2012 19:58:52 UTC-5, Gwayne aka Mike Veltman 
wrote:


On 03/30/2012 12:01 AM, Massimo Di Pierro wrote:

When you say "I want to manipulate db.lvdisksetup but in stead
it manipulates db.lvdisk" what do you mean by "manipulates"?



That when I delete a record or do add a record it gives me the
db.lvdisk table and not the db.lvdisksetup table.

So I delete or add a record that is supposed to be a reverence.




On Wednesday, 28 March 2012 22:58:31 UTC-5, Gwayne aka Mike
Veltman wrote:

Gentle people,

I have the following grid:

query = ( (db.lvdisksetup.lvgroupname_id == usedlvdisksetup)
& (db.lvgroupname.id  ==
usedlvdisksetup) & (db.lvdisksetup.lvdisk_id == db.lvdisk.id
) )
fields = [db.lvdisksetup.id ,
db.lvgroupname.lvgroupnamedesc , db.lvdisk.lvdiskdesc,
db.lvdisksetup.lunid]

form = SQLFORM.grid(query,
fields=fields,
orderby=['lvdisksetup.lunid'],
csv=False,
create = False,
maxtextlength=45
)

I want to manipulate db.lvdisksetup but in stead it
manipulates db.lvdisk :-)

What causes havoc by deleting essential table data :)

Part of the db models :)

# All the LV sizes will be collected in here in bytes, like
30GB, 10GB, 2GB etc
db.define_table('lvsize',

Field('sizename', type='string',
  unique=True,
  label=T('Lun Size')),
Field('size', type='string',
  label=T('LV Size in bytes')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# The LV Disk groups
db.define_table('lvgroupname',

Field('lvgroupnamedesc', type='string',
   unique=True,
  label=T('LV Disk Groupname ')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvgroupname.lvgroupnamedesc.requires = IS_NOT_EMPTY()

# Logical volume on storage
db.define_table('lvdisk',

Field('lvdiskdesc', type='string',
   unique=True,
  label=T('LV Disk description ')),
Field('lvsize_id', db.lvsize,
  default=2,
  label=T('Size ID')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvdisk.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id
', 'lvsize.sizename')
db.lvdisk.lvdiskdesc.requires = IS_NOT_EMPTY()


# lvdisksetup
db.define_table('lvdisksetup',

Field('lvdisk_id', db.lvdisk,
  default=1,
  label=T('Logical volume to be added')),
Field('lvgroupname_id', db.lvgroupname,
  default=1,
  label=T('Member of Logical volume group name')),
Field('lunid', type='integer',
  default=2,
  label=T('Lun ID')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
mi

Re: [web2py] wb2py with existing database

2012-03-30 Thread Manuele Pesenti

Il 29/03/2012 19:14, rdodev ha scritto:

All,

Is it possible to have the DAL create/discover models from an existing 
DB (without providing the schema)? If so, how would I go about making 
sure the models are created?  Thanks in advance.

Hi,

I'm involved in the same problem and I'm developing a plugin for this 
porpose. I'm bound to share a first release.


Manuele


Re: [web2py] Re: Using routes.py as a dispatcher for URL shortener app

2012-03-30 Thread Simon Bushell
Many thanks Jonathan. That did the trick. 

Thank you  to everyone who helped out

S



On Friday, March 30, 2012 3:01:58 AM UTC+1, Anthony wrote:
>
> Thanks for the correction. I guess my version allows you to eliminate the 
> app, controller, and function, but doesn't allow anything else in the url 
> in that case.
>
> Anthony
>
> On Thursday, March 29, 2012 8:34:19 PM UTC-4, Jonathan Lundell wrote:
>>
>> On Mar 29, 2012, at 11:33 AM, Simon Bushell wrote:
>> > This is a neat solution Anthony (actually, it was my original idea for 
>> solving this). however I seem to be getting the same error: invalid 
>> function (default/tcgata). 
>> > 
>> > Forgive me, is this code in the root-level routes.py? or a routes.py in 
>> applications/shortener? 
>> > 
>> > Should anything else be in routes.py? 
>>
>> If I'm remembering this correctly, you want something like this (root 
>> level is fine):
>>
>> routers = dict(
>> BASE = dict(
>> default_application = 'shortener',
>> ),
>> shortener = dict(
>> default_controller = 'default',
>> default_function = 'index',
>> functions = ['index', 'user', 'download', 'call'],
>> ),
>> )
>>
>> ...where the functions list is a complete list of the visible functions 
>> in the default controller (that is, any function that can appear in a URL).
>>
>> The router needs that list so it can distinguish function names from 
>> args, and can then omit 'index'. Since in your example tcgata is not in the 
>> functions list, it can be safely treated as args[0].
>>
>>
>> > 
>> > S
>> > 
>> > 
>> > 
>> > On Thursday, March 29, 2012 6:40:09 PM UTC+1, Anthony wrote:
>> > routes_in = (
>> >  (r'^/?$', r'/app_name/default/index'),
>> >  (r'^/(?P[^/]*)/?$', 
>> r'/app_name/default/index/\g'),   
>> >  )
>> > 
>> > 
>> > in your root-level routes.py The drawback is that you will lose access 
>> to all other apps (including admin) but that can be a good thing for public 
>> deployments.
>> > 
>> > You can catch the other apps by adding route patterns that match them 
>> before your catch-all pattern (the patterns are processed in order, and the 
>> first match is used). Anyway, using the parametric router and specifying 
>> the url-shortening app as the default app might be simpler:
>> > 
>> > routers = dict(
>> > BASE = dict(
>> > default_application = 'shortener',
>> > default_controller = 'default',
>> > default_function = 'index',
>> > ),
>> > )
>> > 
>> > Then http://myapp.com/tcgata will get routed to 
>> http://myapp.com/shortener/default/index/tcgata, and "tcgata" will be 
>> available to the index() function in request.args(0).
>> > 
>>
>>
>>

[web2py] Re: Agree on some terms before registration

2012-03-30 Thread Simon Bushell
How are you inserting the form into your view? If you're using SQLFORM you 
can supply labels to your fields (in your case the 'agree' field) using 
something like:

form = SQLFORM(db.auth_user, fields = ['agree'], labels = {'agree':'Do you 
agree to the Terms and Conditions?'})

Obviously you will need to add all the fields to the fields list you want 
to include in the form. 

S


On Friday, March 30, 2012 8:19:14 AM UTC+1, Hassan Alnatour wrote:
>
> it works but its not showing any text next to the check box  , how can i 
> show some text next to the check box ?



[web2py] Sharing application across development machines - what files to synchronize from databases directory

2012-03-30 Thread Omri Har-Shemesh
Hey List,

I am developing a database application with web2py as the server back-end, 
and a client application in qooxdoo, which interacts with the server 
through JSON-RPC.
I use Mercurial as my VCS and synchronize the code from qooxdoo, the code 
from the controller and the code of the model (I do not use any views since 
it is handled by qooxdoo) using Mercurial to Bitbucket.
I also added the database (SQLite) file to the repository so that I can 
develop on more than one machine.
I do not synchronize the web2py code and the qooxdoo framework code because 
it will make the repository bloated and I don't really need to do that.
My question is the following - which files should I synchronize in order to 
use the database in more than one computer? Tables are being continuously 
added and changed.
I tried synchronizing only the database file, but then the application 
complained about the structure of the tables in the database. To solve it, 
I deleted everything from the "databases" directory, let web2py rebuild the 
files and then
replaced the "storage.sqlite" file with the one from the repository. 

Is there a better way to do that? Should I add to the repository all the 
files from the "databases" directory?

And a different question which occurred to me - is there a way to tell 
web2py to clear the database before deployment, or should I simply delete 
everything from the 'databases' directory and let it rebuild the tables?

Thanks,
Omri



[web2py] Re: web2py icon/logo?

2012-03-30 Thread selecta
thanks, this is better, even though the quality of the rectangular logo is 
still a bit crappy, a svg version would be much better (for all the logos)

On Thursday, March 29, 2012 5:51:44 PM UTC+2, Anthony wrote:
>
> On Thursday, March 29, 2012 10:56:47 AM UTC-4, selecta wrote:
>>
>> thanks i thought so, I like the fav icon because of its compact format, 
>> unfortunately my poster will be in A0 so it will probably not be my choice, 
>> it would be nice if there would be a SVG version of the fac icon for these 
>> kind of purposes. I could do it, all I would need to know for that is the 
>> font that was used :D
>>
>
> The original PNG is in here: 
> http://www.web2py.com/examples/static/artwork.tar.gz 
>


[web2py] issue with multi-select widget

2012-03-30 Thread weheh
I have a grouping function based on what items are selected in a 
multi-select widget. When the user presses a button, an ajax call is made 
to a callback that evaluates the items that have been selected. The 
evaluated item "list" is stored in request.vars.mylist.

Here's the problem. The "list" of values stored in request.vars.mylist may 
or may not be a list. So when I go to evaluate the selected items, I would 
normally do something like this:

for item in request.vars.mylist:
do_something(int(item))

The problem is this. If only one item is selected, a list is not returned. 
A string is returned instead. So if the request.vars.mylist is a single 
item, '123', then item will be set as if request.vars.mylist were 
['1','2','3'].

Now I know I can easily compensate for that (I'm curious to hear what 
people would suggest as the most efficient method). But why wouldn't that 
be considered an inconsistency that needed fixing?


[web2py] Re: Agree on some terms before registration

2012-03-30 Thread weheh
Just add a label argument to Massimo's answer:

auth.settings.custom_fields['auth_user'].append(Field('agree','boolean',label='Abandon
 
hope all ye who enter',requires=IS_NOT_EMPTY(error_message='you must agree 
this'))) 

On Friday, March 30, 2012 3:19:14 PM UTC+8, Hassan Alnatour wrote:
>
> it works but its not showing any text next to the check box  , how can i 
> show some text next to the check box ?



Re: [web2py] Re: Agree on some terms before registration

2012-03-30 Thread Bruno Rocha
custom_fields or extra_fields???

http://zerp.ly/rochacbruno
Em 30/03/2012 07:52, "weheh"  escreveu:

> Just add a label argument to Massimo's answer:
>
> auth.settings.custom_fields['**auth_user'].append(Field('**agree','boolean',label='Abandon
> hope all ye who enter',requires=IS_**NOT_EMPTY(error_message='you must
> agree this')))
>
> On Friday, March 30, 2012 3:19:14 PM UTC+8, Hassan Alnatour wrote:
>>
>> it works but its not showing any text next to the check box  , how can i
>> show some text next to the check box ?
>
>


[web2py] Need reviewers for web2py application development cookbook

2012-03-30 Thread Jitesh Gawali (jite...@packtpub.com)
We released a new book this month which you maybe aware of: *Web2py 
Application Development Cookbook*. The authors for this book are core 
developers of Web2py. We are offering free copies/e-copies of the book to 
people (esp. bloggers) interested in writing a review/feedback for the book 
on their blog and/or Amazon. 

Everything about the book is on this publisher book-page, please take a 
look: http://link.packtpub.com/di3Bc5

If you are a blogger, and are interested in this reviewing opportunity, 
then I'd be glad to send you a copy/e-copy.

The purpose of such a review request is to bring in visibility for the 
book, and get across your opinion about the book to your readers. If 
interested, please reply to this post with your expected time-frame for 
completing the review, and your blog address. I will make sure to get back 
to you as quickly as I can.

Cheers!


[web2py] Will a corrected version of the 4th edition pdf be available ?

2012-03-30 Thread Nomad
Marco et all,

I've been monitoring the google group a bit bit now and it appears that 
several people have found bugs in the example code in the pdf that was 
recently released.
For those of us who bought the release of the 4th edition pdf, will there 
be a cumulative corrected version available ?

Thanks in Advance 


[web2py] Re: [OT] Re: Spatial / GIS support in DAL

2012-03-30 Thread Fran
On Monday, 26 March 2012 22:05:14 UTC+1, Timmie wrote:
>
> Am 20.03.2012 01:24, schrieb DenesL:
> > Spatial / GIS support (in latest trunk)
> > =
> > Sponsored by AidIQ for use by Sahana Eden
> Very cool. Great news.
>
> Has the Sahana Eden team also implemented a solution to the proxy issue 
> with the JS mapping frameworks such as openlayers?
>
> beginnings of a proxy for web2py. See 
> http://trac.sahanapy.org/wiki/BluePrintGISProxy for more
>

Wow, old URL!

Yes, we have a proxy:
https://github.com/flavour/eden/blob/master/controllers/gis.py#L2897

F


Re: [web2py] Re: Facing Trouble in Cascading drop-down with ajax

2012-03-30 Thread Alan Etkin
There may be javascript issues:

> onchange="ajax('admin_assign',['org_name'],'shadow_clone');"

Wouldn't the 'shadow_clone' be specified as '#shadow_clone'? (as it is an 
element selected by id)

> onchange="jQuery(maker_name).remove(); ...

Does the maker_name js variable exist? if maker_name is an element's name 
I'd use this instead:

jQuery('[name=maker_name]').remove();

On Friday, March 30, 2012 1:54:48 AM UTC-3, Sanjeet Kumar wrote:
>
> Yes my code is from web2py slices 
>
> I have the following view :-
>
> {{left_sidebar_enabled,right_sidebar_enabled=True,False}}
> {{extend 'adminlayout.html'}}
> 
> Themis Project Console
> 
> 
>
>  action="{{=URL('default','admin_submit_assign_project')}}" method="post" 
> onsubmit="return showcnf()" >
>
>   Select Organization :  onchange="ajax('admin_assign',['org_name'],'shadow_clone');">
> {{for org in organization:}}
> 
> {{=org.organization}}
> 
> {{pass}}
> 
>
> 
>
> Select Department :  onchange="jQuery(maker_name).remove();
> ajax('admin_assign_pro', ['category_name'], 'shadow_clone');">
> {{for category in categories:}}
>  {{=" selected='selected'" if 
> str(category.category)==request.vars.category_name else ""}}>
> {{=category.category}}
> 
> {{pass}}
> 
>
> 
> 
> 
>  
>Select Employee Email : 
> {{for maker in makers:}}
>  {{=XML(" selected='selected'") if 
> str(maker.email)==request.vars.maker_name else ""}}>
> {{=maker.email}}
> 
> {{pass}}
> 
> 
>
> 
>
> 
>
> 
>
> 
> {{=form}}
> 
>
> and the following Controller :-
>
>
> def admin_assign_project():
> for row2 in db(db.image.email == auth.user.email).select():
>  images=row2.image
> db.assign_project.id.readable=False
> form=SQLFORM.grid(db.assign_project)
>  projects=db().select(db.admin_add_project.ALL)
> organization=db().select(db.auth_user.ALL)
>  categories = db().select(db.category.ALL)
> if request.vars.org_name:
> makers = 
> db(db.auth_user.organization==request.vars.org_name).select(db.auth_user.ALL)
>  else:
> makers = db(db.auth_user.organization=='').select(db.auth_user.ALL)
>  return dict(organization=organization,categories=categories, 
> makers=makers, images=images, form=form)
>  
> def admin_assign():
> makers = 
> db((db.auth_user.organization==request.vars.org_name)).select(db.auth_user.ALL)
> result = ""
> for maker in makers:
> result += "" + 
> str(maker.category) + ""  
> result += ""
> return XML(result)
>
>
> def admin_assign_pro():
> makers = 
> db((db.auth_user.department==request.vars.category_name)).select(db.auth_user.ALL)
> result = ""
> for maker in makers:
> result += "" + 
> str(maker.email+'\t'+'('+maker.first_name+'\t'+maker.last_name+')') + 
> ""  
> result += ""
> return XML(result)
>
>
> Here I want to value in second drop-down category_name filtered on the 
> first drop-down org_name which are selected and the value in the third 
> drop-down maker_name filtered on the second drop-down which will be 
> selected via ajax. 
>
> I am getting the value only in the second drop-down but i am not be able 
> to get the value in the third drop-down filtered on the second . Thanks in 
> advance .
>


Re: [web2py] Re: Facing Trouble in Cascading drop-down with ajax

2012-03-30 Thread Sanjeet Kumar
Thanks Alan

On Fri, Mar 30, 2012 at 6:11 PM, Alan Etkin  wrote:

> There may be javascript issues:
>
>
> > onchange="ajax('admin_assign',['org_name'],'shadow_clone');"
>
> Wouldn't the 'shadow_clone' be specified as '#shadow_clone'? (as it is an
> element selected by id)
>
> > onchange="jQuery(maker_name).remove(); ...
>
> Does the maker_name js variable exist? if maker_name is an element's name
> I'd use this instead:
>
> jQuery('[name=maker_name]').remove();
>
>
> On Friday, March 30, 2012 1:54:48 AM UTC-3, Sanjeet Kumar wrote:
>>
>> Yes my code is from web2py slices
>>
>> I have the following view :-
>>
>> {{left_sidebar_enabled,right_**sidebar_enabled=True,False}}
>> {{extend 'adminlayout.html'}}
>> 
>> Themis Project Console
>> 
>> 
>>
>> 
>>
>>   Select Organization : > onchange="ajax('admin_assign',**['org_name'],'shadow_clone');"**>
>> {{for org in organization:}}
>> 
>> {{=org.organization}}
>> 
>> {{pass}}
>> 
>>
>> 
>>
>> Select Department : > onchange="jQuery(maker_name).**remove();
>> ajax('admin_assign_pro', ['category_name'], 'shadow_clone');">
>> {{for category in categories:}}
>> > {{=" selected='selected'" if 
>> str(category.category)==**request.vars.category_name
>> else ""}}>
>> {{=category.category}}
>> 
>> {{pass}}
>> 
>>
>> 
>>
>> 
>>
>>Select Employee Email : 
>> {{for maker in makers:}}
>> > {{=XML(" selected='selected'") if
>> str(maker.email)==request.**vars.maker_name else ""}}>
>> {{=maker.email}}
>> 
>> {{pass}}
>> 
>> 
>>  
>> 
>>
>> 
>>
>> 
>>
>> 
>> {{=form}}
>> 
>>
>> and the following Controller :-
>>
>>
>> def admin_assign_project():
>> for row2 in db(db.image.email == auth.user.email).select():
>>  images=row2.image
>> db.assign_project.id.readable=**False
>> form=SQLFORM.grid(db.assign_**project)
>>  projects=db().select(db.admin_**add_project.ALL)
>> organization=db().select(db.**auth_user.ALL)
>>  categories = db().select(db.category.ALL)
>> if request.vars.org_name:
>> makers = db(db.auth_user.organization==**request.vars.org_name).select(**
>> db.auth_user.ALL)
>>  else:
>> makers = db(db.auth_user.organization==**'').select(db.auth_user.ALL)
>>  return dict(organization=**organization,categories=**categories,
>> makers=makers, images=images, form=form)
>>
>> def admin_assign():
>> makers = db((db.auth_user.organization=**=request.vars.org_name)).**
>> select(db.auth_user.ALL)
>> result = ""
>> for maker in makers:
>> result += "" +
>> str(maker.category) + ""
>> result += ""
>> return XML(result)
>>
>>
>> def admin_assign_pro():
>> makers = db((db.auth_user.department==**request.vars.category_name)).
>> **select(db.auth_user.ALL)
>> result = ""
>> for maker in makers:
>> result += "" +
>> str(maker.email+'\t'+'('+**maker.first_name+'\t'+maker.**last_name+')')
>> + ""
>> result += ""
>> return XML(result)
>>
>>
>> Here I want to value in second drop-down category_name filtered on the
>> first drop-down org_name which are selected and the value in the third
>> drop-down maker_name filtered on the second drop-down which will be
>> selected via ajax.
>>
>> I am getting the value only in the second drop-down but i am not be able
>> to get the value in the third drop-down filtered on the second . Thanks in
>> advance .
>>
>


[web2py] Re: Storing class instances in sessions... or somewhere

2012-03-30 Thread Massimo Di Pierro
Can I see the object that you are storing in session?

On Friday, 30 March 2012 01:09:09 UTC-5, Web2py Newbie wrote:
>
> session doesn't seem to have a "force an update to me" method, so I am 
> just incrementing a counter. 
>


Re: [web2py] Re: Agree on some terms before registration

2012-03-30 Thread Massimo Di Pierro
sorry extra_fields.

On Friday, 30 March 2012 06:45:18 UTC-5, rochacbruno wrote:
>
> custom_fields or extra_fields???
>
> http://zerp.ly/rochacbruno
> Em 30/03/2012 07:52, "weheh"  escreveu:
>
>> Just add a label argument to Massimo's answer:
>>
>> auth.settings.custom_fields['**auth_user'].append(Field('**agree','boolean',label='Abandon
>>  
>> hope all ye who enter',requires=IS_**NOT_EMPTY(error_message='you must 
>> agree this'))) 
>>
>> On Friday, March 30, 2012 3:19:14 PM UTC+8, Hassan Alnatour wrote:
>>>
>>> it works but its not showing any text next to the check box  , how can i 
>>> show some text next to the check box ?
>>
>>  

Re: [web2py] Re: Facing Trouble in Cascading drop-down with ajax

2012-03-30 Thread Anthony

>
> > onchange="ajax('admin_assign',['org_name'],'shadow_clone');"
>
> Wouldn't the 'shadow_clone' be specified as '#shadow_clone'? (as it is an 
> element selected by id)
>

No, the third argument of ajax() is just the id of the target element -- 
the ajax() function itself prepends the "#" to select the specific element. 
So you cannot just specify any jQuery selector there -- it has to be an 
element id.

Anthony


Re: [web2py] Re: Using routes.py as a dispatcher for URL shortener app

2012-03-30 Thread Jonathan Lundell
On Mar 30, 2012, at 1:58 AM, Simon Bushell wrote:
> Many thanks Jonathan. That did the trick. 

Glad to hear it. Now that you've tested it, some color commentary for router 
users.

> routers = dict(
> BASE = dict(
> default_application = 'shortener',
> ),

BASE might better be named GLOBAL. It takes the default routing dict (see 
router.example.py) and modifies them as specified. In this case, we want to 
specify the default application, which needs to be done globally, at the base 
level.

> shortener = dict(

Following BASE, we specify routing parameters for specific apps. The effective 
router for any give app is the default router dictionary, updated by the BASE 
dictionary, updated by the app's dictionary (if any).

> default_controller = 'default',
> default_function = 'index',

These are actually the default values; they're only here for documentation, and 
aren't strictly necessary.

> functions = ['index', 'user', 'download', 'call'],

By default, the router scans the app's controllers directory to get the 
controller names, but it relies on the router dict for the function names. It 
wants them because it wants to map:

http://domain.com/foobar -> /shortener/default/index/foobar
http://domain.com/user -> /shortener/default/user

It does that by looking at the function candidates (foobar and user, above) and 
seeing whether they're in the functions list.

In outgoing URL() mapping, it uses the list to safely omit elements. So if 
args[0] is 'foobar', it can omit a/c/f safely. But suppose the function is 
'index', but args[0] is 'user', which collides with a known function name. Now 
it knows that it can't safely omit the function name, and the outgoing URL 
becomes '/index/user'.

If you *don't* specify the functions list, then the outgoing URL drops the 
default function name (here 'index') only if args is empty.

> ),
> )




> 
> Thank you  to everyone who helped out
> 
> S
> 
> 
> 
> On Friday, March 30, 2012 3:01:58 AM UTC+1, Anthony wrote:
> Thanks for the correction. I guess my version allows you to eliminate the 
> app, controller, and function, but doesn't allow anything else in the url in 
> that case.
> 
> Anthony
> 
> On Thursday, March 29, 2012 8:34:19 PM UTC-4, Jonathan Lundell wrote:
> On Mar 29, 2012, at 11:33 AM, Simon Bushell wrote:
> > This is a neat solution Anthony (actually, it was my original idea for 
> > solving this). however I seem to be getting the same error: invalid 
> > function (default/tcgata). 
> > 
> > Forgive me, is this code in the root-level routes.py? or a routes.py in 
> > applications/shortener? 
> > 
> > Should anything else be in routes.py?
> If I'm remembering this correctly, you want something like this (root level 
> is fine):
> 
> routers = dict(
> BASE = dict(
> default_application = 'shortener',
> ),
> shortener = dict(
> default_controller = 'default',
> default_function = 'index',
> functions = ['index', 'user', 'download', 'call'],
> ),
> )
> 
> ...where the functions list is a complete list of the visible functions in 
> the default controller (that is, any function that can appear in a URL).
> 
> The router needs that list so it can distinguish function names from args, 
> and can then omit 'index'. Since in your example tcgata is not in the 
> functions list, it can be safely treated as args[0].
> 
> 
> > 
> > S
> > 
> > 
> > 
> > On Thursday, March 29, 2012 6:40:09 PM UTC+1, Anthony wrote:
> > routes_in = (
> >  (r'^/?$', r'/app_name/default/index'),
> >  (r'^/(?P[^/]*)/?$', r'/app_name/default/index/\g'),  
> >  
> >  )
> > 
> > 
> > in your root-level routes.py The drawback is that you will lose access to 
> > all other apps (including admin) but that can be a good thing for public 
> > deployments.
> > 
> > You can catch the other apps by adding route patterns that match them 
> > before your catch-all pattern (the patterns are processed in order, and the 
> > first match is used). Anyway, using the parametric router and specifying 
> > the url-shortening app as the default app might be simpler:
> > 
> > routers = dict(
> > BASE = dict(
> > default_application = 'shortener',
> > default_controller = 'default',
> > default_function = 'index',
> > ),
> > )
> > 
> > Then http://myapp.com/tcgata will get routed to 
> > http://myapp.com/shortener/default/index/tcgata, and "tcgata" will be 
> > available to the index() function in request.args(0).
> >
> 
> 
> 
> 
> 
> 
> 
> 




[web2py] ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
I am trying to make use of the cool 'new' (to me) grow_input which is the 
default widget for a list:integer

I want to validate against an IS_IN_SET(), so looking at the code, I see 
that this requires using IS_LIST_OF() (other validators get ignored)

I see this as the suggested way to use it:
https://groups.google.com/forum/?fromgroups#!newtopic/web2py/web2py/6-7TSMqUgBU

However this doesn't work - with the multiple=True in there I get:

File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
obj = [int(item) for item in obj]
TypeError: int() argument must be a string or a number, not 'list'


If I remove the multiple=True, then it works, however there remain 2 problems:


I cannot find a way to get an IS_NULL_OR() - I can't do it around the 
IS_LIST_OF as the requires is stripped then.

If I put it inside the IS_LIST_OF() & put in a null value I get:

  File "C:\Bin\web2py\gluon\html.py", line 2004, in process
self.validate(**kwargs)
  File "C:\Bin\web2py\gluon\html.py", line 1951, in validate
if self.accepts(**kwargs):
  File "C:\Bin\web2py\gluon\sqlhtml.py", line 1290, in accepts
self.vars.id = self.table.insert(**fields)
  File "C:\Bin\web2py\gluon\dal.py", line 7030, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "C:\Bin\web2py\gluon\dal.py", line 968, in insert
query = self._insert(table,fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in _insert
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in 
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 1100, in expand
return str(self.represent(expression,field_type))
  File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
obj = [int(item) for item in obj]
TypeError: int() argument must be a string or a number, not 'NoneType'


The other issue I have is that form.errors isn't working properly.
I get no error inline with the field when there are errors.
I can see that the widget has hideerror=True, so this appears to be 
deliberate:
https://github.com/mdipierro/web2py/blob/master/gluon/sqlhtml.py#L223 

I tried changing that, but no joy...tracing through I see that the 
self.errors only appear for the other fields (text/submit) & then is 
rejected because the name doesn't match...
https://github.com/mdipierro/web2py/blob/master/gluon/html.py#L1655 
self.errors = Storage: 

Simple test case I used to debug the problem in isolation:
Model:
db.define_table("test",
Field("text", requires=IS_NOT_EMPTY()),
Field("membership_paid", "list:integer",
  label = T("Membership Paid"),
  requires = IS_LIST_OF(IS_IN_SET([2010,2012])),
  ))

Controller:
def index():
form = SQLFORM(db.test)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)

Any help welcome on resolving these 2 issues :)

Many thanks,
Fran.


[web2py] Re: Python Negative Popularity

2012-03-30 Thread Wikus van de Merwe
I don't agree that multiprocessing is difficult in Python. Threading is 
difficult, multiprocessing is easy. Together with asynchronous I/O this 
brings the scalability. You think node.js is multithreading? No, it's 
single thread with event loop and non-blocking callbacks based I/O. And so 
is Twisted or Eventlet and they perform equally well. If you need to scale 
you add another instance of the event loop running on a separate core and 
route your traffic through a load balancer.

I also disagree that python 3.x is a problem. It is a better language than 
2.x. It's a shame that the transition of many projects is happening so 
slow. If the life of 2.x is extended it will only cause further delays in 
transition to 3.x.

Also, in all this discussion on how tragic it is that Python has been 
surpassed by the Javascript, we need to remember that TIOBE index is 
calculated by counting hits on the top 9 search engines using a query of 
" programming". And as Derek has already spotted the query for 
Javascript has been extended and includes "JS programming" too [1]. I think 
it is much more reasonable to count the number of commits in a given 
programming language like ohloh is doing [2]. Then Python is not so much 
behind Java/C/C++ and is recovering from a drop in activity in 2011.

[1] 
http://www.tiobe.com/index.php/content/paperinfo/tpci/tpci_definition.htm
[2] http://goo.gl/suOH6


[web2py] Re: How to use web2py auth using JavaScript+ajax?

2012-03-30 Thread Anthony
On Friday, March 30, 2012 2:22:42 AM UTC-4, thstart wrote:
>
> Thank you, could you please post an example?
>

Perhaps someone else has a full working example. You just need a form on 
the page that gets posted via Ajax (see 
http://web2py.com/books/default/chapter/29/11#The-ajax-function), and then 
check the submitted credentials with auth.login_bare (see 
http://web2py.com/books/default/chapter/29/9#Manual-Authentication).

Anthony 


Re: [web2py] How do we check the number of users in the new google groups?

2012-03-30 Thread Anthony

>
> How do we check the number of users in the new google groups?
> Everything is so complicated compared to the old google groups. :-(
>
>
> Showing 50 of 3709 members
>
> https://groups.google.com/forum/?fromgroups#!members/web2py
>

Via the "Members" button in the upper right, which is only visible from the 
topics list view (not when viewing individual topics). I'm not sure there 
is any longer a way to see the number of posts per month as in the old 
version.

Anthony



Re: [web2py] How do we check the number of users in the new google groups?

2012-03-30 Thread Massimo Di Pierro
Thanks Anthony and Jonathan.

On Friday, 30 March 2012 09:17:39 UTC-5, Anthony wrote:
>
> How do we check the number of users in the new google groups?
>> Everything is so complicated compared to the old google groups. :-(
>>
>>
>> Showing 50 of 3709 members
>>
>> https://groups.google.com/forum/?fromgroups#!members/web2py
>>
>
> Via the "Members" button in the upper right, which is only visible from 
> the topics list view (not when viewing individual topics). I'm not sure 
> there is any longer a way to see the number of posts per month as in the 
> old version.
>
> Anthony
>
>

[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Anthony
IS_LIST_OF takes a "minimum" argument, which defaults to 0, so it should 
still validate if no items are submitted (it also takes a "maximum" 
argument). If that's what you're looking for, you shouldn't need 
IS_EMPTY_OR at all (note, IS_NULL_OR has been deprecated).

As for errors, when a validation error occurs with IS_LIST_OF and the list 
widget, the errors will be in form.errors, but they will not be displayed 
on the form by default (it's complicated, and when we added support for the 
IS_LIST_OF validator, we didn't work that out). So, you're responsible for 
checking form.errors and deciding how you want to communicate the error in 
the UI.

Anthony

On Friday, March 30, 2012 9:54:41 AM UTC-4, Fran wrote:
>
> I am trying to make use of the cool 'new' (to me) grow_input which is the 
> default widget for a list:integer
>
> I want to validate against an IS_IN_SET(), so looking at the code, I see 
> that this requires using IS_LIST_OF() (other validators get ignored)
>
> I see this as the suggested way to use it:
>
> https://groups.google.com/forum/?fromgroups#!newtopic/web2py/web2py/6-7TSMqUgBU
>
> However this doesn't work - with the multiple=True in there I get:
>
> File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
> obj = [int(item) for item in obj]
> TypeError: int() argument must be a string or a number, not 'list'
>
>
> If I remove the multiple=True, then it works, however there remain 2 problems:
>
>
> I cannot find a way to get an IS_NULL_OR() - I can't do it around the 
> IS_LIST_OF as the requires is stripped then.
>
> If I put it inside the IS_LIST_OF() & put in a null value I get:
>
>   File "C:\Bin\web2py\gluon\html.py", line 2004, in process
> self.validate(**kwargs)
>   File "C:\Bin\web2py\gluon\html.py", line 1951, in validate
> if self.accepts(**kwargs):
>   File "C:\Bin\web2py\gluon\sqlhtml.py", line 1290, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "C:\Bin\web2py\gluon\dal.py", line 7030, in insert
> ret =  self._db._adapter.insert(self,self._listify(fields))
>   File "C:\Bin\web2py\gluon\dal.py", line 968, in insert
> query = self._insert(table,fields)
>   File "C:\Bin\web2py\gluon\dal.py", line 964, in _insert
> values = ','.join(self.expand(v,f.type) for f,v in fields)
>   File "C:\Bin\web2py\gluon\dal.py", line 964, in 
> values = ','.join(self.expand(v,f.type) for f,v in fields)
>   File "C:\Bin\web2py\gluon\dal.py", line 1100, in expand
> return str(self.represent(expression,field_type))
>   File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
> obj = [int(item) for item in obj]
> TypeError: int() argument must be a string or a number, not 'NoneType'
>
>
> The other issue I have is that form.errors isn't working properly.
> I get no error inline with the field when there are errors.
> I can see that the widget has hideerror=True, so this appears to be 
> deliberate:
> https://github.com/mdipierro/web2py/blob/master/gluon/sqlhtml.py#L223 
>
> I tried changing that, but no joy...tracing through I see that the 
> self.errors only appear for the other fields (text/submit) & then is 
> rejected because the name doesn't match...
> https://github.com/mdipierro/web2py/blob/master/gluon/html.py#L1655 
> self.errors = Storage: 
>
> Simple test case I used to debug the problem in isolation:
> Model:
> db.define_table("test",
> Field("text", requires=IS_NOT_EMPTY()),
> Field("membership_paid", "list:integer",
>   label = T("Membership Paid"),
>   requires = IS_LIST_OF(IS_IN_SET([2010,2012])),
>   ))
>
> Controller:
> def index():
> form = SQLFORM(db.test)
> if form.process().accepted:
> response.flash = 'form accepted'
> elif form.errors:
> response.flash = 'form has errors'
> else:
> response.flash = 'please fill out the form'
> return dict(form=form)
>
> Any help welcome on resolving these 2 issues :)
>
> Many thanks,
> Fran.
>


[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
On Friday, 30 March 2012 15:43:15 UTC+1, Anthony wrote:
>
> IS_LIST_OF takes a "minimum" argument, which defaults to 0, so it should 
> still validate if no items are submitted (it also takes a "maximum" 
> argument). If that's what you're looking for, you shouldn't need 
> IS_EMPTY_OR at all


Great, that fixes that half perfectly :) 
 

> As for errors, when a validation error occurs with IS_LIST_OF and the list 
> widget, the errors will be in form.errors, but they will not be displayed 
> on the form by default (it's complicated, and when we added support for the 
> IS_LIST_OF validator, we didn't work that out). So, you're responsible for 
> checking form.errors and deciding how you want to communicate the error in 
> the UI.
>

ok, thanks for the answer - I'll see what we can do :)

F


[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
On Friday, 30 March 2012 16:31:42 UTC+1, Fran wrote:
>
> On Friday, 30 March 2012 15:43:15 UTC+1, Anthony wrote:
>>
>> IS_LIST_OF takes a "minimum" argument, which defaults to 0, so it should 
>> still validate if no items are submitted (it also takes a "maximum" 
>> argument). If that's what you're looking for, you shouldn't need 
>> IS_EMPTY_OR at all
>
>
> Great, that fixes that half perfectly :) 
>

Spoke to soon...no it doesn't take (I got confused by the form.errors not 
showing up!)
I see it did default to 0, but the form doesn't get saved...just as I 
originally said...

F


[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
On Friday, 30 March 2012 16:34:43 UTC+1, Fran wrote:
>
> I see it did default to 0, but the form doesn't get saved...just as I 
> originally said...
>

The error comes from the e in (v, e) = self.other(item)
i.e. "value not allowed" from the IS_IN_SET()

I tried adding "" to the set, but obviously that's not an integer so it 
gets rejected...

F


[web2py] More Twitter fun...

2012-03-30 Thread Anthony
Maybe we should take this down: http://www.web2py.com/php. The Python 
"cognoscenti" are having a hissy fit about it on Twitter:

https://twitter.com/#!/mitsuhiko/status/185448802524729344
https://twitter.com/#!/AaronVanderlip/statuses/185453068572299264
https://twitter.com/#!/crgwbr/statuses/185449279496785920

Anthony


[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Anthony
On Friday, March 30, 2012 11:39:01 AM UTC-4, Fran wrote:
>
> On Friday, 30 March 2012 16:34:43 UTC+1, Fran wrote:
>>
>> I see it did default to 0, but the form doesn't get saved...just as I 
>> originally said...
>>
>
> The error comes from the e in (v, e) = self.other(item)
> i.e. "value not allowed" from the IS_IN_SET()
>
> I tried adding "" to the set, but obviously that's not an integer so it 
> gets rejected...
>

Is the problem that one or more of the input fields generated by the widget 
is being submitted with no value, and therefore the IS_IN_SET validator is 
returning an error? Do you not want an error in that case? If not, setting 
IS_IN_SET(..., multiple=True) doesn't work?

Anthony


[web2py] Re: Smarttable & SQLFORM.grid

2012-03-30 Thread greenpoise
Yours is more elaborate!  I am doing a hybrid on the smarttable one 
(www.datatables.net). Nothing fancy, just adding an additional button for 
the actions rather than links. This way I get the live-search plus the add 
button I want.


Thanks



d



On Thursday, 29 March 2012 15:18:07 UTC-7, Derek wrote:
>
> I get what you are saying. I wrote a function (not on web2py, but it's 
> javascript...) 
>
>
> // this will capture the 'enter' key when pressed inside the text box, so 
> searching works better.
> function IEKeyCap(e)
> {
>
> if (e.keyCode == 13) {dsCustomers.filter(myFilterFunc)};
>
> }
>
> function FilterData()
> {
> dsCustomers.filter(myFilterFunc);
> }
>
> function StartFilterTimer()
> {
> if (StartFilterTimer.timerID)
> clearTimeout(StartFilterTimer.timerID);
> StartFilterTimer.timerID = setTimeout(function() { 
> StartFilterTimer.timerID = null; FilterData(); }, 100);
> }
>
> and here was my html that fired it...
>  name="srch" id="srch">
>
> This was using the Adobe Spry framework, but it's essentially the same.
> When you press a key, it starts the timer (for 100ms). If the timer was 
> already going and you press another key, it restarts the timer.
> After 100ms, it then calls the filter function. If they press enter 
> (keycode 13) it will also call the filter function.
>
> I think the problem here is that the SQLFORM.smartgrid isn't AJAX, in that 
> when you click 'search' instead of just reloading the grid with the 
> filtered data, it just redirects you (to the exact same page you're on) and 
> shows you the filtered data. 
>
> The only way I know to do it with AJAX is to write my own smartgrid, or 
> use Adobe Spry Framework because it's awesome - and you can just tell 
> web2py that you want that dict as a json.
>
> On Monday, March 26, 2012 1:24:42 PM UTC-7, greenpoise wrote:
>>
>> What I was looking for was a type-ahead function using SQLFORM.smartgrid 
>> instead of typing a word and pressing search.
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, 22 March 2012 16:15:23 UTC-7, Alan Etkin wrote:
>>>
>>> I think you mean SQLFORM.smartgrid. 
>>>
>>> Book's 7.8 section (the features are explained there): 
>>>
>>> "... 
>>> A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a 
>>> grid but it is 
>>> designed to take as input not a query but only one table and to browse 
>>> said 
>>> table and selected referencing tables. 
>>> ..." 
>>>
>>> On Mar 22, 7:16 pm, greenpoise  wrote: 
>>> > Are these two equivalents?? I remember using smartables at some point. 
>>> What 
>>> > I liked about it was the search feature without having to press any 
>>> button 
>>> > to search for my text within a table. Does SQLFORM.grid provides 
>>> something 
>>> > similar?? 
>>> > 
>>> > Thanks 
>>> > 
>>> > d
>>
>>

[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
On Friday, 30 March 2012 17:01:43 UTC+1, Anthony wrote:
>
> I see it did default to 0, but the form doesn't get saved...just as I 
>>> originally said...
>>>
>> The error comes from the e in (v, e) = self.other(item)
>> i.e. "value not allowed" from the IS_IN_SET()
>> I tried adding "" to the set, but obviously that's not an integer so it 
>> gets rejected...
>>
> Is the problem that one or more of the input fields generated by the 
> widget is being submitted with no value, and therefore the IS_IN_SET 
> validator is returning an error?
>

Exactly
 

> Do you not want an error in that case?
>

Right
 

> If not, setting IS_IN_SET(..., multiple=True) doesn't work?
>

Nope, as per original post, this gives:

File "C:\Bin\web2py\gluon\sqlhtml.py", line 1290, in accepts
self.vars.id = self.table.insert(**fields)
  File "C:\Bin\web2py\gluon\dal.py", line 7030, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "C:\Bin\web2py\gluon\dal.py", line 968, in insert
query = self._insert(table,fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in _insert
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in 
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 1100, in expand
return str(self.represent(expression,field_type))
  File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
obj = [int(item) for item in obj]
TypeError: int() argument must be a string or a number, not 'list'

F



[web2py] Re: ListWidget: IS_NULL_OR & form.errors

2012-03-30 Thread Fran
On Friday, 30 March 2012 17:42:45 UTC+1, Fran wrote:
>
> On Friday, 30 March 2012 17:01:43 UTC+1, Anthony wrote:
>>
>> I see it did default to 0, but the form doesn't get saved...just as I 
 originally said...

>>> The error comes from the e in (v, e) = self.other(item)
>>> i.e. "value not allowed" from the IS_IN_SET()
>>> I tried adding "" to the set, but obviously that's not an integer so it 
>>> gets rejected...
>>>
>> Is the problem that one or more of the input fields generated by the 
>> widget is being submitted with no value, and therefore the IS_IN_SET 
>> validator is returning an error?
>>
> Exactly
>
Do you not want an error in that case?
>
Right
>

I thought that I might eb able to get away with just changing IS_LIST_OF to:
if self.minimum and self.other:
(i.e. don't bother checking the other if minimum=0 since this will be an 
IS_NULL_OR()

However this gives the same basic error:

File "C:\Bin\web2py\gluon\sqlhtml.py", line 1290, in accepts
self.vars.id = self.table.insert(**fields)
  File "C:\Bin\web2py\gluon\dal.py", line 7030, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "C:\Bin\web2py\gluon\dal.py", line 968, in insert
query = self._insert(table,fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in _insert
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 964, in 
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "C:\Bin\web2py\gluon\dal.py", line 1100, in expand
return str(self.represent(expression,field_type))
  File "C:\Bin\web2py\gluon\dal.py", line 1456, in represent
obj = [int(item) for item in obj]
ValueError: invalid literal for int() with base 10: ''


Can list:integer fields not be NULL?

F


Re: [web2py] Tracking/Tracing actions

2012-03-30 Thread Derek
No.

On Thursday, March 29, 2012 5:54:59 PM UTC-7, Francisco Gama wrote:
>
> Let me put it this way:
> Can I determine the hash of an uploaded file during the upload process 
> (when the form is submitted) and before it is actually stored on the 
> filesystem?
>
> I believe that all my questions collapse to that.
>
> Thank you.
>
> On Mar 30, 2012, at 1:43 AM, Derek wrote:
>
> From the documentation:  http://web2py.com/books/default/chapter/29/7
> A SQLFORM object also deals automatically with "upload" fields by saving 
> uploaded files in the "uploads" folder (after having them renamed safely to 
> avoid conflicts and prevent directory traversal attacks) and stores their 
> names (their new names) into the appropriate field in the database. After 
> the form has been processed, the new filename is available in 
> form.vars.fieldname (i.e., it replaces the cgi.FieldStorage object in
> request.vars.fieldname), so you can easily reference the new name right 
> after upload. 
>
> On Thursday, March 29, 2012 5:20:52 PM UTC-7, Francisco Gama wrote:
>>
>> I need to create a form that submits files and at the same time, stores 
>> the user who did it, the name of the file, its hash, the time. Other things 
>> like his IP address, his web client would be interesting as well.
>>
>> I see two ways:
>> 1) some sort of method tracing (a decorator maybe) that informs me what 
>> calls have been done to some controller
>> 2) include in the uploading form, insertions to the database that also 
>> keep track of what has been done (the solution I'm trying)
>>
>>
>> While I want to keep files metadata stored on the database, I want them 
>> to be stored on the file system. So how can I create a form that uploads 
>> the file and stores all this metadata on the database (including getting 
>> the filename, its hash,...)?
>>
>>
>>
>>
>> On Mar 30, 2012, at 12:11 AM, Derek wrote:
>>
>> Are you getting any error messages? What do you mean by "this is not yet 
>> working".
>>
>> On Thursday, March 29, 2012 8:10:38 AM UTC-7, blackthorne wrote:
>>>
>>> Hello,
>>>
>>> I am working on a "secure" documentation system that should support file 
>>> uploads but also to give the ability to trace user actions like 
>>> download/upload of files. This should be integrated in the portal itself so 
>>> that the administrator doesn't need to parse web log files and trace users 
>>> and IP's. Example:
>>>
>>> user Malkovich submitted a file: report.docx with hash: 102310239123123 
>>> at 2012.03.27 10:12:45 (GMT)
>>> user BigFatCat downloaded the file: report.docx (id: 1201010121) 
>>> at 2012.03.27 12:11:05 (GMT)
>>> ...
>>>
>>> So, I just said what I have and I want, so now let me tell have I done 
>>> about this:
>>>
>>> in the model:
>>>
>>> ...
>>> db.define_table('attachment',
>>> Field('name', requires=IS_NOT_EMPTY()),
>>> Field('filename'),
>>> Field('description'),
>>> Field('doc_type', 
>>> requires=IS_IN_SET(['text','report','image','other']), default='other'),
>>> Field('hash', 'string'),
>>> Field('file','upload'),
>>> format='%(name)s')
>>>
>>> db.define_table('logs',
>>> Field('message','string', requires=IS_NOT_EMPTY()),
>>> Field('full_description','text'),
>>> Field('action', 'string', 
>>> requires=IS_IN_SET(['create','remove','download','upload', 
>>> 'edit','other']),default='download'),
>>> Field('attachments', 'list:reference attachment', notnull=False),
>>> Field('user', 'list:reference auth_user'),
>>> Field('happened_on','datetime', default=datetime.datetime.now()))
>>> ...
>>>
>>> in the controller:
>>>
>>> def hash(file):
>>> return hashlib.md5(open(file).read()).hexdigest()
>>>
>>> @auth.requires_login()
>>> def insert_file():
>>> form = SQLFORM(db.attachment, upload=URL('download'), 
>>> fields=['name', 'description', 'file'])
>>> if request.vars.file!=None:
>>> form.vars.filename = request.vars.file.filename # not sure about 
>>> this one...
>>> form.vars.hash = hash(file)
>>> if form.process().accepted:
>>> db.logs.insert(message='file submitted', 
>>> full_description=forn.vars.hash, action='upload', attachments='', user=
>>> auth.user.id, happened_on=request.now)
>>> response.flash = 'form accepted'
>>> elif form.errors:
>>> response.flash = 'something went wrong, try harder'
>>> record = db.attachment(request.args(0)) or redirect(URL('index'))
>>> return dict(form=form)
>>> ...
>>>
>>> This is not yet working but don't think I am on the right track? Tips?
>>>
>>> Thank you
>>>
>>
>>
>

Re: [web2py] Login username fake ending character

2012-03-30 Thread Bruce Wade
Your correct your solution Anthony works.

Massimo, I am not sure I understand what db.auth_user.username.
requires.insert(0, MyStrangeRequirement()) is doing?


On Thu, Mar 29, 2012 at 7:28 PM, Anthony  wrote:

> If i am correct this will not work because it should be:
>>
>> 1. check last character
>> 2. remove last character
>> 3. do db validation
>>
>> I think onvalidation does db validation and then 1&2.
>> Db validation will not pass because usernames are stored without last
>> character (as stated in first post).
>>
>
> The form validation just checks the username field validator, which is
> temporarily changed to IS_NOT_EMPTY, so it is only checking that a username
> was submitted. In any case, even the regular username field validator
> wouldn't check that the submitted value matches what's in the database. The
> check for matching the submitted username with an existing db username
> happens after the form processing, so using onvalidation should work.
>
> Anthony
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Tracking/Tracing actions

2012-03-30 Thread Anthony

>
> Let me put it this way:
> Can I determine the hash of an uploaded file during the upload process 
> (when the form is submitted) and before it is actually stored on the 
> filesystem?
>

I haven't been following this thread, but that sounds doable. When the file 
is uploaded, request.vars.file.file will hold the file object, and 
request.vars.file.filename will hold the original filename, so you could do 
something with those values before calling form.process(). You can also 
specify an onvalidation function via form.process(..., 
onvalidation=myvalidation), and I believe the function will be called 
before the file is stored.

Anthony 


Re: [web2py] Re: Agree on some terms before registration

2012-03-30 Thread Hassan Alnatour
auth.settings.extra_fields['auth_user']= [
  Field('Country',default="None"),
  Field('City',default="None"),
  Field('gender',requires=IS_IN_SET(genders,zero=None)),


# Trying to Show a massage new to the checkbox using this Field ..
  Field('agree','boolean',requires=IS_NOT_EMPTY(error_message='you must 
agree this'))
  ]

>  

Re: [web2py] Re: wb2py with existing database

2012-03-30 Thread Ruben Orduz
Anthony,

Where should I run this scrip from? Does it matter?


On Thu, Mar 29, 2012 at 1:18 PM, Anthony  wrote:
> Check out this
> script: http://code.google.com/p/web2py/source/browse/scripts/extract_pgsql_models.py.
> You may need to adapt it slightly for your particular database.
>
> Anthony
>
>
> On Thursday, March 29, 2012 1:14:56 PM UTC-4, rdodev wrote:
>>
>> All,
>>
>> Is it possible to have the DAL create/discover models from an existing DB
>> (without providing the schema)? If so, how would I go about making sure the
>> models are created?  Thanks in advance.


[web2py] How to Represent a Foreign Key Using Foreign Keys in Primary Table

2012-03-30 Thread pjryan126
I have the following two tables:

db.define_table('table_one',
Field('first', db.first, '%(name)s'),
Field('second', db.second, '%(name)s'),
Field('third', db.third, '%(name)s'),
format = '%(first)s - %(second)s Against %(third)s')

db.define_table('table_two',
Field('fourth', db.fourth),
Field('fifth', db.fifth), 
Field('table_ones', 'list:reference table_one'),
Field('sixth', list:string)

When I go to add a record to the db.form table in appadmin, the 
db.form.plan_classes drop-down box populates using the id's in the 
respective db.table_one fields (i.e., "1 - 1 Against 2", etc).

How would I get the items in the db.table_two.table_ones list to appear in 
a drop-down box using the field representations assigned in the 
db.table_one table definition? Any help on this would be greatly 
appreciated!


Re: [web2py] Login username fake ending character

2012-03-30 Thread Bruno Rocha
 db.auth_user.username.requires.insert(0, MyStrangeRequirement())

is the same of

 db.auth_user.username.requires = [MyStrangeRequirement(), IS_NOT_EMPTY(),
IS_NOT_IN_DB(..)]

MyStrangeRequirement() is your custom validator.

db.table.field.requires is a list of validators, so you can use "insert"
method of list.


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Login username fake ending character

2012-03-30 Thread Anthony

>
> Your correct your solution Anthony works.
>
> Massimo, I am not sure I understand what db.auth_user.username.
> requires.insert(0, MyStrangeRequirement()) is doing?
>

Massimo's solution does the same thing but by creating a custom validator 
and adding the validator to the "requires" attribute of the "username" 
field. See http://web2py.com/books/default/chapter/29/7#Custom-validators. 
A custom validator can be more convenient because once it is added to the 
field it will automatically be applied to any SQLFORM (you don't have to 
set an onvalidation function for every SQLFORM), and it will also be 
applied when records are inserted via the .validate_and_insert() method 
(onvalidation functions don't apply in that case, as it doesn't involve any 
form processing). In this case, though, we only want the validation to 
happen with login, not with other forms or inserts/updates that may include 
the username field, so a custom validator probably doesn't have any 
advantage over an onvalidation function in this case.

Anthony



Re: [web2py] Re: wb2py with existing database

2012-03-30 Thread Anthony

>
> Where should I run this scrip from? Does it matter?
>
Just from the command line. I don't think it requires web2py at all. It's 
just using the db driver to inspect the db and generate the appropriate 
web2py code.

Anthony 


Re: [web2py] Re: wb2py with existing database

2012-03-30 Thread Ruben Orduz
Cool. Thanks for the confirm. It's bombing for me right now, but it's
very likely due to the changes I made so that it would skip most types
since it's mongoDB.

On Fri, Mar 30, 2012 at 4:00 PM, Anthony  wrote:
>> Where should I run this scrip from? Does it matter?
>
> Just from the command line. I don't think it requires web2py at all. It's
> just using the db driver to inspect the db and generate the appropriate
> web2py code.
>
> Anthony


Re: [web2py] Login username fake ending character

2012-03-30 Thread Bruce Wade
Yes I agree with this situation it is only on the login. Every other part
of the site uses the real username. Thanks for the explanation of Massimo's
example Bruno and Anthony.

On Fri, Mar 30, 2012 at 12:56 PM, Anthony  wrote:

> Your correct your solution Anthony works.
>>
>> Massimo, I am not sure I understand what db.auth_user.username.req**
>> uires.insert(0, MyStrangeRequi**rement()) is doing?
>>
>
> Massimo's solution does the same thing but by creating a custom validator
> and adding the validator to the "requires" attribute of the "username"
> field. See http://web2py.com/books/default/chapter/29/7#Custom-validators.
> A custom validator can be more convenient because once it is added to the
> field it will automatically be applied to any SQLFORM (you don't have to
> set an onvalidation function for every SQLFORM), and it will also be
> applied when records are inserted via the .validate_and_insert() method
> (onvalidation functions don't apply in that case, as it doesn't involve any
> form processing). In this case, though, we only want the validation to
> happen with login, not with other forms or inserts/updates that may include
> the username field, so a custom validator probably doesn't have any
> advantage over an onvalidation function in this case.
>
> Anthony
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: How to Represent a Foreign Key Using Foreign Keys in Primary Table

2012-03-30 Thread Derek
Just curious as to why you chose list:reference.
I'd just do it like this:
Field('table_ones', db.table_one ), 

On Friday, March 30, 2012 12:38:23 PM UTC-7, pjryan126 wrote:
>
> I have the following two tables:
>
> db.define_table('table_one',
> Field('first', db.first, '%(name)s'),
> Field('second', db.second, '%(name)s'),
> Field('third', db.third, '%(name)s'),
> format = '%(first)s - %(second)s Against %(third)s')
>
> db.define_table('table_two',
> Field('fourth', db.fourth),
> Field('fifth', db.fifth), 
> Field('table_ones', 'list:reference table_one'),
> Field('sixth', list:string)
>
> When I go to add a record to the db.form table in appadmin, the 
> db.form.plan_classes drop-down box populates using the id's in the 
> respective db.table_one fields (i.e., "1 - 1 Against 2", etc).
>
> How would I get the items in the db.table_two.table_ones list to appear in 
> a drop-down box using the field representations assigned in the 
> db.table_one table definition? Any help on this would be greatly 
> appreciated!
>


[web2py] Re: How to Represent a Foreign Key Using Foreign Keys in Primary Table

2012-03-30 Thread pjryan126
Derek:

Thanks for your response. It's a many-to-many relationship between 
table_one and table_two. i was hoping to denormalize this relationship with 
list:reference, but maybe it's more trouble than it's worth in this case. 

On Friday, March 30, 2012 3:38:23 PM UTC-4, pjryan126 wrote:
>
> I have the following two tables:
>
> db.define_table('table_one',
> Field('first', db.first, '%(name)s'),
> Field('second', db.second, '%(name)s'),
> Field('third', db.third, '%(name)s'),
> format = '%(first)s - %(second)s Against %(third)s')
>
> db.define_table('table_two',
> Field('fourth', db.fourth),
> Field('fifth', db.fifth), 
> Field('table_ones', 'list:reference table_one'),
> Field('sixth', list:string)
>
> When I go to add a record to the db.form table in appadmin, the 
> db.form.plan_classes drop-down box populates using the id's in the 
> respective db.table_one fields (i.e., "1 - 1 Against 2", etc).
>
> How would I get the items in the db.table_two.table_ones list to appear in 
> a drop-down box using the field representations assigned in the 
> db.table_one table definition? Any help on this would be greatly 
> appreciated!
>


[web2py] data source configuration

2012-03-30 Thread Alex
Hello,

I need to configure my data source for different instances. Currently this 
is the last problem preventing me from going productive. I run my 
application for multiple customer instances and of course the database 
connection is different for each customer. This issue also occurs if you 
have a test and a productive environment. I think this is a fairly common 
use case and necessary for most real world applications, so I'm really 
surprised that I didn't see any solution for this in web2py (especially 
since web2py is so easy and powerful for everything else). Or did I just 
miss something?

Massimo, in case you read this, do you have an advice for me? is an 
environment configuration a feature that could be added in the future? I 
think that I read somewhere that web2py developers don't think this is 
necessary but I really don't understand why.

Is there a workaround for me? I have some ideas but nothing seems to be 
optimal. I'd prefer to avoid dirty hacks...

thanks,
Alex



[web2py] Re: Problem with GAE and Cloud SQL

2012-03-30 Thread Matt
Sure. Will Do.

Matt

On Wednesday, 28 March 2012 04:10:31 UTC+13, Anthony wrote:
>
> Can you submit an issue about this: 
> http://code.google.com/p/web2py/issues/list
>
> Anthony
>
> On Tuesday, March 27, 2012 5:41:55 AM UTC-4, Matt wrote:
>>
>> I've managed to figure out a solution. (Not sure if it's 100% correct 
>> though but it seems to work fine).
>>
>> The GoogleSqlAdapter needs the following change:
>>
>> class GoogleSQLAdapter(UseDatabaseStoredFile,MySQLAdapter):
>> uploads_in_blob = True
>>
>> Hope this helps somebody else.
>>
>> Matt
>>
>> On Tuesday, 27 March 2012 11:21:57 UTC+13, Matt wrote:
>>>
>>> Hi there,
>>>
>>> I'm trying to install a web2py application on GAE using Cloud SQL.
>>>
>>> When I try and submit a form that contains an upload field I get the 
>>> following exception:
>>>
>>> dal.py", line 6124, in store os.makedirs(path)
>>> AttributeError: 'module' object has no attribute 'makedirs'
>>>
>>> I'm currently running on web2py-1.99.7-stable.
>>>
>>> Any suggestions in fix this or is this a bug with the combination of GAE 
>>> and Cloud SQL?
>>>
>>> Thanks in advance,
>>> Matt
>>>
>>

Re: [web2py] Re: Python Negative Popularity

2012-03-30 Thread Michele Comitini
I agree: if you need to use multicores, multiprocessing is simpler,
faster and safer than threading.

NaCl is becoming more and more interesting.
https://developers.google.com/native-client/

It is going to LLVM so maybe in a not too far future web2py will enjoy
pushing some pypy generated vm on the client.

In the mean time if we want to stop having people go after javascript,
we need to extend web2py to the client.
A basic idea can be the defining a basic set of widgets and simple
wire protocol (ajax, json...) to push events to web2py.

So a button would be:

class BUTTONW(WIDGET):
.
.
.
  def onclick(self, target):
.
.  
.
 target.update()

Serialization of BUTTONW creates the needed javascript so one can simply write:

{{=BUTTON(id='id1', target='')}}

The target objects are objects whose state is know to web2py so that
they can be serialized back to the client on request (target.update())

If the widget tree becomes big, so to satisfy most usage patterns,
then  using web2py would help reducing the usage of javascript.
Of course there would still be javascript underlying, as there is
assembler as a result of a compilation, but how many care about
assembler today?

mic


Il 30 marzo 2012 16:01, Wikus van de Merwe
 ha scritto:
> I don't agree that multiprocessing is difficult in Python. Threading is
> difficult, multiprocessing is easy. Together with asynchronous I/O this
> brings the scalability. You think node.js is multithreading? No, it's single
> thread with event loop and non-blocking callbacks based I/O. And so is
> Twisted or Eventlet and they perform equally well. If you need to scale you
> add another instance of the event loop running on a separate core and route
> your traffic through a load balancer.
>
> I also disagree that python 3.x is a problem. It is a better language than
> 2.x. It's a shame that the transition of many projects is happening so slow.
> If the life of 2.x is extended it will only cause further delays in
> transition to 3.x.
>
> Also, in all this discussion on how tragic it is that Python has been
> surpassed by the Javascript, we need to remember that TIOBE index is
> calculated by counting hits on the top 9 search engines using a query of
> " programming". And as Derek has already spotted the query for
> Javascript has been extended and includes "JS programming" too [1]. I think
> it is much more reasonable to count the number of commits in a given
> programming language like ohloh is doing [2]. Then Python is not so much
> behind Java/C/C++ and is recovering from a drop in activity in 2011.
>
> [1]
> http://www.tiobe.com/index.php/content/paperinfo/tpci/tpci_definition.htm
> [2] http://goo.gl/suOH6


[web2py] make a registration and login form in another language

2012-03-30 Thread Hassan Alnatour
Dear ALL,

I have a website  it has two languages so i have a controller for 
every language , i want to change the labels for the fields in the login 
and registration form  , how can i do that ?
 


[web2py] Re: make a registration and login form in another language

2012-03-30 Thread Anthony
Why do you have a controller for every language? Have you looked into the 
web2py translation 
system: 
http://web2py.com/books/default/chapter/29/4#T-and-Internationalization? 
All fields can have a "label" attribute, which can be translated using the 
T() translator. Note, all the Auth field labels are set via the 
auth.messages object (e.g., auth.messages.label_first_name, etc.), and all 
the auth.messages are automatically translated by default. So, to change 
the labels on the login and registration forms (or any Auth forms), you 
just have to add the specific translations to the appropriate language file 
in the /languages folder. I believe many of the field names are already 
translated in the language files that come with the "welcome" app.

Anthony

On Friday, March 30, 2012 6:11:56 PM UTC-4, Hassan Alnatour wrote:
>
> Dear ALL,
>
> I have a website  it has two languages so i have a controller for 
> every language , i want to change the labels for the fields in the login 
> and registration form  , how can i do that ?
>  
>


[web2py] Re: More Twitter fun...

2012-03-30 Thread Massimo Di Pierro
Check it again.

On Friday, 30 March 2012 10:48:21 UTC-5, Anthony wrote:
>
> Maybe we should take this down: http://www.web2py.com/php. The Python 
> "cognoscenti" are having a hissy fit about it on Twitter:
>
> https://twitter.com/#!/mitsuhiko/status/185448802524729344
> https://twitter.com/#!/AaronVanderlip/statuses/185453068572299264
> https://twitter.com/#!/crgwbr/statuses/185449279496785920
>
> Anthony
>


[web2py] Validators.py

2012-03-30 Thread Bruce Wade
Hi,

I am curious why the validators don't use translations engine? For example
IS_STRONG English is great however I can't translate it without overriding
the error message. What is the reason for not wrapping the strings in a T()
so users of the validations can easily just update the translation files?

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Tracking/Tracing actions

2012-03-30 Thread Massimo Di Pierro
yes and no. The file is not loaded in memory and then written to file. It 
is uploaded into temp (request.vars.field.file points to the temp file) 
then shuil.copyfile from temp to the destination. You can compute the hash 
from request.vars.field.file then request.vars.field.file.seek(0)

On Friday, 30 March 2012 13:51:18 UTC-5, Anthony wrote:
>
> Let me put it this way:
>> Can I determine the hash of an uploaded file during the upload process 
>> (when the form is submitted) and before it is actually stored on the 
>> filesystem?
>>
>
> I haven't been following this thread, but that sounds doable. When the 
> file is uploaded, request.vars.file.file will hold the file object, and 
> request.vars.file.filename will hold the original filename, so you could do 
> something with those values before calling form.process(). You can also 
> specify an onvalidation function via form.process(..., 
> onvalidation=myvalidation), and I believe the function will be called 
> before the file is stored.
>
> Anthony 
>


[web2py] Re: Validators.py

2012-03-30 Thread Massimo Di Pierro
I think they do but now that I look into it, IS_STRONG does not. Please 
open a ticket and we'll fix it.

On Friday, 30 March 2012 17:40:53 UTC-5, Detectedstealth wrote:
>
> Hi,
>
> I am curious why the validators don't use translations engine? For example 
> IS_STRONG English is great however I can't translate it without overriding 
> the error message. What is the reason for not wrapping the strings in a T() 
> so users of the validations can easily just update the translation files?
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  


Re: [web2py] Re: Validators.py

2012-03-30 Thread Bruce Wade
Massimo, I have looked at the file none of them have it.

IE:
IS_URL error_message='enter a valid URL'
IS_HTTP_URL error_message='enter a valid URL'

On Fri, Mar 30, 2012 at 4:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I think they do but now that I look into it, IS_STRONG does not. Please
> open a ticket and we'll fix it.
>
>
> On Friday, 30 March 2012 17:40:53 UTC-5, Detectedstealth wrote:
>>
>> Hi,
>>
>> I am curious why the validators don't use translations engine? For
>> example IS_STRONG English is great however I can't translate it without
>> overriding the error message. What is the reason for not wrapping the
>> strings in a T() so users of the validations can easily just update the
>> translation files?
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.**fitnessfriendsfinder.com
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Validators.py

2012-03-30 Thread Bruce Wade
Ticket: http://code.google.com/p/web2py/issues/detail?id=747

On Fri, Mar 30, 2012 at 4:17 PM, Bruce Wade  wrote:

> Massimo, I have looked at the file none of them have it.
>
> IE:
> IS_URL error_message='enter a valid URL'
> IS_HTTP_URL error_message='enter a valid URL'
>
>
> On Fri, Mar 30, 2012 at 4:13 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> I think they do but now that I look into it, IS_STRONG does not. Please
>> open a ticket and we'll fix it.
>>
>>
>> On Friday, 30 March 2012 17:40:53 UTC-5, Detectedstealth wrote:
>>>
>>> Hi,
>>>
>>> I am curious why the validators don't use translations engine? For
>>> example IS_STRONG English is great however I can't translate it without
>>> overriding the error message. What is the reason for not wrapping the
>>> strings in a T() so users of the validations can easily just update the
>>> translation files?
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade
>>> http://www.wadecybertech.com
>>> http://www.warplydesigned.com
>>> http://www.**fitnessfriendsfinder.com
>>>
>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: More Twitter fun...

2012-03-30 Thread Anthony
Nice. :-)

On Friday, March 30, 2012 6:39:21 PM UTC-4, Massimo Di Pierro wrote:
>
> Check it again.
>
> On Friday, 30 March 2012 10:48:21 UTC-5, Anthony wrote:
>>
>> Maybe we should take this down: http://www.web2py.com/php. The Python 
>> "cognoscenti" are having a hissy fit about it on Twitter:
>>
>> https://twitter.com/#!/mitsuhiko/status/185448802524729344
>> https://twitter.com/#!/AaronVanderlip/statuses/185453068572299264
>> https://twitter.com/#!/crgwbr/statuses/185449279496785920
>>
>> Anthony
>>
>

Re: [web2py] Re: Validators.py

2012-03-30 Thread Anthony

>
> Massimo, I have looked at the file none of them have it.
>
> IE:
> IS_URL error_message='enter a valid URL'
> IS_HTTP_URL error_message='enter a valid URL'
>

 The error messages are not translated when specified as an argument to 
__init__, they are translated when they are actually returned by the 
__call__ method:

def __call__(self, value):
[validation code]
return (value, translate(self.error_message)

Anthony


[web2py] Re: More Twitter fun...

2012-03-30 Thread Ron McOuat
Love it hehe


[web2py] Re: data source configuration

2012-03-30 Thread nick name
The database connection is initialized in models/db.py (assuming you used 
the wizard to generate your application). Look for the line that says 
"db=DAL(...)", and make it select the right database according to your 
request, e.g. request.host, or however else you determine the configuration 
environment.

Alternatively, you could keep it all in the same database with a 
"request_tenant' field: 
https://groups.google.com/d/topic/web2py/CixV2qflqkk/discussion - 

if you add a field such as the following to a table:

...
   Field('request_tenant', default=request.host),
...
(where the default is however you identify the specific environment)

web2py will add a "and request_tenant=''+request.host+''" to every query 
relating to that table, and of course would insert it to new records. 
Effectively, this means every record in a table with such a field will only 
be seen when the default value of the field in this request is the same as 
when it was generated. (You can still get all records by either setting the 
default to None, or adding an "ignore_common_filter=True")

On Friday, March 30, 2012 4:55:16 PM UTC-4, Alex wrote:
>
> Hello,
>
> I need to configure my data source for different instances. Currently this 
> is the last problem preventing me from going productive. I run my 
> application for multiple customer instances and of course the database 
> connection is different for each customer. This issue also occurs if you 
> have a test and a productive environment. I think this is a fairly common 
> use case and necessary for most real world applications, so I'm really 
> surprised that I didn't see any solution for this in web2py (especially 
> since web2py is so easy and powerful for everything else). Or did I just 
> miss something?
>
> Massimo, in case you read this, do you have an advice for me? is an 
> environment configuration a feature that could be added in the future? I 
> think that I read somewhere that web2py developers don't think this is 
> necessary but I really don't understand why.
>
> Is there a workaround for me? I have some ideas but nothing seems to be 
> optimal. I'd prefer to avoid dirty hacks...
>
> thanks,
> Alex
>
>

[web2py] Re: How to Represent a Foreign Key Using Foreign Keys in Primary Table

2012-03-30 Thread Derek
I see what you mean. In that case, you don't want to reference the other 
table, since you don't have a many to many table.
For many to many relationships, you should have three tables.

table_one
table_two
table_relationship_between_one_and_two

But if you just want a list of the strings like so:   '%(first)s - 
%(second)s Against %(third)s'
What you wrote should work, based on what it says in the documentation, the 
defaults should be sufficient. You can try this -- add:

db.table_two.requires=IS_IN_DB(db,table_one.id, db.table_one._format, 
multiple=True)

That's just explicitly defining what should be the default...

On Friday, March 30, 2012 1:49:12 PM UTC-7, pjryan126 wrote:
>
> Derek:
>
> Thanks for your response. It's a many-to-many relationship between 
> table_one and table_two. i was hoping to denormalize this relationship with 
> list:reference, but maybe it's more trouble than it's worth in this case. 
>
> On Friday, March 30, 2012 3:38:23 PM UTC-4, pjryan126 wrote:
>>
>> I have the following two tables:
>>
>> db.define_table('table_one',
>> Field('first', db.first, '%(name)s'),
>> Field('second', db.second, '%(name)s'),
>> Field('third', db.third, '%(name)s'),
>> format = '%(first)s - %(second)s Against %(third)s')
>>
>> db.define_table('table_two',
>> Field('fourth', db.fourth),
>> Field('fifth', db.fifth), 
>> Field('table_ones', 'list:reference table_one'),
>> Field('sixth', list:string)
>>
>> When I go to add a record to the db.form table in appadmin, the 
>> db.form.plan_classes drop-down box populates using the id's in the 
>> respective db.table_one fields (i.e., "1 - 1 Against 2", etc).
>>
>> How would I get the items in the db.table_two.table_ones list to appear 
>> in a drop-down box using the field representations assigned in the 
>> db.table_one table definition? Any help on this would be greatly 
>> appreciated!
>>
>

[web2py] CSRF protection - off by default?

2012-03-30 Thread nick name
I was intrigued by this discussion: 
http://news.ycombinator.com/item?id=3778158 about CSRF.

Do I understand correctly that the FORM / SQLFORM CSRF protection only 
works when you pass a session (which is by default None)?

If so, I think it is important to update the book to caution everyone to 
use session variable with forms - it is not stressed enough.

Also, this might be serious enough to warrant a breaking change like the 
default views - e.g.:

if the user is ok with current situation, they have to pass 
"session=DISABLE_CSRF_PROTECTION" to form/sqlform
Otherwise, a form with "session=None" will always fail to accept.

(unless you set something like: 
request.default_session=DISABLE_CSRF_PROTECTION)



[web2py] Re: issue with multi-select widget

2012-03-30 Thread Derek
I'd say the most efficient is:
if type(mylist).__name__='string':
else

etc etc..

On Friday, March 30, 2012 3:36:01 AM UTC-7, weheh wrote:
>
> I have a grouping function based on what items are selected in a 
> multi-select widget. When the user presses a button, an ajax call is made 
> to a callback that evaluates the items that have been selected. The 
> evaluated item "list" is stored in request.vars.mylist.
>
> Here's the problem. The "list" of values stored in request.vars.mylist may 
> or may not be a list. So when I go to evaluate the selected items, I would 
> normally do something like this:
>
> for item in request.vars.mylist:
> do_something(int(item))
>
> The problem is this. If only one item is selected, a list is not returned. 
> A string is returned instead. So if the request.vars.mylist is a single 
> item, '123', then item will be set as if request.vars.mylist were 
> ['1','2','3'].
>
> Now I know I can easily compensate for that (I'm curious to hear what 
> people would suggest as the most efficient method). But why wouldn't that 
> be considered an inconsistency that needed fixing?
>


[web2py] Re: CSRF protection - off by default?

2012-03-30 Thread Anthony
Note, the book now recommends using .validate() or .process(), and they 
default to using the session (and therefore protecting against CSRF). I 
believe CSRF protection is on by default in Crud, Auth, and SQLFORM.grid as 
well. I agree, though, that the book should discuss CSRF in the context of 
form submission and make it clear that excluding the session from 
.accepts() is a security risk.

Anthony

On Friday, March 30, 2012 9:17:52 PM UTC-4, nick name wrote:
>
> I was intrigued by this discussion: 
> http://news.ycombinator.com/item?id=3778158 about CSRF.
>
> Do I understand correctly that the FORM / SQLFORM CSRF protection only 
> works when you pass a session (which is by default None)?
>
> If so, I think it is important to update the book to caution everyone to 
> use session variable with forms - it is not stressed enough.
>
> Also, this might be serious enough to warrant a breaking change like the 
> default views - e.g.:
>
> if the user is ok with current situation, they have to pass 
> "session=DISABLE_CSRF_PROTECTION" to form/sqlform
> Otherwise, a form with "session=None" will always fail to accept.
>
> (unless you set something like: 
> request.default_session=DISABLE_CSRF_PROTECTION)
>
>

[web2py] Re: Storing class instances in sessions... or somewhere

2012-03-30 Thread Web2py Newbie
Here's a simplified version:

class debugDM(object):
def __init__(self):
self.allDefs=[]

def add_def(self, rawText):
if rawText not in self.allDefs:
self.allDefs.append(rawText)

Here are some controllers:

def debug2():
print "counter: %s, counter2: %s len: 
%s"%(session.counter,session.counter2, len(session.defManager.allDefs))
#session.defManager.add_def("Test%s"%session.counter)
session.counter +=1
return locals() #session.defManager.dump()

def debug3():
print "counter: %s, counter2: %s len: 
%s"%(session.counter,session.counter2, len(session.defManager.allDefs))
session.defManager.add_def("Test%s"%session.counter)
print '\nDebug3: '.join(session.defManager.allDefs)
#session.counter +=1
return "".join(session.defManager.allDefs)

def test():
print "\n** in test()"
right_sidebar_enabled = True
if session.defManager is None: # web2py returns None for undefined 
attributes
print "initialising definition manager"
session.defManager = toc.debugDM()
print "In test(): ",session.defManager
session.defManager.add_def("AddFromTest")
session.counter = 0
session.counter2 = 0



On Friday, 30 March 2012 23:55:59 UTC+11, Massimo Di Pierro wrote:
>
> Can I see the object that you are storing in session?
>
> On Friday, 30 March 2012 01:09:09 UTC-5, Web2py Newbie wrote:
>>
>> session doesn't seem to have a "force an update to me" method, so I am 
>> just incrementing a counter. 
>>
>

[web2py] Re: Storing class instances in sessions... or somewhere

2012-03-30 Thread Web2py Newbie
I meant "a simplified version which acts the same way"



Re: [web2py] Re: Validators.py

2012-03-30 Thread Bruce Wade
Awe so that also answers my question from a past post on how to use
translate in a custom module, that is out side the application directory.

On Fri, Mar 30, 2012 at 4:57 PM, Anthony  wrote:

> Massimo, I have looked at the file none of them have it.
>>
>> IE:
>> IS_URL error_message='enter a valid URL'
>> IS_HTTP_URL error_message='**enter a valid URL'
>>
>
>  The error messages are not translated when specified as an argument to
> __init__, they are translated when they are actually returned by the
> __call__ method:
>
> def __call__(self, value):
> [validation code]
> return (value, translate(self.error_message)
>
> Anthony
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Broken application after upgrade.

2012-03-30 Thread Derek
If you deleted a .table file, fake_migrate will recreate it for you.

On Tuesday, March 27, 2012 6:34:58 PM UTC-7, web-dev-m wrote:
>
> Just continues trying to connect to any application.  The application is 
> still under development.  After your suggestion, I dumped my db and deleted 
> everything from the databases folder. 
>
> It's working now...not sure what exactly happened.
>
> On Tuesday, March 27, 2012 4:54:51 PM UTC-5, pbreit wrote:
>>
>> It's weird that one app would affect other apps since usually they are 
>> pretty insulated from each other.
>>
>> Deleting .table files can be a problem. Was the app under development and 
>> you wouldn't care if you erased the DB? If so (and it's SQLite), you can 
>> delete all the files in the "database" directory and start with a fresh new 
>> DB.
>>
>> When you say that it's not working, how exactly does it behave? Do you 
>> get any error messages? Have you touched the routes.py file?
>>
>> Another thing to consider is downloading a fresh version of Web2py and 
>> then copying the applications over one-by-one.
>>
>

[web2py] web2py and apache

2012-03-30 Thread netcode
hello guys,
please am a newbie on ubuntu environment but been using python for a month 
now. I am using the InstantPress to make a blog on the web2py framework. 
Now, am reading the deployment recipe on the official web2py documentation 
but it males no sense to me yet. i get confused at this point:

Then, enable the SSL module, the proxy module, and the WSGI module in 
Apache:

1.
2.
3.
4.
5.
6.

sudo ln -s /etc/apache2/mods-available/proxy_http.load \
   /etc/apache2/mods-enabled/proxy_http.load

Am i to run the command as a single line or am i to break them into two, i 
really dont understand the backslah at the end of the first line. cos when 
i run as a single line, i dont see anything processing on my terminal.
Also, most links on web2py site are broken, they give an invalid reference 
ticket.


thanks, 
netcode


[web2py] Re: data source configuration

2012-03-30 Thread Alex
ok, I think now I understand how the request_tenant works. So there would 
be just one database for everything but every table is filtered by the 
field? If that is the case that's really not what I want.

I also thought about selecting the db by the request.env.http_host etc. 
this also seems like a hack to me but I guess I could live with that... 
only problem is this will not work with cron jobs (accessing the db), at 
least that is what I assume. I'm currently using enviroment variables for 
the db config but this fails now because of the cron jobs (external cron).

I'm now thinking of reading the db config from a config file in db.py but 
this also seems like a really bad solution. Then I'd probably have the file 
I/O for every request just to get the db configuration.

Am Samstag, 31. März 2012 03:05:27 UTC+2 schrieb nick name:
>
> The database connection is initialized in models/db.py (assuming you used 
> the wizard to generate your application). Look for the line that says 
> "db=DAL(...)", and make it select the right database according to your 
> request, e.g. request.host, or however else you determine the configuration 
> environment.
>
> Alternatively, you could keep it all in the same database with a 
> "request_tenant' field: 
> https://groups.google.com/d/topic/web2py/CixV2qflqkk/discussion - 
>
> if you add a field such as the following to a table:
>
> ...
>Field('request_tenant', default=request.host),
> ...
> (where the default is however you identify the specific environment)
>
> web2py will add a "and request_tenant=''+request.host+''" to every query 
> relating to that table, and of course would insert it to new records. 
> Effectively, this means every record in a table with such a field will only 
> be seen when the default value of the field in this request is the same as 
> when it was generated. (You can still get all records by either setting the 
> default to None, or adding an "ignore_common_filter=True")
>
> On Friday, March 30, 2012 4:55:16 PM UTC-4, Alex wrote:
>>
>> Hello,
>>
>> I need to configure my data source for different instances. Currently 
>> this is the last problem preventing me from going productive. I run my 
>> application for multiple customer instances and of course the database 
>> connection is different for each customer. This issue also occurs if you 
>> have a test and a productive environment. I think this is a fairly common 
>> use case and necessary for most real world applications, so I'm really 
>> surprised that I didn't see any solution for this in web2py (especially 
>> since web2py is so easy and powerful for everything else). Or did I just 
>> miss something?
>>
>> Massimo, in case you read this, do you have an advice for me? is an 
>> environment configuration a feature that could be added in the future? I 
>> think that I read somewhere that web2py developers don't think this is 
>> necessary but I really don't understand why.
>>
>> Is there a workaround for me? I have some ideas but nothing seems to be 
>> optimal. I'd prefer to avoid dirty hacks...
>>
>> thanks,
>> Alex
>>
>>

[web2py] Re: More Twitter fun...

2012-03-30 Thread Andrew
Am I missing something ?   Looks alright to me. 

On Saturday, March 31, 2012 1:57:55 PM UTC+13, Ron McOuat wrote:
>
> Love it hehe
>