[web2py] Job opening

2015-09-30 Thread weheh
I'm leading a large, multi-phase project with immediate need for additional 
software development human resource. We're searching for a top talent with 
the following full-stack expertise:
- python
- web2py
- javascript & jQuery
- ractive
- Bootstrap
- css
- postgreSQL or MongoDB

If you've got this background and want to learn more, send me a private 
email and I'll discuss the project with you in more detail. There is 
potential here both for steady income and major upside. Location is 
flexible.

Richard

-- 
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.


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

2015-09-30 Thread Alex Glaros
it pretty much works from PythonAnywhere, except it doesn't put data in the 
vars correctly .  Data looks like this with strange letter "u" in front:

{u'loc': u'38.5249,-121.9708', u'city': u'Winters', u'country': u'US', 
u'region': u'California', u'hostname': u'No Hostname', u'ip': 
u'108.70.229.156', u'org': u'AS7018 AT&T Services, Inc.', u'postal': 
u'95694'}

 name 'city' is not defined

how to get clean data in the vars?  It did not accept location_data.city or 
location_data[city] either

thanks,

Alex

-- 
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.


Re: [web2py] Caching - need your thoughts

2015-09-30 Thread Kiran Subbaraman

Richard,
Thanks a lot for the pointers. The cache test code provided the 
information I needed.

I had tried to look for answers only in the group and docs.
Note to self: Look at the groups, docs, source and test codebase, before 
posting a question



Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Wed, 30-09-2015 7:05 PM, Richard Vézina wrote:

https://github.com/web2py/web2py/blob/1e66fa3a93560aa5d32c27a6b1b7251e0dd8a428/gluon/cache.py

Here the test file about cache :
https://github.com/web2py/web2py/blob/1e66fa3a93560aa5d32c27a6b1b7251e0dd8a428/gluon/tests/test_cache.py

Richard

On Wed, Sep 30, 2015 at 9:33 AM, Richard Vézina 
mailto:ml.richard.vez...@gmail.com>> wrote:


About Cache, you may try to import gluon cache.py module and see
if it can solve you requirement.

Something like that :

fromcacheimportCacheInRam, CacheOnDisk, Cache

You may need to include it in python path...

Richard

On Wed, Sep 30, 2015 at 8:22 AM, Kiran Subbaraman
mailto:subbaraman.ki...@gmail.com>>
wrote:

Hello group,
I have a standard web2py application, but within its modules
directory, I have a bunch of code which run within the web2py
context (and its scheduler), and also as scripts independent
of web2py. It is just that this code resident within web2py's
modules.
I wanted to use the web2py caching capability within some of
these scripts, and soon realized that they are dependent on
the web2py context. A couple of questions:

  * So, I cannot use the cache module independent of web2py's
running context. Is this a fair assumption? If not, any
suggestions on how I can use this cache module will help.
  * Less important question: Ended up searching for python
based caches, and I came across Beaker
, and Dogpile
, among
others. Before I decide on what to do about my cache
requirement, I thought I'll reach out to the community to
see if there are any viewpoints on either of these projects?

Thank you,

Kiran

-- 
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.



--
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.


--
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: Easy way to increment a field?

2015-09-30 Thread Dave S


On Wednesday, September 30, 2015 at 6:23:45 PM UTC-7, Anthony wrote:
>
> Yes, that's the way to do it if the calculations must be done in Python. 
> You can only use the direct update method if the database itself can do the 
> calculations (via a SQL expression). For example, here is what you can do 
> in PostgreSQL: 
> http://www.postgresql.org/docs/9.4/static/functions-math.html.
>
> Anthony
>
>
Thanks.  And that's a pretty good list to have at your backend's 
beck-and-call.

/dps

 

> On Wednesday, September 30, 2015 at 8:36:48 PM UTC-4, Dave S wrote:
>>
>>
>>
>> On Tuesday, September 29, 2015 at 1:25:33 PM UTC-7, Anthony wrote:
>>>
>>> You can do it in one line - just let the database do the incrementing by 
>>> passing an expression in the .update() method:
>>>
>>> db(db.mytable).update(counter=db.mytable.counter + 1)
>>>
>>> Much more efficient because you don't have to load any records from the 
>>> db or do any processing in Python.
>>>
>>>
>>
>> For the fearsome case where some additional python logic was needed to 
>> compute the new value, would you use
>> newcount = complex_calc(row.count, obtuse_parameters)
>> row.update_record(count = newcount)
>>
>> or can lambda's be used in the db(...).update() call?
>>
>> /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] Wizard inside a LOAD

2015-09-30 Thread Jose
Hi

I am embedding wizard in a LOAD

{{=LOAD('default', 'f1', ajax=True, ajax_trap=True)}}



def f1():
form = FORM(...)

if form.process().accepted:
#I do something
redirect(URL('f2'))

return form




def f2():
form = FORM(...)

if form.process().accepted:
#I do something
redirect(URL('f3'))

return form




def f3():
form = FORM(...)

if form.process().accepted:
#I do something
redirect(URL('f_end'))

return form



After submit in f1, works well and redirects to f2, but when you submit in 
f2 does what I expect and redirects to f1 (should redirect to f3)

Any idea how to fix it

Best Regards,
José

-- 
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: Easy way to increment a field?

2015-09-30 Thread Anthony
Yes, that's the way to do it if the calculations must be done in Python. 
You can only use the direct update method if the database itself can do the 
calculations (via a SQL expression). For example, here is what you can do 
in PostgreSQL: 
http://www.postgresql.org/docs/9.4/static/functions-math.html.

Anthony

On Wednesday, September 30, 2015 at 8:36:48 PM UTC-4, Dave S wrote:
>
>
>
> On Tuesday, September 29, 2015 at 1:25:33 PM UTC-7, Anthony wrote:
>>
>> You can do it in one line - just let the database do the incrementing by 
>> passing an expression in the .update() method:
>>
>> db(db.mytable).update(counter=db.mytable.counter + 1)
>>
>> Much more efficient because you don't have to load any records from the 
>> db or do any processing in Python.
>>
>>
>
> For the fearsome case where some additional python logic was needed to 
> compute the new value, would you use
> newcount = complex_calc(row.count, obtuse_parameters)
> row.update_record(count = newcount)
>
> or can lambda's be used in the db(...).update() call?
>
> /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] Migration of java/tomcat backend

2015-09-30 Thread Joel McGraw
Hello group, long-time lurker here.

I just joined a startup that has a working version of software that was
created by an outsourced team. It's the backend for a mobile app and is a
fairly typical tomcat/hibernate/java application. Without getting into the
reasons, I'm considering migrating to web2py (other platforms are on the
list, but I'm most productive with Python and like what I've seen of
web2py).

My question:
I will probably have to migrate the API in pieces. Does anyone have
experience running a Tomcat/Java application and web2py side-by-side? Any
caveats?

-Joel

-- 
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: Easy way to increment a field?

2015-09-30 Thread Dave S


On Tuesday, September 29, 2015 at 1:25:33 PM UTC-7, Anthony wrote:
>
> You can do it in one line - just let the database do the incrementing by 
> passing an expression in the .update() method:
>
> db(db.mytable).update(counter=db.mytable.counter + 1)
>
> Much more efficient because you don't have to load any records from the db 
> or do any processing in Python.
>
>

For the fearsome case where some additional python logic was needed to 
compute the new value, would you use
newcount = complex_calc(row.count, obtuse_parameters)
row.update_record(count = newcount)

or can lambda's be used in the db(...).update() call?

/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.


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

2015-09-30 Thread Alex Glaros
I think you're right.   Will try from home tonight.  Thanks!

On Wed, Sep 30, 2015 at 4:31 PM, Leonel Câmara 
wrote:

> There must be something wrong on your side (maybe a firewall blocking
> python or another network issue) because this works fine on my tests.
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/NY68H62ii5s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 access external API

2015-09-30 Thread Leonel Câmara
There must be something wrong on your side (maybe a firewall blocking 
python or another network issue) because this works fine on my tests.

-- 
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.


Re: [web2py] Re: How to include session data in error tickets

2015-09-30 Thread Christopher L
Interesting - that's what I was worried about. Does anyone know how web2py
decides when to include useful info/when it's able to?

On Wed, Sep 30, 2015 at 4:25 PM, Dave S  wrote:

>
>
> On Wednesday, September 30, 2015 at 8:31:47 AM UTC-7, Chris wrote:
>>
>> Hi Stifan,
>>
>> Yes, that's exactly the part I used to see (locals, request, session,
>> response) that I'm not seeing anymore! Very odd.
>> Here's what the ticket looks like to me: http://imgur.com/kowN8eg
>>
>>
>>
> Having spent much of the last day or two generating tickets (not by
> choice, mind you), I can tell you "it varies".
>
> I had a bad unindent and that ticket did  generate buttons for locals,
> etc.   Ditto a missing close-quote on a string literal., ditto "object of
> type 'Row' has no len()".
>
> I also had attribute error tickets, with no buttons, and a "global name
> 'now' is not defined", also with no buttons, and again with "missing 'pass'
> in view".
>
> So it looks like it depends on the specific error and where it is detected.
>
> /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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/H4kShWCTDi4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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: Nested Role Based Access Control

2015-09-30 Thread PN
No graph database needed the way we implemented it. We use a regular db and 
generate the graph in-memory. 

The current simple implementation is to query auth_permissions where 
table_name = 'auth_group' so we only get entries that are relevant to 
group-group ownerships. The graph is kept in memory and updated 
periodically. This avoid recursive queries into the database as all entries 
are retrieved in one call. This structure is shared between *all* users, so 
not pulled at every login. We refresh the structure periodically (every 60 
seconds in our case). Disadvantage is what happens if there are so many 
group-group permissions that they don't fit in memory. Also, a periodic 
refresh is not as accurate as an event based refresh (only refresh when a 
group-group entry is created/modified/deleted in permissions)

I see your point about the alternate architecture - one that implements a 
layer on top of RBAC and creates the appropriate auth_permission entries 
for each group/sub-group. In this situation, if you create a building under 
a sub-group, you would create two entries in auth_permission, one for the 
sub-group and one for the top-level group. This is good when you want to 
just retrieve all buildings that a user has access to, not as useful when 
you want to create a hierarchical view for the user (for example, a 
drill-down list of sub-groups kinda like windows shows files and folders - 
you see a list of all files in the top level folder, and a list of 
subfolders that you can click to view files within that subfolder). Using a 
layer on top of the RBAC would mean we have to do recursive queries anyway 
to show the top-level view (i.e. show me all buildings that are owned by 
the top-level group AND not owned by any of the sub-groups). Not sure if 
I'm explaining it clearly. It seems like a generic use-case so I was hoping 
there was a standard design pattern we could follow. Maybe by having a 
different permission name when the group owns a building directly, vs when 
a group has access to a building through a sub-group?

I'm happy to work on the n+1 query problem on RBAC, is there a reference 
thread somewhere that I can use as a jumping off point?

On Wednesday, September 30, 2015 at 3:46:12 PM UTC-4, Niphlod wrote:
>
> This has been discussed before and trashed as soon as a graph database is 
> needed to store and retrieve efficiently data.
> Of course, recursive queries are a no-go.
> There's a reason why Active Directory through Kerberos sends out the 
> flattened list of group membership when trying to authenticate.
> And a reason why even with that trick it's fading away. We don't need to 
> copy behaviour from a well known architecture which has already proven its 
> limits. 
> Checking membership recursively at login-time is FAR FAR FAR worse than 
> just managing group membership on another layer, on top of RBAC which isn't 
> limiting from the "turing" perspective. 
>
> PS: web2py suffers of the n+1 query problem EVEN for not nested groups. I 
> assume it was done to support noSQL database. I realized it reviewing the 
> code in order to allow JWT authentication. IMHO the eventual "refactoring 
> hours" spent on RBAC should be spent there instead of nested groups 
> functionality 
>

-- 
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: ST_X function on POSTGIS geography() fields

2015-09-30 Thread wish7code
Done: https://github.com/web2py/pydal/issues/298

Cheers
Toby

Am Dienstag, 29. September 2015 23:17:37 UTC+2 schrieb wish...@gmail.com:
>
> +1 from my side too :-) Was a pydal ticket ever opened?
> Otherwise I would do now...
>
> Cheers 
> Toby
>
> Am Montag, 22. Juni 2015 08:51:59 UTC+2 schrieb Massimo Di Pierro:
>>
>> Please open a pydal ticket. I do not think we support this yet but we can 
>> add it.
>>
>> On Wednesday, 23 April 2014 05:44:39 UTC-5, libe...@gmail.com wrote:
>>>
>>> Hi everyone,
>>> I am trying to extract latitude and longitude from a POSTGIS geography() 
>>> field. Unfortunately the usual st_x() and st_y() functions normally used
>>> for geometry() fields won't work.
>>> How can I extract the required values or transform geography in geometry?
>>>
>>> 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 access external API

2015-09-30 Thread Alex Glaros
only made a couple of attempts, not one thousand.  And the call from 
browser still works so doesn't appear that number of attempts is causing it 
to actively refuse my IP.  Also tried another company and got same error:  
http://api.db-ip.com/addrinfo?addr=173.194.67.1&api_key=f268dd236413839e52713b38e*Disguised
 
the key* 

is there another way to get the info without json or fetch or maybe loads? 
 Am wondering if they are adding anything.  

any work-around ideas would be appreciated

thanks

Alex

-- 
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 access external API

2015-09-30 Thread Leonel Câmara
Well the errors says it all. You connection is being refused. It appears 
you bumped into the 1k calls API limit by making too many calls.

It has to be json.loads because fetch returns a string.

-- 
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.


Re: [web2py] Re: How to include session data in error tickets

2015-09-30 Thread Dave S


On Wednesday, September 30, 2015 at 8:31:47 AM UTC-7, Chris wrote:
>
> Hi Stifan,
>
> Yes, that's exactly the part I used to see (locals, request, session, 
> response) that I'm not seeing anymore! Very odd.
> Here's what the ticket looks like to me: http://imgur.com/kowN8eg
>
>
>
Having spent much of the last day or two generating tickets (not by choice, 
mind you), I can tell you "it varies".

I had a bad unindent and that ticket did  generate buttons for locals, 
etc.   Ditto a missing close-quote on a string literal., ditto "object of 
type 'Row' has no len()".

I also had attribute error tickets, with no buttons, and a "global name 
'now' is not defined", also with no buttons, and again with "missing 'pass' 
in view".

So it looks like it depends on the specific error and where it is detected.

/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 access external API

2015-09-30 Thread Alex Glaros
Leonel, this string works from a browser (http://ipinfo.io/8.8.8.8/json)  so 
your sample is very close to working, but am getting an error.  Also, is 
word supposed to be "load" or "loads" or doesn't matter?

 Versionweb2py™Version 
2.12.2-stable+timestamp.2015.08.09.14.29.44PythonPython 2.7.9: 
C:\alex\alt_web2py\web2py\web2py.exe (prefix: C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.

Traceback (most recent call last):
  File "C:\alex\alt_web2py\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "C:/alex/alt_web2py/web2py/applications/ES1/controllers/default.py" 
, line 
5824, in 
  File "C:\alex\alt_web2py\web2py\gluon\globals.py", line 412, in 
self._caller = lambda f: f()
  File "C:\alex\alt_web2py\web2py\gluon\tools.py", line 3769, in f
return action(*a, **b)
  File "C:/alex/alt_web2py/web2py/applications/ES1/controllers/default.py" 
, line 
5770, in locate_me
location_data = json.loads(fetch('http://ipinfo.io/%s/json' % 
request.client))
  File "C:\alex\alt_web2py\web2py\gluon\tools.py", line 4749, in fetch
html = urllib2.urlopen(req).read()
  File "urllib2.py", line 154, in urlopen
  File "urllib2.py", line 431, in open
  File "urllib2.py", line 449, in _open
  File "urllib2.py", line 409, in _call_chain
  File "urllib2.py", line 1227, in http_open
  File "urllib2.py", line 1197, in do_open
URLError: 

Error snapshot [image: help] 


()

-- 
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: Nested Role Based Access Control

2015-09-30 Thread Niphlod
This has been discussed before and trashed as soon as a graph database is 
needed to store and retrieve efficiently data.
Of course, recursive queries are a no-go.
There's a reason why Active Directory through Kerberos sends out the 
flattened list of group membership when trying to authenticate.
And a reason why even with that trick it's fading away. We don't need to 
copy behaviour from a well known architecture which has already proven its 
limits. 
Checking membership recursively at login-time is FAR FAR FAR worse than 
just managing group membership on another layer, on top of RBAC which isn't 
limiting from the "turing" perspective. 

PS: web2py suffers of the n+1 query problem EVEN for not nested groups. I 
assume it was done to support noSQL database. I realized it reviewing the 
code in order to allow JWT authentication. IMHO the eventual "refactoring 
hours" spent on RBAC should be spent there instead of nested groups 
functionality 

-- 
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: Any idea about how to interpolate into a dal query string?

2015-09-30 Thread Leonel Câmara
Use this instead

query = db[field_array[3]].id ==field_array[1]
db(query).select()

-- 
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 access external API

2015-09-30 Thread Leonel Câmara
I haven't tried it but, this should work and it's a simple enough example

# In the default controller

def locateme():
import json
from gluon.tools import fetch
location_data = json.loads(fetch('http://ipinfo.io/%s/json' % request.
client))
return location_data


# In the view default/locateme.html

{{extend 'layout.html'}}



  City
  {{=city}}
  Region
  {{=region}}
  Country
  {{=country}}


Then you'll probably need to add some checking for cases where the API 
doesn't return a city/region/country

-- 
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] Any idea about how to interpolate into a dal query string?

2015-09-30 Thread Mark Billion
This fails:
query = "db.%s.id==%s" %(field_array[3], field_array[1])
db(query).select()
Any idea about how to interpolate into a dal query string?

-- 
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] how to access external API

2015-09-30 Thread Alex Glaros
Am new to APIs.

How do I access this API and get data to w2p vars?

http://ipinfo.io/developers

Goal is read user's IP address to determine what country/city they are in.

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: Easy way to increment a field?

2015-09-30 Thread Dave S


On Tuesday, September 29, 2015 at 1:25:33 PM UTC-7, Anthony wrote:
>
> You can do it in one line - just let the database do the incrementing by 
> passing an expression in the .update() method:
>
> db(db.mytable).update(counter=db.mytable.counter + 1)
>
> Much more efficient because you don't have to load any records from the db 
> or do any processing in Python.
>
> Anthony
>

Exactly what I was looking for, with just a dim memory to guide me.

Thanks, Anthony, and Leonel too!

/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] Nested Role Based Access Control

2015-09-30 Thread PN
Currently web2py's RBAC functionality does not accommodate nested groups. 
Any interest in adding this to the standard web2py access control module?


*Example Use-Case*

Suppose we are creating an inventory management application that lets you 
view addresses for buildings within your portfolio of buildings. Now a 
customer wants to divide their buildings into sub-regions, give permission 
to some users over sub-regions, and some users over all the sub-regions.

1. A table named Buildings represents buildings and their addresses. 

2. An auth_group entry for the top-level customer ("Wayne Industries"), and 
another entry for each of the sub-regions ("Gotham City", "Gotham Suburbs")

3. Users are assigned groups using the auth_membership table. Users who 
should have access to all the buildings get put into the "Wayne Industries" 
group. Users who should only see a sub-region get put into one of the City 
or Suburbs groups.


*Problem*

Suppose we want to show a user a grid of buildings based on what group they 
belong to. Users in Gotham City should only see sites that are part of that 
sub-region, but users in Wayne Industries should see buildings that are 
part of all 3 groups.

In the current setup, we would have to create two auth_permission entry for 
each building. One for the Wayne Industries group, and another for either 
of the sub-groups so users in the top-level group and the sub-group can see 
that building. This is fine if the list of buildings or groups is not 
dynamic. But if we are allowing users to add sub-groups and buildings, then 
every time a building is created, we need to know that the building should 
also be added to the top-level group. Various ways exist but keeping things 
in sync become hard.


*The proposed alternative*

1. We assign buildings to sub-regions by creating an auth_permission entry 
for the sub-region and the building ({Group: "Gotham City", Table: 
"Buildings", Name: "EDIT", Record_ID: }, etc.)

2. We assign the Wayne Industries group ADMIN permssion over the Gotham 
City and Gotham Suburbs group

3. We build a access control tree that allows queries over the nested 
groups. We can do this using a library like NetworkX that makes building 
and searching a graph/tree structure easier. We also add a parameter to the 
auth.accessible_query that decides whether to return only records owned by 
groups this user is a member of, or also return records owned by any 
(sub)groups the users' current groups have admin permission over. We can 
add a cache time property that allows storing this tree in memory to reduce 
db hits.

Does this sound like good design/useful feature to add? Much of this has 
already been built for our current application but we were looking to do 
something more standardized, putting it into web2py would allow us to get 
feedback on the implementation and how generalized/fast/secure it is.

-- 
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.


Re: [web2py] Re: How to include session data in error tickets

2015-09-30 Thread Christopher L
Hi Stifan,

Yes, that's exactly the part I used to see (locals, request, session,
response) that I'm not seeing anymore! Very odd.
Here's what the ticket looks like to me: http://imgur.com/kowN8eg

Thanks! -C



On Tue, Sep 29, 2015 at 7:57 PM, 黄祥  wrote:

> not sure, i got about your question, if you click the link that show error
> traceback, scroll it, on the middle there is context that contain some
> button : locals, request, session, response
> just click the session button, then you can see what the current session
> active in the error page.
>
> 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 (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/H4kShWCTDi4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

StoryLab  is here! Write your own
gamebooks/Choose Your Own Adventures!

Adventure Cow
:
Facebook  |
Twitter 

-- 
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] Matplotlib

2015-09-30 Thread Laurent Lc
I 'd like to view in a view this part of code :

import datetime
import matplotlib.pyplot as plt

x = [datetime.date(2014, 1, 29), datetime.date(2014, 4, 15), 
datetime.date(2014, 3, 29)]
y = [2, 4, 1]

fig, ax = plt.subplots()
ax.plot_date(x, y, markerfacecolor='CornflowerBlue', 
markeredgecolor='white')
fig.autofmt_xdate()
ax.set_xlim([datetime.date(2014, 1, 26), datetime.date(2014, 5, 1)])
ax.set_ylim([0, 5])


How can i do : i saw examples with canvas it works but to see this kind of 
graphic , i can't
Could you give me a simple example with this piece or anothe one of code

Regards

-- 
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.


Re: [web2py] Caching - need your thoughts

2015-09-30 Thread Richard Vézina
About Cache, you may try to import gluon cache.py module and see if it can
solve you requirement.

Something like that :

from cache import CacheInRam, CacheOnDisk, Cache

You may need to include it in python path...

Richard

On Wed, Sep 30, 2015 at 8:22 AM, Kiran Subbaraman <
subbaraman.ki...@gmail.com> wrote:

> Hello group,
> I have a standard web2py application, but within its modules directory, I
> have a bunch of code which run within the web2py context (and its
> scheduler), and also as scripts independent of web2py. It is just that this
> code resident within web2py's modules.
> I wanted to use the web2py caching capability within some of these
> scripts, and soon realized that they are dependent on the web2py context. A
> couple of questions:
>
>- So, I cannot use the cache module independent of web2py's running
>context. Is this a fair assumption? If not, any suggestions on how I can
>use this cache module will help.
>- Less important question: Ended up searching for python based caches,
>and I came across Beaker ,
>and Dogpile ,
>among others. Before I decide on what to do about my cache requirement, I
>thought I'll reach out to the community to see if there are any viewpoints
>on either of these projects?
>
> Thank you,
>
> Kiran
>
> --
> 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.
>

-- 
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.


Re: [web2py] Caching - need your thoughts

2015-09-30 Thread Richard Vézina
https://github.com/web2py/web2py/blob/1e66fa3a93560aa5d32c27a6b1b7251e0dd8a428/gluon/cache.py

Here the test file about cache :
https://github.com/web2py/web2py/blob/1e66fa3a93560aa5d32c27a6b1b7251e0dd8a428/gluon/tests/test_cache.py

Richard

On Wed, Sep 30, 2015 at 9:33 AM, Richard Vézina  wrote:

> About Cache, you may try to import gluon cache.py module and see if it can
> solve you requirement.
>
> Something like that :
>
> from cache import CacheInRam, CacheOnDisk, Cache
>
> You may need to include it in python path...
>
> Richard
>
> On Wed, Sep 30, 2015 at 8:22 AM, Kiran Subbaraman <
> subbaraman.ki...@gmail.com> wrote:
>
>> Hello group,
>> I have a standard web2py application, but within its modules directory, I
>> have a bunch of code which run within the web2py context (and its
>> scheduler), and also as scripts independent of web2py. It is just that this
>> code resident within web2py's modules.
>> I wanted to use the web2py caching capability within some of these
>> scripts, and soon realized that they are dependent on the web2py context. A
>> couple of questions:
>>
>>- So, I cannot use the cache module independent of web2py's running
>>context. Is this a fair assumption? If not, any suggestions on how I can
>>use this cache module will help.
>>- Less important question: Ended up searching for python based
>>caches, and I came across Beaker
>>, and Dogpile
>>, among
>>others. Before I decide on what to do about my cache requirement, I 
>> thought
>>I'll reach out to the community to see if there are any viewpoints on
>>either of these projects?
>>
>> Thank you,
>>
>> Kiran
>>
>> --
>> 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.
>>
>
>

-- 
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] Caching - need your thoughts

2015-09-30 Thread Kiran Subbaraman
Hello group,
I have a standard web2py application, but within its modules directory, I 
have a bunch of code which run within the web2py context (and its 
scheduler), and also as scripts independent of web2py. It is just that this 
code resident within web2py's modules.
I wanted to use the web2py caching capability within some of these scripts, 
and soon realized that they are dependent on the web2py context. A couple 
of questions: 

   - So, I cannot use the cache module independent of web2py's running 
   context. Is this a fair assumption? If not, any suggestions on how I can 
   use this cache module will help. 
   - Less important question: Ended up searching for python based caches, 
   and I came across Beaker , and 
   Dogpile , 
   among others. Before I decide on what to do about my cache requirement, I 
   thought I'll reach out to the community to see if there are any viewpoints 
   on either of these projects? 

Thank you,

Kiran

-- 
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.


Re: [web2py] How to build the book...

2015-09-30 Thread Willoughby
It's a big, wide world out there.  Not everyone has stable electricity 
24/7, nor Google Fiber to their door.  :-)
But I appreciate your efforts in helping the community.

And as you said, Vinicius gave an elegant solution - Thanks Vinicius.
Hopefully that helps out the OP.



On Tuesday, September 29, 2015 at 2:12:13 PM UTC-4, Dave S wrote:
>
>
> On Tuesday, September 29, 2015 at 5:04:06 AM UTC-7, Willoughby wrote:
>>
>> I know it's hard to believe, but some of us don't have constant internet 
>> connection.
>> So telling us to just 'go online' isn't always a productive option.
>>
>>
> That is  kind of surprising when one is working with web app development, 
> but since web2py runs fine on localhost, I suppose you can work around it.  
> And Vinicius has outlined doing just that sort of thing to browse the book 
> "locally online".
>
> /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: LOAD and export to CSV

2015-09-30 Thread 'DenesL' via web2py-users
Thanks for the link Brian. Checking it out right now.


On Tuesday, September 29, 2015 at 9:19:33 PM UTC-4, Brian M wrote:
>
> Yeah, with a little looking, and also another recent post here, you can't 
> start a download with JavaScript so you'll have to do something else. 
> Either just redirect the user to a download page that'll generate the CSV 
> or else look into using something like this --> 
> http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
>  
> I haven't tried that but it looks interesting.
>
> On Monday, September 28, 2015 at 11:04:57 PM UTC-5, DenesL wrote:
>>
>>
>> Yes, the content is properly set but it is returned as the component 
>> content instead of a separate file, which is what should happen IMHO.
>> What I need is some way to "cancel" the LOAD so the file is returned 
>> instead and the component is not updated, because otherwise it would become 
>> empty.
>>
>> So far the best solution seems to be to create the file and set a link to 
>> download it as part of the LOAD return, a two step process for the export 
>> scenario.
>> I was just hoping someone had a better idea.
>>
>> Thanks,
>> Denes
>>
>>  
>>
>> On Monday, September 28, 2015 at 8:38:37 PM UTC-4, Brian M wrote:
>>>
>>> Have you tried setting the appropriate content type header before 
>>> returning? I've not done it inside a LOAD before but know that setting the 
>>> content type will normally get the browser to download & save a CSV file 
>>> rather than just display it.
>>>
>>> Brian
>>>
>>

-- 
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.