[web2py] Re: Correct way to put libraries in site-package folder?

2018-03-16 Thread Jaison Raj
Hi Anthony,

Yes i have empty __init__.py files in each folders.
I tried to use "import xml.etree.ElementTree as ET". (instead of 
cElementTree) it works.

Now i am having problem importing another library: Plotly

the trace back as follows;
Traceback

1.
2.
3.
4.
5.
6.
7.
8.

Traceback (most recent call last):
  File "D:\2. Projects\Web2Py\2_MULA_2_0\web2py\gluon\restricted.py", line 219, 
in restricted
exec(ccode, environment)
  File 
"c:/web2py/applications/MULA_2_0\compiled\controllers.cell_reselection.index.py",
 line 3, in 
  File "D:\2. Projects\Web2Py\2_MULA_2_0\web2py\gluon\custom_import.py", line 
104, in custom_importer
raise ImportError(e1, import_tb)  # there an import error in the module
ImportError: (ImportError(ImportError(ImportError('cannot import name 
exceptions',), ), ), )


I even copied everything from my C:\Python27\Lib\site-packages to. ... 
web2py\site-packages, still no luck.

Is web2py binary limited to import certain type of libraries only?


Please advise.


Regards,

Jaison


On Friday, 16 March 2018 23:00:56 UTC+8, Anthony wrote:
>
> Do you have empty __init__.py files inside those two subfolders?
>
> On Friday, March 16, 2018 at 6:34:02 AM UTC-4, Jaison Raj wrote:
>>
>> Hi, 
>> I am trying to create a binary application (after compiling and packaging 
>> from windows).
>> In my controller, i am importing a library :"import 
>> xml.etree.cElementTree as ET".
>> I placed the files cElementTree.py and cElementTree.pyc in etree folder 
>> as follows:
>> \web2py\site-packages\xml\etree.
>>
>> I am getting error: 
>>  No module named cElementTree.
>>
>> How can i solver this error?
>> Pls advice.
>>
>>
>> Regards,
>> Jaison
>>
>

-- 
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: Issue with defaultdict(list)

2018-03-16 Thread Drew Howell
After taking a break and working on another section, I finally found what 
was causing the issue. There was, indeed, an error elsewhere within that 
controller, which was causing me all the headache. I appreciate your guys' 
help! Thanks.

On Sunday, March 11, 2018 at 11:14:27 PM UTC-4, Drew Howell wrote:
>
> I seem to be having issues getting defaultdict to work within Web2Py. I am 
> using Web2Py version 2.16.1 (Python 2.7.11).
>
> Here is the code in my controller:
> from collections import defaultdict
> g = defaultdict(list)
> g['someKey'].append('someValue')
>
> Here is the error I'm getting:
>
> File "D:/web2py/applications/fpr/controllers/students.py" 
> , line 
> 14, in view
>  g['someKey'].append('someValue')
> AttributeError: 'dict' object has no attribute 'append'
>
> If I do the same thing in the Python Interpreter, I don't seem to get the 
> issue.
>
> >>> from collections import defaultdict
> >>> g = defaultdict(list)
> >>> g['k'].append('v')
> >>> print g['k']
> ['v']
>
> Am I implementing this wrong or is there some sort of issue with using 
> defaultdict(list) in Web2Py?
>
>

-- 
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] auth.settings.actions_disabled.append('register')

2018-03-16 Thread Andrea Fae'
In layout.html there is an error...


wrong
  

right
  {{=T('Lost Password')}}


Il giorno venerdì 16 marzo 2018 20:07:27 UTC+1, Andrea Fae' ha scritto:
>
> Do you mean that, like in the other versions, it shoud be enogh only to 
> write auth.settings.actions_disabled.append('register') and nothing more?
> I see "password smarrita" in the menu and clicking it I see the same error 
> 404 NOT FOUND and it points to "request_password" controller. Why if in the 
> user function is written
>  http:///[app]/default/user/retrieve_password ?
>
>
> Il giorno venerdì 16 marzo 2018 05:27:32 UTC+1, Massimo Di Pierro ha 
> scritto:
>>
>> That used to be done automatically when registration was disabled. It 
>> made the layout unnecessarily complex. Any action could be disabled and 
>> that;s a lot of if statements.
>>
>> On Saturday, 10 March 2018 21:34:49 UTC-6, alex wrote:
>>>
>>> What about removing this: 
>>>
>>> >> href="{{=URL('default','user/register')}}">{{=T('Sign up')}}
>>>
>>> from layout.html?
>>>
>>>
>>> On March 11, 2018 at 4:42:52, Andrea Fae' (and...@gmail.com) wrote:
>>>
>>> Sometimes problems arises. I need to eliminate "sign up" menu item from 
>>> LOGIN but nevertheless I inserted this line
>>>
>>> auth.settings.actions_disabled.append('register')
>>>
>>> or this
>>>
>>> auth.settings.actions_disabled = ['register']
>>>
>>> in the db.py I can see the item in the menu, and when I click I see "404 
>>> NOT FOUND" page.
>>>
>>> One time only this line could delete this menu item.
>>>
>>> Do I forgot anything?
>>> 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+un...@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] auth.settings.actions_disabled.append('register')

2018-03-16 Thread Andrea Fae'
Do you mean that, like in the other versions, it shoud be enogh only to 
write auth.settings.actions_disabled.append('register') and nothing more?
I see "password smarrita" in the menu and clicking it I see the same error 
404 NOT FOUND and it points to "request_password" controller. Why if in the 
user function is written
 http:///[app]/default/user/retrieve_password ?


Il giorno venerdì 16 marzo 2018 05:27:32 UTC+1, Massimo Di Pierro ha 
scritto:
>
> That used to be done automatically when registration was disabled. It made 
> the layout unnecessarily complex. Any action could be disabled and that;s a 
> lot of if statements.
>
> On Saturday, 10 March 2018 21:34:49 UTC-6, alex wrote:
>>
>> What about removing this: 
>>
>> > href="{{=URL('default','user/register')}}">{{=T('Sign up')}}
>>
>> from layout.html?
>>
>>
>> On March 11, 2018 at 4:42:52, Andrea Fae' (and...@gmail.com ) 
>> wrote:
>>
>> Sometimes problems arises. I need to eliminate "sign up" menu item from 
>> LOGIN but nevertheless I inserted this line
>>
>> auth.settings.actions_disabled.append('register')
>>
>> or this
>>
>> auth.settings.actions_disabled = ['register']
>>
>> in the db.py I can see the item in the menu, and when I click I see "404 
>> NOT FOUND" page.
>>
>> One time only this line could delete this menu item.
>>
>> Do I forgot anything?
>> 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+un...@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: LOAD an routes_onerror

2018-03-16 Thread Anthony
The redirect would go in the /error/default/index controller action. It 
sends a 200 response to the browser with a special header instructing 
web2py.js to do a client-side redirect (i.e., load a new URL in the address 
bar).

Anthony

On Friday, March 16, 2018 at 5:25:10 AM UTC-4, Annet wrote:
>
> Hi Anthony,
>
> Thanks for your reply.
>
>
> Have you tried redirect(..., client_side=True) in your error handler?
>>
>
>
> The error handler  error/default/index contains the following lines of 
> code:
>
>
> def index():
> session.forget(response)
>
> response.title = 'Leonexus - Error handler'
>
> return dict()
>
>
> I do not have a line redirect(..., client_side=True) in my code. Is it 
> possible to add 
> client_side = True to error_handler in routes.py
>
> error_handler = dict(application='error',
>  controller='default',
>  function='index',
>  client_side = True)
>
>
> Kind regards,
>
> Annet
>

-- 
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: Correct way to put libraries in site-package folder?

2018-03-16 Thread Anthony
Do you have empty __init__.py files inside those two subfolders?

On Friday, March 16, 2018 at 6:34:02 AM UTC-4, Jaison Raj wrote:
>
> Hi, 
> I am trying to create a binary application (after compiling and packaging 
> from windows).
> In my controller, i am importing a library :"import xml.etree.cElementTree 
> as ET".
> I placed the files cElementTree.py and cElementTree.pyc in etree folder as 
> follows:
> \web2py\site-packages\xml\etree.
>
> I am getting error: 
>  No module named cElementTree.
>
> How can i solver this error?
> Pls advice.
>
>
> Regards,
> Jaison
>

-- 
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 verify woocommerce webhook signature in web2py auth decorator

2018-03-16 Thread Anthony

>
> Before to definitely fly to other places where to find answers to my 
> problem I have one little question related with web2py...
> In woocommerce documentation they say this about request signature:
>
> "X-WC-Webhook-Signature - a base64 encoded HMAC-SHA256 hash of the 
> payload."[1]
>
> Till now I interpreted "payload" as the request body... so as the json 
> string I can read simply using `request.body.read()`.
> Could it even be interpreted as the whole send content including the the 
> request header?
>

I would be surprised if that were the case given that (1) order of HTTP 
headers is not supposed to be significant (but would need to be if being 
used to generate a hash) and (2) WSGI applications receive incoming 
requests in the form of an environment dictionary generated by the 
WSGI-compliant web server, not the original HTTP message.
 

> How could it be get or reconstructed from the request storage object?
>

I'm not sure if it includes the entire original HTTP message or just the 
request body, but you can try request.env['wsgi.input']. If that doesn't 
work, web2py (and probably any WSGI-compliant framework) would not have 
access to the original HTTP message (which is parsed by the web server 
before passing request data to the web framework/application).

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.


Re: [web2py] Re: Off Topic:Pony

2018-03-16 Thread António Ramos
The only thing that caught my attention was

Write your database queries using Python generators & lambdas



2018-03-16 11:32 GMT+00:00 Leonel Câmara :

> Pony does not support postgis. I could not use pony. pyDAL also supports
> quite a bit more databases.
>
> --
> 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: Off Topic:Pony

2018-03-16 Thread Leonel Câmara
Pony does not support postgis. I could not use pony. pyDAL also supports 
quite a bit more databases.  

-- 
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 verify woocommerce webhook signature in web2py auth decorator

2018-03-16 Thread Manuele Pesenti



On 15/03/2018 22:17, Manuele Pesenti wrote:

You might be better off getting help from folks who know
WooCommerce, as this issue does not appear to be web2py specific.


Yes for sure! Thanks a lot.

     M.
Before to definitely fly to other places where to find answers to my 
problem I have one little question related with web2py...

In woocommerce documentation they say this about request signature:

"X-WC-Webhook-Signature - a base64 encoded HMAC-SHA256 hash of the 
payload."[1]


Till now I interpreted "payload" as the request body... so as the json 
string I can read simply using `request.body.read()`.
Could it even be interpreted as the whole send content including the the 
request header?


How could it be get or reconstructed from the request storage object?

Thanks a lot
    Manuele

[1] 
https://github.com/woocommerce/woocommerce-rest-api-docs/blob/master/source/includes/wp-api-v1/_webhooks.md


--
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] Correct way to put libraries in site-package folder?

2018-03-16 Thread Jaison Raj
Hi, 
I am trying to create a binary application (after compiling and packaging 
from windows).
In my controller, i am importing a library :"import xml.etree.cElementTree 
as ET".
I placed the files cElementTree.py and cElementTree.pyc in etree folder as 
follows:
\web2py\site-packages\xml\etree.

I am getting error: 
 No module named cElementTree.

How can i solver this error?
Pls advice.


Regards,
Jaison

-- 
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 an routes_onerror

2018-03-16 Thread 'Annet' via web2py-users
Hi Anthony,

Thanks for your reply.


Have you tried redirect(..., client_side=True) in your error handler?
>


The error handler  error/default/index contains the following lines of code:


def index():
session.forget(response)

response.title = 'Leonexus - Error handler'

return dict()


I do not have a line redirect(..., client_side=True) in my code. Is it 
possible to add 
client_side = True to error_handler in routes.py

error_handler = dict(application='error',
 controller='default',
 function='index',
 client_side = True)


Kind regards,

Annet

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