[web2py] Re: how to access external API

2015-10-01 Thread Leonel Câmara
That's not problem in python 2 a string like this u'' just means it's unicode you can convert it to utf-8 but there's no need. If you notice how I do it in my example I use the dict the API returns as the dict my controller returns, so you access it's keys directly in the view. --

[web2py] interpolate table name

2015-10-01 Thread Mark Billion
Following up on my last post--this fails: db.%s.validate_and_insert(...) %var_containing_table_name Any thoughts on how to interpolate? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] interpolate table name

2015-10-01 Thread Anthony
You cannot treat Python code like a string. In this case, though, you can use dictionary syntax: db[table_name].validate_and_insert() Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: how to access external API

2015-10-01 Thread Alex Glaros
sure, I copied your view exactly, but is there anything different in the view that you tested on your side? {{extend 'layout.html'}} City {{=city}} Region {{=region}} Country {{=country}} Do I need to define "city" in my controller? I get this error: name 'city' is not

Re: [web2py] Re: how to access external API

2015-10-01 Thread 'Diogene Laerce' via web2py-users
Le 01/10/2015 17:26, Alex Glaros a écrit : > sure, I copied your view exactly, but is there anything different in > the view that you tested on your side? > | > {{extend 'layout.html'}} > > City > {{=city}} > Region > {{=region}} > Country > {{=country}} > > | > > Do I need to define

[web2py] Re: Wizard inside a LOAD

2015-10-01 Thread Jose
I found this [1] and [2]. it seems that with some modifications on an old version of web2py work (web2py.js and web2py_ajax.html), but I can not fix it in new versions José [1] https://groups.google.com/forum/?fromgroups#!topic/web2py/J7-SD0n8hQQ [2]

Re: [web2py] Re: how to access external API

2015-10-01 Thread Alex Glaros
hi Laer, it's available as can be seen from displaying contents of "location_data" {u'loc': u'38.6071,-121.4633', u'city': u'Sacramento', u'country': u'US', u'region': u'California', u'hostname': u'No Hostname', u'ip': u'159.145.7.104', u'org': u'AS1226 California Technology Agency',

[web2py] IOError(11, 'Resource temporarily unavailable')

2015-10-01 Thread Calvin
Hi We have been experiencing the above error message particularly for calls which require more complex queries. The set up is as follows: nginx, uwsgi, postgresql-9.1, web2py Version 2.11.2-stable+timestamp.2015.05.30.11.29.46 We have seen this error occur at different controllers/function.

[web2py] Re: IOError(11, 'Resource temporarily unavailable')

2015-10-01 Thread Niphlod
where does this error pop up ? On Thursday, October 1, 2015 at 8:53:01 PM UTC+2, Calvin wrote: > > Hi > > We have been experiencing the above error message particularly for calls > which require more complex queries. The set up is as follows: > > nginx, uwsgi, postgresql-9.1, web2py Version >

Re: [Bulk] Re: [web2py] Re: how to access external API

2015-10-01 Thread Alex Glaros
sure, it is the same maybe I need to define the globals or location_data as a dict? as a work-around, I can read location_data as string, but seems that a simple answer might be available -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

Re: [Bulk] Re: [web2py] Re: how to access external API

2015-10-01 Thread 'Diogene Laerce' via web2py-users
Le 01/10/2015 21:05, Alex Glaros a écrit : > hi Laer, > > it's available as can be seen from displaying contents of "location_data" > > {u'loc': u'38.6071,-121.4633', u'city': u'Sacramento', u'country': > u'US', u'region': u'California', u'hostname': u'No Hostname', u'ip': > u'159.145.7.104',

[web2py] Re: Wizard inside a LOAD

2015-10-01 Thread Niphlod
getting on it... On Thursday, October 1, 2015 at 8:21:50 PM UTC+2, Jose wrote: > > I found this [1] and [2]. it seems that with some modifications on an old > version > of web2py work (web2py.js and web2py_ajax.html), but I can not fix it in new > versions > > José > > > [1]

Re: [Bulk] Re: [web2py] Re: how to access external API

2015-10-01 Thread Alex Glaros
This works. But is it good programming? in controller, convert into a dict: location_data = dict(json.loads(fetch('http://ipinfo.io/%s/json' % request.client))) in view: {{=location_data['city']}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

Re: [Bulk] Re: [web2py] Re: how to access external API

2015-10-01 Thread 'Diogene Laerce' via web2py-users
Le 01/10/2015 22:30, Alex Glaros a écrit : > This works. But is it good programming? > > in controller, convert into a dict: > > | > location_data > =dict(json.loads(fetch('http://ipinfo.io/%s/json'%request.client))) > | > > in view: > > | > {{=location_data['city']}} > | As Leonel said,

[web2py] Re: Wizard inside a LOAD

2015-10-01 Thread Niphlod
umpf. the behaviour is reproducible. The thing is, handling component redirects with ajax as normal redirects is bad because ajax just follow the same convention as browsers and it's impossible to intercept a get wich follows a redirect from a normal get in any way. For now the proposed

[web2py] console.log on page reload?

2015-10-01 Thread Tom Campbell
Working on a single-page app and trying to ensure that only part of the page gets refreshed. Doing some tests using LOAD() that look like this: *file default/new.html:* {{extend 'layout.html'}} {{=LOAD('default', 'new.load',ajax=True)}} *file default/new.load:* {{if 'message'in globals():}}

[web2py] Re: Wizard inside a LOAD

2015-10-01 Thread Niphlod
proposed fix: gluon.main : just after setting web2py-component-command, set a new web2py-component-origaction header = request.url web2py.js : in ajax_page, inside oncomplete, just before web2py.trap_form, handle it var origaction = xhr.getresponseheader('web2py-component-origaction');

[web2py] Re: how to access external API

2015-10-01 Thread Leonel Câmara
Alex I think you're slightly confused, let me explain. This was the original controller function I suggested. def locateme(): import json from gluon.tools import fetch location_data = json.loads(fetch('http://ipinfo.io/%s/json' % request. client)) return location_data Note that

[web2py] Re: console.log on page reload?

2015-10-01 Thread Derek
You don't need that, just do this... console.log('loaded ' + date()) On Thursday, October 1, 2015 at 4:01:14 PM UTC-7, Tom Campbell wrote: > > Working on a single-page app and trying to ensure that only part of the > page gets refreshed. Doing some tests using LOAD() that look like this: > >

[web2py] Re: how to access external API

2015-10-01 Thread Alex Glaros
thanks Leonel, I get the logic but it didn't work in my configuration, however I'm very happy to have it work with the extra "dict" term. Appreciate for your patience. It's my introduction to API and JSON. great to have these explanations! Alex -- Resources: - http://web2py.com -

[web2py] Re: console.log on page reload?

2015-10-01 Thread Tom Campbell
Thank you, Derek, but I'm still flummoxed. I added this new script tag to web2py_ajax.html: console.log('loaded ' + Date.now()) But I'm getting this message even when I use LOAD(). So I'm trying to understand whether I am placing this code in the wrong location or what, because I think it

[web2py] how to get count (number of records) from grid.element('.web2py_counter')

2015-10-01 Thread Alex Glaros
how to retrieve the number records in grid.element('.web2py_counter')? I'm looking for something like if grid[0][0] > 1: response.flash = T('The same zip code may exist for one or more countries') Thanks, Alex Glaros -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] SQLFORM.grid + count

2015-10-01 Thread Bruno Oliveira
I'm trying to create a SQLFORM.grid in web2py that group 2 fields and count them up, but I couldn't figure it out how to do it. *Model* db.define_table('invocados', Field('modulo_servico', 'string', label='Módulo (Serviço)', default=IS_LENGTH(2)),

[web2py] Re: ST_X function on POSTGIS geography() fields

2015-10-01 Thread 'DenesL' via web2py-users
Has anyone tried using the functions?. They are defined in web2py 2.12.03 pydal/adapters/postgres.py as ST_X and ST_Y. On Wednesday, September 30, 2015 at 4:56:56 PM UTC-4, wish7...@gmail.com wrote: > > Done: https://github.com/web2py/pydal/issues/298 > > Cheers > Toby > > Am Dienstag, 29.

[web2py] Re: IS_IN_DB validation error

2015-10-01 Thread 'DenesL' via web2py-users
The second parameter of IS_IN_DB should be a set not a query: query: (geo_item.f_collection_id == geo_collection.id) set: db(geo_item.f_collection_id == geo_collection.id)

[web2py] Re: IOError(11, 'Resource temporarily unavailable')

2015-10-01 Thread Calvin
I have an error handler within web2py that provides the error trace. One hypothesis offered was that nginx is closing the socket as uwsgi is taking too long to serve data. I've increased the keepalive_timeout parameter from 60 to 600 but this does not help. Where else could the problem be?

[web2py] Lost Style when deploying

2015-10-01 Thread Michael Messmer
So I spun up the latest web2py source on a Fedora 22 build and when i goto the url I get this. Does anyone know why I can get to it but the formatting looks terrible? I googled to no avail. Installed: yum install httpd mod_ssl mod_wsgi wget python checkpolicy policycoreutils

[web2py] scheduled task not committing

2015-10-01 Thread Jeremy Martin
Okay, so I have a strange issue. I have a simple database update in a function in a file called "scheduler.py" in the "models" folder. When I call this function from my website running on Apache, works great, no problem. However, when a scheduled task runs it (i.e. something like

[web2py] Lost Fomatting on new build

2015-10-01 Thread Michael Messmer
S I don't know what Im doing wrong. Spun up a new Fedora 22 Workstation box. Ran my normal stuff to get it all running and now I am facing this jacked up formatting: Any Thouhgts? Like is missing the ability to talk to a CSS or something. I dunno. Help/pointers?

[web2py] IS_IN_DB validation error

2015-10-01 Thread John Smidt
Im currently creating a website for a geology museum. Each exhibit in the museum contains different collections (or categories) of minerals, and each collection has a handful of individual minerals that are being shown at this museum. The part that I am currently working on is to allow an

[web2py] update list:string type colum

2015-10-01 Thread arihant daga
Hello, I have my table like this, db.define_table('myTable', Field('listfield','list:string'), ) now i want to update my table and add items into listfield if i do db(db.myTable.id==1).validate_and_update(listfield=newList) it will update the list with newList

[web2py] Running threads in Scheduler process

2015-10-01 Thread Bilal Hasan
Before I tested this out (I'm running on production environment), I wanted to ask would it be okay to spawn threads in the scheduler function? Since I need to split some tasks using the Linux command line. What would be the best way to do this? Using the threading library? Or just run a bunch

[web2py] How to start a web2py application on another ser

2015-10-01 Thread Chris Andrew
Hi guys, I currently have two systems that have web2py installed on them. System 1 has app1 installed on web2py and System 2 has app2 installed. Is it possible for me to call functions of app2 which is on System 2 using app1 which is on System1? They are both connected to my home network. Thank

[web2py] How to remove quotes around a FORM field

2015-10-01 Thread lohan . spies
Hi, I have a form that takes input from the user via a normal input textbox as per below TR("Asset Custom Field",INPUT(_type="text",_name="metadata",value="{'type':'bugs','weight':'250'}",requires=IS_NOT_EMPTY())), Then i assign the metadata value to a new variable as per below

[web2py] Re: How to start a web2py application on another ser

2015-10-01 Thread 黄祥
had you already try redirect? e.g. def function_on_system1(): redirect(URL('function_on_system2') ) best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list

Re: [web2py] how to get count (number of records) from grid.element('.web2py_counter')

2015-10-01 Thread Vinicius Assef
You got almost there. Try this: ``` grid = SQLFORM.grid(my_table) num_recs = int(grid.element('.web2py_counter')[0].split()[0]) if num_recs > 1: response.flash = T('The same zip code may exist for one or more countries') return dict(grid=grid) ``` -- Vinicius Assef On 1 October 2015 at

Re: [web2py] How to start a web2py application on another ser

2015-10-01 Thread Vinicius Assef
Read about Services [0]. Maybe it's what you're looking for. [0] http://web2py.com/books/default/chapter/29/10/services?search=rpc#Remote-procedure-calls -- Vinicius Assef On 1 October 2015 at 02:00, Chris Andrew wrote: > Hi guys, > I currently have two systems that

Re: [web2py] How to remove quotes around a FORM field

2015-10-01 Thread Vinicius Assef
``` assetcustomfield[1:-1] ``` -- Vinicius Assef On 30 September 2015 at 06:36, wrote: > Hi, > > I have a form that takes input from the user via a normal input textbox as > per below > TR("Asset Custom >

Re: [web2py] how to get count (number of records) from grid.element('.web2py_counter')

2015-10-01 Thread Alex Glaros
Thanks Vinicius, it worked. if it couldn't find the value, it raised this error: list index out of range Is the below way acceptable way of preventing the error message? Or is there a shorter way? try: num_recs = int(grid.element('.web2py_counter')[0].split()[0]) except

[web2py] Re: Matplotlib

2015-10-01 Thread Laurent Lc
I found something : In a controller (the import is done in a model) : def mychart(): return dict(a=IMG(_src=URL('draw'+'.png'))) def draw(): x = [datetime.date(2014, 1, 29), datetime.date(2014, 4, 15), datetime.date(2014, 3, 29)] y = [2, 4, 1] fig, ax = plt.subplots()

[web2py] Re: Matplotlib

2015-10-01 Thread Laurent Lc
Sorry i found just put the function draw in a model and add write in the controller: def mychart(): response.headers['Content-Type']='image/png' return draw() Le jeudi 1 octobre 2015 10:36:27 UTC+2, Laurent Lc a écrit : > > I found something : > > In a controller (the import is done in

[web2py] Re: Migration of java/tomcat backend

2015-10-01 Thread Leonel Câmara
I definitely think web2py is much more productive than that stack. However, it's worth considering if the migration is worth it. In my company we still support one app that has a backend like that, I always wanted to migrate it because it's the only thing still using Java. Frankly, even though