[web2py] SQLFORM widget IS_IN_SET translation

2018-07-24 Thread rāma
I could do this in SQLFORM readonly mode: https://groups.google.com/forum/#!topic/web2py/KnEaFsRRHL4 However, how do you make SQLFORM to show the translations in edit mode. Do you have to modify the widget? How? Thank you. -- Resources: - http://web2py.com - http://web2py.com/book (Documenta

[web2py] info: represent when IS_IN_SET multiple is set to True

2018-07-24 Thread rāma
Just to share with everyone for a record here. Tried searching and couldn't find anything easily. If you're using the T function for translations and you need to represent an IS_IN_SET value using represent, here is the way to do it: represent= lambda f, r: [T(i.languages) for i in r]) This ha

Re: [web2py] Re: Updated script for 'Moving your data from one database to another' recipe

2018-07-24 Thread 黄祥
*static/scripts/python/mover.py* URI = 'mysql://root:mysqlpassword@localhost/site' other_db = DAL(URI, auto_import = True) print ('Exporting data') db.export_to_csv_file(open('tmp.csv', 'wb') ) print ('Importing data') other_db.import_from_csv_file(open('tmp.csv', 'rb') ) other_db.commit() print ('

[web2py] Re: what is an id map? In the context of import_from_csv_file for pydal (web2py)

2018-07-24 Thread Kevin Huang
Thanks for the response Leonel! On Wednesday, July 25, 2018 at 12:25:50 AM UTC+8, Leonel Câmara wrote: > > Ideally you would save the id_map from the first time you imported, you > can then supply the same id_map to the import_from_csv_file function so it > would update the records instead of in

[web2py] Re: Dealing with reserved keywords when you change or upgrade your database from SQLite to POSTGRES

2018-07-24 Thread Anthony
I believe the DAL now always double quotes table and field names when constructing queries, so I'm not sure you even need to use check_reserved anymore. What happens if you simply remove it? Anthony On Tuesday, July 24, 2018 at 4:39:05 PM UTC-4, pbreit wrote: > > Apparently if you are going to

[web2py] Re: Dealing with reserved keywords when you change or upgrade your database from SQLite to POSTGRES

2018-07-24 Thread pbreit
Apparently if you are going to use "rname" you may need to surround the column name with single and double quotes which will send the double-quotes to the DB: Field('state', rname='"state"') As an aside, it always seemed to me that a DB access library would be able to be structured in such a w

[web2py] Re: Issues getting web2py to work.

2018-07-24 Thread Anthony
You'll need to run web2py with Python 2.7 (the specific issue below is that the DAL code includes a dictionary comprehension, which is only supported in Python 2.7+). Anthony On Tuesday, July 24, 2018 at 4:03:13 PM UTC-4, Ben Duncan wrote: > > Redhack 6.9 > Python 2.6.6 > > Installed web2py sou

[web2py] Issues getting web2py to work.

2018-07-24 Thread Ben Duncan
Redhack 6.9 Python 2.6.6 Installed web2py source. Ran the command: >python web2py.py got the message: Traceback (most recent call last): File "web2py.py", line 21, in import gluon.widget File "/data/web2py/web2py/gluon/__init__.py", line 23, in import pydal File "/data/web2py/web2

[web2py] Re: Sum/Total of the column values in SQLFROM.grid?

2018-07-24 Thread Anthony
You should do a separate query and have the database calculate the sum for you (rather than loading all the records from the database and doing the calculation in Python). Anthony On Tuesday, July 24, 2018 at 3:08:12 PM UTC-4, sandeep patel wrote: > > Hello, > I have a grid that is worked as I

[web2py] Sum/Total of the column values in SQLFROM.grid?

2018-07-24 Thread sandeep patel
Hello, I have a grid that is worked as I expected. now I want to sum all the values that have in "number_of_bags" Field. So that I have used grid.rows (*sum([int(grid.rows[i].number_of_bags) for i in range(len(grid.rows))])*) but this gives me sum of first 10 records but i want sum of all the v

[web2py] Re: Dealing with reserved keywords when you change or upgrade your database from SQLite to POSTGRES

2018-07-24 Thread Rahul
All, To add - Syntax like below worked however I am getting a few application errors. Field(‘notifys’ , ‘boolean’, rname=‘notify’), In above notify is a reserved postgres keyword but we can use it as a field name in postgres db table. The reference field name ‘notifys’ in this case is some

[web2py] Re: what is an id map? In the context of import_from_csv_file for pydal (web2py)

2018-07-24 Thread Leonel Câmara
Ideally you would save the id_map from the first time you imported, you can then supply the same id_map to the import_from_csv_file function so it would update the records instead of inserting new ones. To save the id_map you can do something like this the first time you import my_map = {} db.

Re: [web2py] Deleting a db table row

2018-07-24 Thread Maurice Waka
This works well. I guess I failed to clarify: 2. Is there a way of following this example but deleting rows upto a certain limit, say anything above 50 like in this example:... Should have been retain latest inputs up a certain limit e.g. the last 50, and delete older inputs. I got a better deal

[web2py] Re: what is an id map? In the context of import_from_csv_file for pydal (web2py)

2018-07-24 Thread Kevin Huang
So let's say I have a CSV with: id,name 1,Bob 2,Mary 3,John let's say I update the CSV to the following: id,name 1,Bob 2,Sue 3,John How would I use id_map parameter to make this change happen so the table updates appropriately? On Tuesday, July 24, 2018 at 7:10:21 PM UTC+8, Leonel Câmara wro

[web2py] Re: scheduler_worker table is not created

2018-07-24 Thread GiuGiu Roberti
Try this: 1) - delete all databases/*_scheduler_*.table files 2) - delete scheduler_worker, scheduler_tasks, scheduler_run table from your backend MANUALLY 3) - use Scheduler(db, , migrate=True) 4) - open appadmin 5) - reset Scheduler(db, , migrate=False) In my case i solved but i

[web2py] Web2py and Janrain: facebook login redirect misfires

2018-07-24 Thread GiuGiu Roberti
Hi, I use social login service by Janrain (https://www.janrain.com) my website is made using Web2py. I set up the service and the site worked properly for 11 months. But now the Facebook social login redirect fails (on the first try) and if I reload the page everything works correctly. I do not

[web2py] Re: what is an id map? In the context of import_from_csv_file for pydal (web2py)

2018-07-24 Thread Leonel Câmara
This something used very frequently when you're making code to import something. You can have a map (a dictionary) that maps existing record ids to the ids that are present in the csv. This is used for two reasons, to update records instead of inserting new ones when you have already imported o

[web2py] Re: Dealing with reserved keywords when you change or upgrade your database from SQLite to POSTGRES

2018-07-24 Thread Rahul
Thank you! for getting back Dave and pointing me to this page - I used it for *state *field name and it did *not *work for me. Field('state', rname='state_country'), Give me below syntax error still - *SyntaxError*: invalid table/column name "state" is a "POSTGRES_NONRESERVED" reserved SQ

[web2py] Re: error: cannot switch to a different thread

2018-07-24 Thread Alvin Ang
seems like it's due to my Scheduler implementation within the App, I remove scheduler.py from models and App starts to work fine. best regards, Alvin -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.

[web2py] what is an id map? In the context of import_from_csv_file for pydal (web2py)

2018-07-24 Thread Kevin Huang
Hi all, This should be simple, but what is the id_map specified in import_from_csv_file(*csvfile*, *id_map=None*, *null=''*, *unique='uuid'*, *id_offset=None*, *transform=None*, *validate=False*, ***kwargs*) function from https://pydal.readthedocs.io/en/latest/#pydal.base.DAL.Table.import_fr