[web2py] Call functions from other applications without network requests

2017-01-04 Thread Brendan Barnwell
I have a situation where I have (or am going to have) multiple applications running on a single web2py instance. Each application will do its own thing, but they are all using the same databases. Some of the applications may serve as backend API endpoints where certain kinds of data can be

[web2py] Re: Arbitrary args/kwargs with service?

2017-01-04 Thread Brendan Barnwell
It looks like I could use request.restful for that, but to be honest I find that mechanism somewhat awkward. Creating functions as local variables and then returning locals() just seems gross to me. :-) But from the other side of things, I guess the question is, if we can do that, is there

[web2py] Re: Rest Json

2017-01-04 Thread PK
On Wednesday, January 4, 2017 at 10:04:31 PM UTC, Anthony wrote: > > On Wednesday, January 4, 2017 at 4:42:28 PM UTC-5, 黄祥 wrote: >> >> with >> return response.json(list_of_records) >> >> it return a json format even we request it with *.xml >> curl http://127.0.0.1:8000/a/default/api/test.xml

[web2py] Formatting decimal in SQLFORM.smartgrid edit form

2017-01-04 Thread icodk
I have the following field definition: Field('unit_price', 'decimal(8,4)', label=T('Price'),represent=lambda val,row: '{:8.2f}'.format(val),requires=IS_DECIMAL_IN_RANGE(0, 1, dot=","),default=0, writable=True,readable=True), This field shows as it should (with only 2 decimals) in the grid

[web2py] Re: DAL: why is "field == None" not "field is None"?

2017-01-04 Thread Anthony
On Wednesday, January 4, 2017 at 4:28:28 PM UTC-5, backseat wrote: > > My PEP8 checker tells me that: > > db.table.field == None > > should be > > db.table.field is None > When creating expressions with DAL Field objects, we don't want to generate boolean values but instead need to generate

[web2py] Re: Rest Json

2017-01-04 Thread Anthony
On Wednesday, January 4, 2017 at 4:42:28 PM UTC-5, 黄祥 wrote: > > with > return response.json(list_of_records) > > it return a json format even we request it with *.xml > curl http://127.0.0.1:8000/a/default/api/test.xml > is there a way to have it both json or xml without content variable? > You

[web2py] Re: DAL: why is "field == None" not "field is None"?

2017-01-04 Thread Dave S
On Wednesday, January 4, 2017 at 1:28:28 PM UTC-8, backseat wrote: > > My PEP8 checker tells me that: > > db.table.field == None > > should be > > db.table.field is None > > But that doesn't evaluate correctly. Why? > > (I did search for this but couldn't find it discussed before: apologies if

[web2py] Re: truncate tables with record versioning enabled

2017-01-04 Thread 黄祥
error traceback about reference to another table. not sure what is the detail root cause, but found the solution after restart the server (kill python), perhaps it got tired, lol thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Rest Json

2017-01-04 Thread 黄祥
with return response.json(list_of_records) it return a json format even we request it with *.xml curl http://127.0.0.1:8000/a/default/api/test.xml is there a way to have it both json or xml without content variable? best regards, stifan -- Resources: - http://web2py.com -

[web2py] DAL: why is "field == None" not "field is None"?

2017-01-04 Thread backseat
My PEP8 checker tells me that: db.table.field == None should be db.table.field is None But that doesn't evaluate correctly. Why? (I did search for this but couldn't find it discussed before: apologies if I missed it). Thanks -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Re: Column export to txt

2017-01-04 Thread Anthony
On Wednesday, January 4, 2017 at 2:40:22 PM UTC-5, yarecki wr wrote: > > I found it needs _file and this works fine but then I tried > export_to_csv_file(mycsv,'wb', > write_colnames=False) and that tells me the argument is incorrect. I also > tried calnames=False and represent=False from the

[web2py] Re: Column export to txt

2017-01-04 Thread yarecki wr
I found it needs _file and this works fine but then I tried export_to_csv_file(mycsv,'wb', write_colnames=False) and that tells me the argument is incorrect. I also tried calnames=False and represent=False from the BOOK each time getting the error with invalid keyword argument. -- Resources:

[web2py] Re: Column export to txt

2017-01-04 Thread Anthony
Sorry, it's .export_to_csv_file (I corrected the original). Anthony On Wednesday, January 4, 2017 at 6:26:47 AM UTC-5, yarecki wr wrote: > > Testing Anthony's method, although it looks simpler I get an >>> AttributeError saying Rows object has no attribute export_to_csv. Also I >>> added >>>

[web2py] Re: Column export to txt

2017-01-04 Thread Dave S
On Wednesday, January 4, 2017 at 3:26:47 AM UTC-8, yarecki wr wrote: > > Testing Anthony's method, although it looks simpler I get an >>> AttributeError saying Rows object has no attribute export_to_csv. Also I >>> added >>> >> data = open(myfile).read > in the same function I created for the

Re: [web2py] Re: db won't recreate when create site from scratch

2017-01-04 Thread b.l. masters
Hi Thanks for getting back. I got sidetracked with holiday travels and some other work. Here is what finally worked. I made sure that my databases folder was completed empty (not just the .table files). I switched everything to: db = DAL(... migrate_enabled=False, migrate=False)

[web2py] Re: Rest Json

2017-01-04 Thread PK
On Wednesday, January 4, 2017 at 4:21:35 PM UTC, Anthony wrote: > > Presumably you are relying on the generic.json view. Note, the only way > for a view to be triggered is for the controller to return a dictionary, > but of course that means the generic.json view will be converting a >

[web2py] Re: Simple question about jquery inside onclick...

2017-01-04 Thread António Ramos
found it $('#myTabs a[href=\'#control-sidebar-favorites-tab\']').tab('show'); thank you 2017-01-04 17:25 GMT+00:00 António Ramos : > the first selector is accepted but the second gives a string error... > > where is the bug? > > onclick=" >

[web2py] Simple question about jquery inside onclick...

2017-01-04 Thread António Ramos
the first selector is accepted but the second gives a string error... where is the bug? onclick=" $('.control-sidebar').addClass('control-sidebar-open'); $('#myTabs a[href="#control-sidebar-favorites-tab"]').tab('show'); " thank you -- Resources: - http://web2py.com -

[web2py] Re: How to show a writable=False field as a disabled input

2017-01-04 Thread icodk
It works Thanks again for helping me On Wednesday, January 4, 2017 at 5:33:32 PM UTC+1, Anthony wrote: > > Field('tag_id', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, > _disabled=True)) > > Anthony > > On Wednesday, January 4, 2017 at 11:22:35 AM UTC-5, icodk wrote: >> >> .. other

[web2py] Re: How to show a writable=False field as a disabled input

2017-01-04 Thread Anthony
Field('tag_id', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, _disabled=True)) Anthony On Wednesday, January 4, 2017 at 11:22:35 AM UTC-5, icodk wrote: > > .. other then setting it to writable=True so it get's an id and name and > then manipulate it with javascript on

[web2py] Re: What is the simplest way to password protect a video?

2017-01-04 Thread Anthony
> > Both URL signing (see > http://web2py.com/books/default/chapter/29/12/components-and-plugins?search=signing#LOAD-and-Client-Server-component-communications>, > > before the "Trapped ..." section) > and JWT (see gluon/contrib/web2py_jwt.py) are available to address that > issue, but the

[web2py] Re: Smartgrid headers not working

2017-01-04 Thread Anthony
Any argument to .grid that is normally a dictionary must actually be a dictionary of dictionaries with .smartgrid -- you need a separate key for each table: headers = {'sede': {'sede.nome': 'Struttura', 'sede.is_active': 'Attivo'}} Anthony On Wednesday, January 4, 2017 at 11:15:29 AM UTC-5,

[web2py] Re: What is the simplest way to password protect a video?

2017-01-04 Thread Anthony
Would a digitally signed URL provide sufficient protection (no need for a password in that case): http://web2py.com/books/default/chapter/29/04/the-core#Digitally-signed-urls Anthony On Tuesday, January 3, 2017 at 12:12:01 AM UTC-5, Joe wrote: > > What I would like to do is to send a user a

[web2py] Re: How to show a writable=False field as a disabled input

2017-01-04 Thread icodk
.. other then setting it to writable=True so it get's an id and name and then manipulate it with javascript on $(document).ready(function(... On Wednesday, January 4, 2017 at 5:19:02 PM UTC+1, icodk wrote: > > Thanks. You are right . Still, is it possible to show a disabled input > element

[web2py] Re: Rest Json

2017-01-04 Thread Anthony
Presumably you are relying on the generic.json view. Note, the only way for a view to be triggered is for the controller to return a dictionary, but of course that means the generic.json view will be converting a dictionary to JSON -- there is no way to have it receive and convert a list to

[web2py] Re: How to show a writable=False field as a disabled input

2017-01-04 Thread icodk
Thanks. You are right . Still, is it possible to show a disabled input element instead of the standard div shown for writable=False fields ? On Wednesday, January 4, 2017 at 5:11:23 PM UTC+1, Anthony wrote: > > The "represent" attribute should be a function that takes the value and > outputs

[web2py] Smartgrid headers not working

2017-01-04 Thread Andrea Fae'
I have this situation: headers={'sede.nome':'Struttura','sede.is_active':'Attivo'} exportcls = dict(csv_with_hidden_cols=False, xml=True, html=False, json=False, tsv_with_hidden_cols=False, tsv=False) grid = SQLFORM.smartgrid(db.sede,linked_tables=['uo','pc'],fields=[db.sede.nome,

[web2py] Re: grid exportclasses not work in recent version

2017-01-04 Thread Andrea Fae'
Hello, I solved with this headers={'sede.nome':'Struttura','sede.is_active':'Attivo'} exportcls = dict(csv_with_hidden_cols=False, xml=True, html=False, json=False, tsv_with_hidden_cols=False, tsv=False) grid =

[web2py] Re: How to show a writable=False field as a disabled input

2017-01-04 Thread Anthony
The "represent" attribute should be a function that takes the value and outputs some transformation of it. Anthony On Wednesday, January 4, 2017 at 10:44:59 AM UTC-5, icodk wrote: > > In SQLFORM.factory, when a field is writable=False, the field is only > shown with it's default value as an

[web2py] Re: python code in wiki page

2017-01-04 Thread Massimo Di Pierro
The whole point of a wiki markup is that you cannot because you should not put code into it. In fact when it is possible that is considered a vulnerability. That said it is possible to create custom tags (for example ````:execute) that will run you marked up code. I do not recommend it.

[web2py] How to show a writable=False field as a disabled input

2017-01-04 Thread icodk
In SQLFORM.factory, when a field is writable=False, the field is only shown with it's default value as an html div. Is it possible to represent it as a disabled INPUT (it both looks better and is accessible for java script ) ? I tried:

[web2py] Re: truncate tables with record versioning enabled

2017-01-04 Thread Massimo Di Pierro
what is the error? you may to first truncate all the tables referencing that table, in particular the _archive tables. On Monday, 2 January 2017 00:00:06 UTC-6, 黄祥 wrote: > > is it possible to truncate tables with record versioning enabled? > *e.g.* > def truncate(): > for table in db.tables: >

[web2py] Re: Simple scheduler issue

2017-01-04 Thread Niphlod
you're probably referring to -X . in any case, web2py.py -h is your best friend ;-) On Tuesday, January 3, 2017 at 12:47:39 AM UTC+1, Aydin wrote: > > I cann't believe I have spent 3 days trying every thing to find out what > the hell is happening. Last time I used it, it was 2 years ago and I

Re: [web2py] Re: Issues with record versioning

2017-01-04 Thread 黄祥
have the same situation but work fine, modified_on and modified_by is updated on the table. not sure why update_record on your side is not work. best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: Rest Json

2017-01-04 Thread 黄祥
tryin to help but no clue, hehe *python console work as expected* >>> d = {"content": [{"a": "1", "b": "2", "c": "3"}]} >>> l = d.values() >>> l[0] [{'a': '1', 'c': '3', 'b': '2'}] *controllers/default.py* @request.restful() def api(): response.view = 'generic.' + request.extension def

[web2py] Rest Json

2017-01-04 Thread PK
Can i remove "content" from restapi return json ? it gives a little trouble when i m trying to get or post json object. -- Resources: - http://web2py.com -

Re: [web2py] Re: Issues with record versioning

2017-01-04 Thread Ricardo Oliveira
Thanks Áureo, good to know! I use the other format because I do a few checks before doing the update, to see if the data is valid, but this short notation will no doubt be helpful in the future :) Ricardo. On Wednesday, January 4, 2017 at 11:06:05 AM UTC, Áureo Dias Neto wrote: > > Hello, > >

[web2py] Re: Column export to txt

2017-01-04 Thread yarecki wr
> > Testing Anthony's method, although it looks simpler I get an >> AttributeError saying Rows object has no attribute export_to_csv. Also I >> added >> > data = open(myfile).read in the same function I created for the export to txt and created a view for it. This allowed me to get the data

Re: [web2py] Re: Issues with record versioning

2017-01-04 Thread Áureo Dias Neto
Hello, You can do this, for update db(db.person.id==1).update(name='Tim') 2017-01-04 9:01 GMT-02:00 Ricardo Oliveira : > Hi Anthony, > > Thanks for your reply. > I'm using the DAL's insert method for the creation. Eg: > > db.table_x.insert(name='something') > > For

[web2py] Re: Issues with record versioning

2017-01-04 Thread Ricardo Oliveira
Hi Anthony, Thanks for your reply. I'm using the DAL's insert method for the creation. Eg: db.table_x.insert(name='something') For updates, I get the rows from the table first, change the values on the row object and then use the update_record() method for updating. Eg: record =

[web2py] Re: What is the simplest way to password protect a video?

2017-01-04 Thread Dave S
On Monday, January 2, 2017 at 9:12:01 PM UTC-8, Joe wrote: > > What I would like to do is to send a user a link to a page where there is > a video. When the user clicks to play the video, he will have to submit a > password *(which I already sent him*) to watch the video. > > I don't want to

[web2py] Re: Retrofit and Web2py

2017-01-04 Thread Htet Wai Kyu
Can i change web2py json to [{ }] instead of content[{}] -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are

[web2py] Re: how to make a set object from a list object

2017-01-04 Thread Dave S
On Tuesday, January 3, 2017 at 5:01:31 PM UTC-8, Alex Glaros wrote: > > is this correct way to make a set object from a list object? > > all_roles = db(db.Role.id.belongs(aggregateRoleData)).select(db.Role.ALL) > > here is the list aggregateRoleData: [22L, 23L, 24L, 25L, 26L, 320L, 321L, >