[web2py] how to format JSON data?

2016-06-08 Thread Alex Glaros
I cannot make JSON data correctly. (The result of below has duplicate data 
with the word : '{"title": "Battlespace 
Networks", "key":18, "parentId":2, "folder": false, "lazy": true},', : '{"title": "Municipality", "key":26, "parentId":2, "folder": 
false, "lazy": true},', : '{"title": 
"Service cross reference", "key":15, "parentId":2, "folder": false, "lazy": 
true},', : '{"title": "IT System", 
"key":32, "parentId":2, "folder": false, "lazy": true},', : '{"title": "Federal US 
government", "key":3, "parentId":2, "folder": false, "lazy": true},', : '{"title": "Province", "key":25, "parentId":2, "folder": 
false, "lazy": true},', : '{"title": "County", "key":5, 
"parentId":2, "folder": false, "lazy": true},', : '{"title": "Executive Branch", "key":8, "parentId":2, 
"folder": false, "lazy": true},', : '{"title": 
"Council of Ministers", "key":20, "parentId":2, "folder": false, "lazy": 
true},'}

Is there a python "JSON.parse" function I can use to make it valid JSON 
(https://jsonformatter.curiousconcept.com/)?

I tried this 

for r in new_roots:
   result[r] = gluon.contrib.simplejson.loads('{"title": '  +  '"' + 
r.taxonomy_column_name 
+  '"' +   ', "key":' +   str(r.id) +  ', "parentId":' + '2' + ', "folder": 
false, "lazy": true}')

but data came out encoded as below:

{: {u'folder': False, u'parentId': 2, u'lazy': True, u'key': 
25, u'title': u'Province'},

Tried this: 
result[r] = json.dumps({"title" + ':'   +  str(r.taxonomy_column_name) + ', 
' + "key" + ':' + str(r.id) + ', ' + "parentId" + ':' + '2' + ', ' + 
"folder" + ':' + 'false' + ', ' + "lazy" + ':' + 'true'}) 

but data resulted in: 

* set(['title:Defense and National Security, 
key:16, parentId:2, folder:false, lazy:true']) is not JSON serializable*

Is it supposed to go into a dict like that?

thanks,

Alex Glaros

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: bug web2py ticket json

2016-06-08 Thread Alessio Varalta
Ok I make in these days

On Saturday, 4 June 2016 17:47:34 UTC+2, Massimo Di Pierro wrote:
>
> Can you please open a ticket and provide a minimal example of a controller 
> to reproduce?
>
>
> On Monday, 30 May 2016 04:15:41 UTC-5, Alessio Varalta wrote:
>>
>> Hi, I notice a big problem with the ticket report when you use json.
>>
>> I have a controller where i take from the body the json with simple json 
>> and after parsing the body.
>>
>> The problem is that if there is an error the ticket reporting an error of 
>> decoding json in any cases...For example in my case the error was the wrong 
>> name of table or in another case a null pointer exception but web2py 
>> reporting alway the error on json 
>>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: The built-in web2py wiki error

2016-06-08 Thread Mirek Zvolský
now merged in trunk



Dne úterý 7. června 2016 15:03:42 UTC+2 Mirek Zvolský napsal(a):
>
> It really looks like this is broken with some new commit.
>
> In 2.14.5 I have - gluon/tools.py 6476-6478
> gid = group.id if group else db.auth_group.insert(
> role='wiki_editor')
> auth.add_membership(gid)
>
> In trunk (and probably 2.14.6) - gluon/tools.py 6506-6510
> if group:
> gid = group.id
> else:
> db.auth_group.insert(role='wiki_editor')
> auth.add_membership(gid)
>
> I see nothing better on the 2nd solution. And there is sure an error 
> (ommiting assignment to gid).
> I will create a pull request.
> Thank you.
>
>
>
>
> Dne pátek 27. května 2016 0:40:32 UTC+2 greenpoise napsal(a):
>>
>>
>> I had never done this part of the book but when I tried, it gave me an 
>> error:
>>
>>
>>  local variable 'gid' referenced 
>> before assignmentVersion
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>> Python Python 2.7.11: /usr/bin/python2.7 (prefix: /usr)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>>
>> Traceback (most recent call last):
>>   File "/home/gs/Applications/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/gs/Applications/web2py/applications/wiki2py/controllers/default.py" 
>> , 
>> line 52, in 
>>   File "/home/gs/Applications/web2py/gluon/globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File 
>> "/home/gs/Applications/web2py/applications/wiki2py/controllers/default.py" 
>> , 
>> line 13, in index
>> return auth.wiki()
>>   File "/home/gs/Applications/web2py/gluon/tools.py", line 4687, in wiki
>> groups=groups)
>>   File "/home/gs/Applications/web2py/gluon/tools.py", line 6454, in __init__
>> auth.add_membership(gid)
>> UnboundLocalError: local variable 'gid' referenced before assignment
>>
>>
>>
>>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Anthony
On Wednesday, June 8, 2016 at 4:00:48 AM UTC-4, Alex Glaros wrote:
>
> I cannot make JSON data correctly. (The result of below has duplicate data 
> with the word 
> result = dict()
> for r in new_roots:
>result[r] = '{"title": '  +  '"' + r.taxonomy_column_name +  '"' +   ', 
> "key":' +   str(r.id) +  ', "parentId":' + '2' + ', "folder": false, 
> "lazy": true},'
>

It appears that r is a Row object, and yet you are using it as a key in the 
result dictionary -- so you are getting exactly that, a dictionary whose 
keys are Row objects. Perhaps you instead want to use the row id as a key: 
result[r.id] = ...

Anyway, this is not the way to construct JSON. Instead, just construct a 
Python data structure of dictionaries and lists and use json.dumps() to 
convert it to JSON.

Anthony

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: MySQL connection error after scheduled task completes

2016-06-08 Thread Andre
I was not able to get the scheduler to work with Postgres so I tried using 
SQLite and it seems to work!  

So moving forward I'll try using two databases: SQLite for the scheduler 
and MySQL for everything else.

As a side note, I'm not quite sure why Postgres did not work. I tried 
clearing out the tables and then have the scheduler recreate everything but 
I was still getting the same error. Poking around the forums, it seems a 
possible solution is updating the postgres drivers however my hands are a 
bit tied since I'm using PythonAnywhere.

-Andre




On Tuesday, June 7, 2016 at 4:17:59 PM UTC-4, Niphlod wrote:
>
> NP. perfectly kosher. For all matter and purposes, unless you need 
> "transactional consistency" a separate db makes perfect sense.
> Those messages though indicate that the scheduler isn't finding the 
> tables, or the tables have an incorrect structure.
>
> On Tuesday, June 7, 2016 at 7:08:41 PM UTC+2, Andre Kozaczka wrote:
>>
>> Ah bummer! Thank you for looking into this for me.
>>
>> Through PythonAnywhere, I've added a Postgres database. I'm not sure if I 
>> will migrate everything from MySQL to Postgres but I was thinking of just 
>> starting off with the scheduler. I created a second DAL for the Postgres 
>> and initialized the scheduler with it. All the tables are generated however 
>> I'm getting error messages on the console and the task sits in QUEUED 
>> status.
>>
>> I know I'm veering off from the original question, but is it kosher to 
>> have a second database just for the scheduler? 
>>
>> Here are the error messages:
>> 2016-06-07 14:54:57,026 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - Error retrieving status
>> 2016-06-07 14:54:57,335 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (0)
>> 2016-06-07 14:54:57,843 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (1)
>> 2016-06-07 14:54:58,353 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (2)
>> 2016-06-07 14:54:58,862 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (3)
>> 2016-06-07 14:54:59,370 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (4)
>> 2016-06-07 14:54:59,878 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (5)
>> 016-06-07 14:55:00,048 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - Error retrieving status
>> 2016-06-07 14:55:00,398 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (6)
>> 2016-06-07 14:55:00,908 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (7)
>> 2016-06-07 14:55:01,417 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (8)
>> 2016-06-07 14:55:01,972 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - TICKER: error assigning tasks (9)
>> 2016-06-07 14:55:03,066 - web2py.scheduler.giles-liveconsole2#12039 - 
>> ERROR - Error retrieving status
>>
>> On Tuesday, June 7, 2016 at 8:07:32 AM UTC-4, Niphlod wrote:
>>>
>>> uhm, then it'll be quite impossible to fix it given the timeout is 
>>> seemingly random.
>>>
>>> On Tuesday, June 7, 2016 at 1:19:07 PM UTC+2, Andre Kozaczka wrote:

 Yes, same lines.

 On Tuesday, June 7, 2016 at 5:54:37 AM UTC-4, Niphlod wrote:
>
> is the exception raised in the same lines ?
>
> On Tuesday, June 7, 2016 at 4:32:45 AM UTC+2, Andre Kozaczka wrote:
>>
>>  
>> Well. adding "sync_output=200" ended up working for tasks that 
>> were just over the 300 second mark (where previously I was failing). I 
>> changed the task length to 600 seconds and I'm back to failing. Ah... so 
>> close!!!
>>
>> I tried changing sync_output to 100 but still failed. Unless you have 
>> another trick up your sleeve, I may have to wave the white flag and 
>> ditch 
>> MySQL and maybe give Postgres a try?
>>
>> -Andre
>>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] SELECT without duplicates for a specific field

2016-06-08 Thread Gael Princivalle
Hello.

Is there a way to select some rows without duplicates for a specific field ?

MODEL:
db.define_table('products'):
Field('code', type='string'),
Field('category_code', type='integer'))

ROWS:
code / category_code
A1125 / 3
C2214 / 2
D235 / 3
Z886 / 1

I would like to make a select that give this result:
code / category_code
A1125 / 3
C2214 / 2
Z886 / 1
   
Someone have an idea ?

Thanks.


-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SELECT without duplicates for a specific field

2016-06-08 Thread Anthony
You could do a simple groupby 

 
if you don't care which record is retained.

Anthony

On Wednesday, June 8, 2016 at 10:10:33 AM UTC-4, Gael Princivalle wrote:
>
> Hello.
>
> Is there a way to select some rows without duplicates for a specific field 
> ?
>
> MODEL:
> db.define_table('products'):
> Field('code', type='string'),
> Field('category_code', type='integer'))
>
> ROWS:
> code / category_code
> A1125 / 3
> C2214 / 2
> D235 / 3
> Z886 / 1
>
> I would like to make a select that give this result:
> code / category_code
> A1125 / 3
> C2214 / 2
> Z886 / 1
>
> Someone have an idea ?
>
> Thanks.
>
>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Alex Glaros
so would code look like this?  want to know if I'm going in the right 
general direction...

json_list = []
for r in new_roots:
json_list.append('{"title": '  +  '"' + r.taxonomy_column_name +  
'"' +   ', "key":' ...etc...}')

Also, thanks for catching the id error


-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Alex Glaros
does this output look right?  am still getting javaScript error: Uncaught 
SyntaxError: Unexpected token &

["{\"title\": \"Defense and National Security\", \"key\":16, 
\"parentId\":2, \"folder\": false, \"lazy\": true},", "{\"title\": 
\"State\", \"key\":4, \"parentId\":2, \"folder\": false, \"lazy\": true},", 
"{\"title\": \"County\", \"key\":5, \"parentId\":2, \"folder\": false, 
\"lazy\": true},", "{\"title\": \"City\", \"key\":6, \"parentId\":2, 
\"folder\": false, \"lazy\": true},", "{\"title\": \"House of 
Representatives\", \"key\":11, \"parentId\":2, \"folder\": false, \"lazy\": 
true},", "{\"title\": \"Senate\", \"key\":10, \"parentId\":2, \"folder\": 
false, \"lazy\": true},", "{\"title\": \"Mission Sector cross reference\", 
\"key\":13, \"parentId\":2, \"folder\": false, \"lazy\": true},", 
"{\"title\": \"Business Function cross reference\", \"key\":14, 
\"parentId\":2, \"folder\": false, \"lazy\": true},"]

Seems that above is correctly escaping quotes " so that there shouldn't be 
any & translated into the javaScript source data...

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Anthony
Why not:

json_list.append(dict(title=r.taxonomy_column_name, key=...))
...
return json.dumps(json_list)

Anthony

On Wednesday, June 8, 2016 at 12:28:27 PM UTC-4, Alex Glaros wrote:
>
> so would code look like this?  want to know if I'm going in the right 
> general direction...
>
> json_list = []
> for r in new_roots:
> json_list.append('{"title": '  +  '"' + r.taxonomy_column_name +  
> '"' +   ', "key":' ...etc...}')
>
> Also, thanks for catching the id error
>
>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Alex Glaros
how to get the return json.dumps(json_list) output to the view?  The view 
is expecting other vars besides json_list.

tried a sub-function:

for r in new_roots:
json_list.append(dict(title=r.taxonomy_column_name, key=r.id, 
parentId=2))
def output_json(json_list):
return json.dumps(json_list)
json_list = output_json(json_list)

and also tried adding the return to the other vars at the end of whole 
function: 

return locals, json.dumps(json_list)



-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: MySQL connection error after scheduled task completes

2016-06-08 Thread Niphlod
sqlite is the worst choice for concurrency, which scheduler is quite all 
about. I'd investigate further on the path of pythonanywhere's postgresql 
not being viable, mostly because it seems that psycopg2 is a "battery 
included" library.

On Wednesday, June 8, 2016 at 3:55:30 PM UTC+2, Andre wrote:
>
> I was not able to get the scheduler to work with Postgres so I tried using 
> SQLite and it seems to work!  
>
> So moving forward I'll try using two databases: SQLite for the scheduler 
> and MySQL for everything else.
>
> As a side note, I'm not quite sure why Postgres did not work. I tried 
> clearing out the tables and then have the scheduler recreate everything but 
> I was still getting the same error. Poking around the forums, it seems a 
> possible solution is updating the postgres drivers however my hands are a 
> bit tied since I'm using PythonAnywhere.
>
> -Andre
>
>
>
>
> On Tuesday, June 7, 2016 at 4:17:59 PM UTC-4, Niphlod wrote:
>>
>> NP. perfectly kosher. For all matter and purposes, unless you need 
>> "transactional consistency" a separate db makes perfect sense.
>> Those messages though indicate that the scheduler isn't finding the 
>> tables, or the tables have an incorrect structure.
>>
>> On Tuesday, June 7, 2016 at 7:08:41 PM UTC+2, Andre Kozaczka wrote:
>>>
>>> Ah bummer! Thank you for looking into this for me.
>>>
>>> Through PythonAnywhere, I've added a Postgres database. I'm not sure if 
>>> I will migrate everything from MySQL to Postgres but I was thinking of just 
>>> starting off with the scheduler. I created a second DAL for the Postgres 
>>> and initialized the scheduler with it. All the tables are generated however 
>>> I'm getting error messages on the console and the task sits in QUEUED 
>>> status.
>>>
>>> I know I'm veering off from the original question, but is it kosher to 
>>> have a second database just for the scheduler? 
>>>
>>> Here are the error messages:
>>> 2016-06-07 14:54:57,026 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - Error retrieving status
>>> 2016-06-07 14:54:57,335 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (0)
>>> 2016-06-07 14:54:57,843 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (1)
>>> 2016-06-07 14:54:58,353 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (2)
>>> 2016-06-07 14:54:58,862 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (3)
>>> 2016-06-07 14:54:59,370 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (4)
>>> 2016-06-07 14:54:59,878 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (5)
>>> 016-06-07 14:55:00,048 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - Error retrieving status
>>> 2016-06-07 14:55:00,398 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (6)
>>> 2016-06-07 14:55:00,908 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (7)
>>> 2016-06-07 14:55:01,417 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (8)
>>> 2016-06-07 14:55:01,972 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - TICKER: error assigning tasks (9)
>>> 2016-06-07 14:55:03,066 - web2py.scheduler.giles-liveconsole2#12039 - 
>>> ERROR - Error retrieving status
>>>
>>> On Tuesday, June 7, 2016 at 8:07:32 AM UTC-4, Niphlod wrote:

 uhm, then it'll be quite impossible to fix it given the timeout is 
 seemingly random.

 On Tuesday, June 7, 2016 at 1:19:07 PM UTC+2, Andre Kozaczka wrote:
>
> Yes, same lines.
>
> On Tuesday, June 7, 2016 at 5:54:37 AM UTC-4, Niphlod wrote:
>>
>> is the exception raised in the same lines ?
>>
>> On Tuesday, June 7, 2016 at 4:32:45 AM UTC+2, Andre Kozaczka wrote:
>>>
>>>  
>>> Well. adding "sync_output=200" ended up working for tasks that 
>>> were just over the 300 second mark (where previously I was failing). I 
>>> changed the task length to 600 seconds and I'm back to failing. Ah... 
>>> so 
>>> close!!!
>>>
>>> I tried changing sync_output to 100 but still failed. Unless you 
>>> have another trick up your sleeve, I may have to wave the white flag 
>>> and 
>>> ditch MySQL and maybe give Postgres a try?
>>>
>>> -Andre
>>>
>>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Save Full Calendar event to Mysql

2016-06-08 Thread Jeff Riley
Hello all.  Has anyone figured out how to save a Jquery Full Calendar event 
to their Mysql database?  I know I should use the Ajax function, but I am 
not seeing how to get the information from the Full Calendar jquery event 
dialog.

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: MySQL connection error after scheduled task completes

2016-06-08 Thread Andre
Okay, fair enough.

Along with the errors I posted earlier (related to Postgres), I also 
noticed that when I try to access the scheduler_worker table I get the 
following error:

 Traceback (most recent call last):
  File "/home/wdis/web2py/applications/wdis/controllers/appadmin.py", line 252, 
in select
limitby=(start, stop))
  File "/home/wdis/web2py/gluon/packages/dal/pydal/objects.py", line 2020, in 
select
return adapter.select(self.query, fields, attributes)
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1296, in select
return self._select_aux(sql,fields,attributes)
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1277, in _select_aux
return processor(rows,fields,self._colnames,cacheable=cacheable)
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1767, in parse
for row in rows]
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1677, in _parse
value = self.parse_value(value, ft, blob_decode)
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1527, in parse_value
return self.parsemap[key](value,field_type)
  File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1633, in parse_json
raise RuntimeError('json data not a string')
RuntimeError: json data not a string


I'm not sure if the errors are related but perhaps it can offer a clue to 
what's going on. Any thoughts?

-Andre


On Wednesday, June 8, 2016 at 3:29:16 PM UTC-4, Niphlod wrote:
>
> sqlite is the worst choice for concurrency, which scheduler is quite all 
> about. I'd investigate further on the path of pythonanywhere's postgresql 
> not being viable, mostly because it seems that psycopg2 is a "battery 
> included" library.
>
> On Wednesday, June 8, 2016 at 3:55:30 PM UTC+2, Andre wrote:
>>
>> I was not able to get the scheduler to work with Postgres so I tried 
>> using SQLite and it seems to work!  
>>
>> So moving forward I'll try using two databases: SQLite for the scheduler 
>> and MySQL for everything else.
>>
>> As a side note, I'm not quite sure why Postgres did not work. I tried 
>> clearing out the tables and then have the scheduler recreate everything but 
>> I was still getting the same error. Poking around the forums, it seems a 
>> possible solution is updating the postgres drivers however my hands are a 
>> bit tied since I'm using PythonAnywhere.
>>
>> -Andre
>>
>>
>>
>>
>> On Tuesday, June 7, 2016 at 4:17:59 PM UTC-4, Niphlod wrote:
>>>
>>> NP. perfectly kosher. For all matter and purposes, unless you need 
>>> "transactional consistency" a separate db makes perfect sense.
>>> Those messages though indicate that the scheduler isn't finding the 
>>> tables, or the tables have an incorrect structure.
>>>
>>> On Tuesday, June 7, 2016 at 7:08:41 PM UTC+2, Andre Kozaczka wrote:

 Ah bummer! Thank you for looking into this for me.

 Through PythonAnywhere, I've added a Postgres database. I'm not sure if 
 I will migrate everything from MySQL to Postgres but I was thinking of 
 just 
 starting off with the scheduler. I created a second DAL for the Postgres 
 and initialized the scheduler with it. All the tables are generated 
 however 
 I'm getting error messages on the console and the task sits in QUEUED 
 status.

 I know I'm veering off from the original question, but is it kosher to 
 have a second database just for the scheduler? 

 Here are the error messages:
 2016-06-07 14:54:57,026 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - Error retrieving status
 2016-06-07 14:54:57,335 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (0)
 2016-06-07 14:54:57,843 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (1)
 2016-06-07 14:54:58,353 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (2)
 2016-06-07 14:54:58,862 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (3)
 2016-06-07 14:54:59,370 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (4)
 2016-06-07 14:54:59,878 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (5)
 016-06-07 14:55:00,048 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - Error retrieving status
 2016-06-07 14:55:00,398 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (6)
 2016-06-07 14:55:00,908 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (7)
 2016-06-07 14:55:01,417 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning tasks (8)
 2016-06-07 14:55:01,972 - web2py.scheduler.giles-liveconsole2#12039 - 
 ERROR - TICKER: error assigning task

[web2py] Re: MySQL connection error after scheduled task completes

2016-06-08 Thread Andre
More information just tried initializing the DAL with pg8000 and things 
appear to be working. This points to an issue with psycopg2 (or at least 
the version that PythonAnywhere has installed)


On Wednesday, June 8, 2016 at 3:50:42 PM UTC-4, Andre wrote:
>
> Okay, fair enough.
>
> Along with the errors I posted earlier (related to Postgres), I also 
> noticed that when I try to access the scheduler_worker table I get the 
> following error:
>
>  Traceback (most recent call last):
>   File "/home/wdis/web2py/applications/wdis/controllers/appadmin.py", line 
> 252, in select
> limitby=(start, stop))
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/objects.py", line 2020, in 
> select
> return adapter.select(self.query, fields, attributes)
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1296, in select
> return self._select_aux(sql,fields,attributes)
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1277, in _select_aux
> return processor(rows,fields,self._colnames,cacheable=cacheable)
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1767, in parse
> for row in rows]
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1677, in _parse
> value = self.parse_value(value, ft, blob_decode)
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1527, in parse_value
> return self.parsemap[key](value,field_type)
>   File "/home/wdis/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 1633, in parse_json
> raise RuntimeError('json data not a string')
> RuntimeError: json data not a string
>
>
> I'm not sure if the errors are related but perhaps it can offer a clue to 
> what's going on. Any thoughts?
>
> -Andre
>
>
> On Wednesday, June 8, 2016 at 3:29:16 PM UTC-4, Niphlod wrote:
>>
>> sqlite is the worst choice for concurrency, which scheduler is quite all 
>> about. I'd investigate further on the path of pythonanywhere's postgresql 
>> not being viable, mostly because it seems that psycopg2 is a "battery 
>> included" library.
>>
>> On Wednesday, June 8, 2016 at 3:55:30 PM UTC+2, Andre wrote:
>>>
>>> I was not able to get the scheduler to work with Postgres so I tried 
>>> using SQLite and it seems to work!  
>>>
>>> So moving forward I'll try using two databases: SQLite for the scheduler 
>>> and MySQL for everything else.
>>>
>>> As a side note, I'm not quite sure why Postgres did not work. I tried 
>>> clearing out the tables and then have the scheduler recreate everything but 
>>> I was still getting the same error. Poking around the forums, it seems a 
>>> possible solution is updating the postgres drivers however my hands are a 
>>> bit tied since I'm using PythonAnywhere.
>>>
>>> -Andre
>>>
>>>
>>>
>>>
>>> On Tuesday, June 7, 2016 at 4:17:59 PM UTC-4, Niphlod wrote:

 NP. perfectly kosher. For all matter and purposes, unless you need 
 "transactional consistency" a separate db makes perfect sense.
 Those messages though indicate that the scheduler isn't finding the 
 tables, or the tables have an incorrect structure.

 On Tuesday, June 7, 2016 at 7:08:41 PM UTC+2, Andre Kozaczka wrote:
>
> Ah bummer! Thank you for looking into this for me.
>
> Through PythonAnywhere, I've added a Postgres database. I'm not sure 
> if I will migrate everything from MySQL to Postgres but I was thinking of 
> just starting off with the scheduler. I created a second DAL for the 
> Postgres and initialized the scheduler with it. All the tables are 
> generated however I'm getting error messages on the console and the task 
> sits in QUEUED status.
>
> I know I'm veering off from the original question, but is it kosher to 
> have a second database just for the scheduler? 
>
> Here are the error messages:
> 2016-06-07 14:54:57,026 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - Error retrieving status
> 2016-06-07 14:54:57,335 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (0)
> 2016-06-07 14:54:57,843 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (1)
> 2016-06-07 14:54:58,353 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (2)
> 2016-06-07 14:54:58,862 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (3)
> 2016-06-07 14:54:59,370 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (4)
> 2016-06-07 14:54:59,878 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER: error assigning tasks (5)
> 016-06-07 14:55:00,048 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - Error retrieving status
> 2016-06-07 14:55:00,398 - web2py.scheduler.giles-liveconsole2#12039 - 
> ERROR - TICKER

[web2py] migrate uwsgi + nginx --> twisted

2016-06-08 Thread Mark Graves
Hey everyone,

I am migrating an app from uwsgi + nginx to twisted.

I've read the docs and can get it started on my local machine.

Now, I'm putting it on a separate box.

Does anyone have a service startup script that they would mind sharing?

Otherwise, any recommendations for further reading?

-Mark

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Alex Glaros
Anyone have any ideas?  

I cannot get the json formated data to get passed to view.

Also tried creating separate controller.  (Note isolated by itself, 
 json.dumps(json_list) works to format the data correctly.)

def output_json(json_list):
import json
return json.dumps(json_list)

call the function from the main controller below.

output_json(json_list) (and also tried: json_list = output_json(json_list))

but does not copy the json-formatted data back to main controller or view

any suggestions?


-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Dave S


On Wednesday, June 8, 2016 at 3:09:11 PM UTC-7, Alex Glaros wrote:
>
> Anyone have any ideas?  
>
> I cannot get the json formated data to get passed to view.
>
> Also tried creating separate controller.  (Note isolated by itself, 
>  json.dumps(json_list) works to format the data correctly.)
>
> def output_json(json_list):
> import json
> return json.dumps(json_list)
>
> call the function from the main controller below.
>
> output_json(json_list) (and also tried: json_list = output_json(json_list)
> )
>
> but does not copy the json-formatted data back to main controller or view
>
> any suggestions?
>
>
One of my controllers has a fragment that looks like

   else:
result = '{ ' + json.dumps(x.errors) + '}'
return result

(the if-clause does less interesting stuff)

/dps

  

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Alex Glaros
anyone see anything wrong with this latest output? still getting:  *Uncaught 
SyntaxError: Unexpected token &*

is the first quote a problem?

"[{\"parentId\": 2, \"key\": 16, \"title\": \"Defense and National 
Security\"}, {\"parentId\": 2, \"key\": 4, \"title\": \"State\"}, 
{\"parentId\": 2, \"key\": 5, \"title\": \"County\"}, {\"parentId\": 2, 
\"key\": 6, \"title\": \"City\"}, {\"parentId\": 2, \"key\": 11, \"title\": 
\"House of Representatives\"}, {\"parentId\": 2, \"key\": 10, \"title\": 
\"Senate\"}, {\"parentId\": 2, \"key\": 13, \"title\": \"Mission Sector 
cross reference\"}, {\"parentId\": 2, \"key\": 14, \"title\": \"Business 
Function cross reference\"}, {\"parentId\": 2, \"key\": 15, \"title\": 
\"Service cross reference\"}, {\"parentId\": 2, \"key\": 17, \"title\": 
\"National Defense\"}, {\"parentId\": 2, \"key\": 18, \"title\": 
\"Battlespace Networks\"}, {\"parentId\": 2, \"key\": 19, \"title\": 
\"Command and Control\"}, {\"parentId\": 2, \"key\": 21, \"title\": 
\"Province\"}, {\"parentId\": 2, \"key\": 22, \"title\": \"District\"}, 
{\"parentId\": 2, \"key\": 23, \"title\": \"Subdistricts of Afghanistan\"}, 
{\"parentId\": 2, \"key\": 26, \"title\": \"Municipality\"}, {\"parentId\": 
2, \"key\": 25, \"title\": \"Province\"}, {\"parentId\": 2, \"key\": 34, 
\"title\": \"Suggestion\"}, {\"parentId\": 2, \"key\": 35, \"title\": 
\"Crowd Source Item\"}, {\"parentId\": 2, \"key\": 1, \"title\": \"BRM\"}, 
{\"parentId\": 2, \"key\": 2, \"title\": \"DRM\"}, {\"parentId\": 2, 
\"key\": 3, \"title\": \"Federal US government\"}, {\"parentId\": 2, 
\"key\": 7, \"title\": \"Legislative Branch\"}, {\"parentId\": 2, \"key\": 
8, \"title\": \"Executive Branch\"}, {\"parentId\": 2, \"key\": 9, 
\"title\": \"Judicial Branch\"}, {\"parentId\": 2, \"key\": 12, \"title\": 
\"BRM cross reference\"}, {\"parentId\": 2, \"key\": 20, \"title\": 
\"Council of Ministers\"}, {\"parentId\": 2, \"key\": 24, \"title\": 
\"Central Government\"}, {\"parentId\": 2, \"key\": 27, \"title\": \"DRM 
cross reference\"}, {\"parentId\": 2, \"key\": 28, \"title\": \"Party\"}, 
{\"parentId\": 2, \"key\": 29, \"title\": \"Meeting Category\"}, 
{\"parentId\": 2, \"key\": 30, \"title\": \"Meeting\"}, {\"parentId\": 2, 
\"key\": 31, \"title\": \"Engagement Squared Idea\"}, {\"parentId\": 2, 
\"key\": 32, \"title\": \"IT System\"}, {\"parentId\": 2, \"key\": 33, 
\"title\": \"Inventory (think I need to remove this as is more a 
classification concept)\"}]"


-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Anthony
No need for the separate function (that function does nothing but simply 
return the same thing we already had).

Anyway, the resulting JSON is just a string -- pass it to the view the same 
way you pass anything to the view -- as one of the items in the dictionary 
that the controller returns.

Anthony

On Wednesday, June 8, 2016 at 3:10:35 PM UTC-4, Alex Glaros wrote:
>
> how to get the return json.dumps(json_list) output to the view?  The view 
> is expecting other vars besides json_list.
>
> tried a sub-function:
>
> for r in new_roots:
> json_list.append(dict(title=r.taxonomy_column_name, key=r.id, 
> parentId=2))
> def output_json(json_list):
> return json.dumps(json_list)
> json_list = output_json(json_list)
>
> and also tried adding the return to the other vars at the end of whole 
> function: 
>
> return locals, json.dumps(json_list)
>
>
>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to format JSON data?

2016-06-08 Thread Anthony
Make sure you're doing something like:

var roots = {{=XML(json_list)}}

where json_list is the output of json.dumps(). And don't put any quotes 
around the entire JSON string -- in Javascript, it is not a string but an 
object.

Anthony

On Wednesday, June 8, 2016 at 10:41:02 PM UTC-4, Alex Glaros wrote:
>
> anyone see anything wrong with this latest output? still getting:  *Uncaught 
> SyntaxError: Unexpected token &*
>
> is the first quote a problem?
>
> "[{\"parentId\": 2, \"key\": 16, \"title\": \"Defense and National 
> Security\"}, {\"parentId\": 2, \"key\": 4, \"title\": \"State\"}, 
> {\"parentId\": 2, \"key\": 5, \"title\": \"County\"}, {\"parentId\": 2, 
> \"key\": 6, \"title\": \"City\"}, {\"parentId\": 2, \"key\": 11, \"title\": 
> \"House of Representatives\"}, {\"parentId\": 2, \"key\": 10, \"title\": 
> \"Senate\"}, {\"parentId\": 2, \"key\": 13, \"title\": \"Mission Sector 
> cross reference\"}, {\"parentId\": 2, \"key\": 14, \"title\": \"Business 
> Function cross reference\"}, {\"parentId\": 2, \"key\": 15, \"title\": 
> \"Service cross reference\"}, {\"parentId\": 2, \"key\": 17, \"title\": 
> \"National Defense\"}, {\"parentId\": 2, \"key\": 18, \"title\": 
> \"Battlespace Networks\"}, {\"parentId\": 2, \"key\": 19, \"title\": 
> \"Command and Control\"}, {\"parentId\": 2, \"key\": 21, \"title\": 
> \"Province\"}, {\"parentId\": 2, \"key\": 22, \"title\": \"District\"}, 
> {\"parentId\": 2, \"key\": 23, \"title\": \"Subdistricts of Afghanistan\"}, 
> {\"parentId\": 2, \"key\": 26, \"title\": \"Municipality\"}, {\"parentId\": 
> 2, \"key\": 25, \"title\": \"Province\"}, {\"parentId\": 2, \"key\": 34, 
> \"title\": \"Suggestion\"}, {\"parentId\": 2, \"key\": 35, \"title\": 
> \"Crowd Source Item\"}, {\"parentId\": 2, \"key\": 1, \"title\": \"BRM\"}, 
> {\"parentId\": 2, \"key\": 2, \"title\": \"DRM\"}, {\"parentId\": 2, 
> \"key\": 3, \"title\": \"Federal US government\"}, {\"parentId\": 2, 
> \"key\": 7, \"title\": \"Legislative Branch\"}, {\"parentId\": 2, \"key\": 
> 8, \"title\": \"Executive Branch\"}, {\"parentId\": 2, \"key\": 9, 
> \"title\": \"Judicial Branch\"}, {\"parentId\": 2, \"key\": 12, \"title\": 
> \"BRM cross reference\"}, {\"parentId\": 2, \"key\": 20, \"title\": 
> \"Council of Ministers\"}, {\"parentId\": 2, \"key\": 24, \"title\": 
> \"Central Government\"}, {\"parentId\": 2, \"key\": 27, \"title\": \"DRM 
> cross reference\"}, {\"parentId\": 2, \"key\": 28, \"title\": \"Party\"}, 
> {\"parentId\": 2, \"key\": 29, \"title\": \"Meeting Category\"}, 
> {\"parentId\": 2, \"key\": 30, \"title\": \"Meeting\"}, {\"parentId\": 2, 
> \"key\": 31, \"title\": \"Engagement Squared Idea\"}, {\"parentId\": 2, 
> \"key\": 32, \"title\": \"IT System\"}, {\"parentId\": 2, \"key\": 33, 
> \"title\": \"Inventory (think I need to remove this as is more a 
> classification concept)\"}]"
>
>
>

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.