[web2py] third party login using JWT

2020-11-18 Thread Manuele Pesenti

Hi!

I would need to set up my web2py application to login through a service 
based on this library: https://github.com/auth0/java-jwt


Is there some login method in contrib that already perfectly fit to it 
or do I have to implement the interface following the existent examples?


Any idea?

Thanks a lot

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/dccd6547-643e-2236-b1f3-254aa58ebd5f%40gmail.com.


[web2py] custom headers to error pages

2020-09-15 Thread Manuele Pesenti
Hi!

What's the correct way to add custom headers to response with status
different to 200 (i.e. 500)?

Thanks a lot

    Manuele

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/42dbf427-0821-0c8e-59f3-3592eea0a4b3%40gmail.com.


Re: [web2py] Re: get the current hostname behind a mod_proxy installation

2020-09-10 Thread Manuele Pesenti
Actually I used request.env.HTTP_X_FORWARDED_SERVER I really don't know 
if your answer fits anyway.


Thanks!

    Manuele

On 09/09/20 16:44, Clemens wrote:

Does request.env.http_host gives us the information you want?


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/90610122-50f5-78e5-5ea0-6d40ee33c453%40gmail.com.


[web2py] get the current hostname behind a mod_proxy installation

2020-09-09 Thread Manuele Pesenti

Hi!!
Behind a mod_proxy apache virtual host how can I get within the server 
side code witch hostname has been currently called? Considering at the 
moment I have configured one hostname and more than one aliases I'd like 
not to write the hostname directly ion the code.


Thanks a lot!

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1bcf417e-51c4-2fa5-e8bc-d4b595c8ed69%40gmail.com.


[web2py] Fwd: client side caching

2020-05-14 Thread Manuele Pesenti

Excuse me for the crossposting,

maybe someone else in here can answer my question... I haven't found 
nothing ready to use out of the box in py4web for caching controller 
results client side so I thought to implement my self following the 
cache.action decorator code in web2py, but without success till now.


I'll be glad for any siggestion

Cheers

    Manuele



 Forwarded Message 
Subject:client side caching
Date:   Wed, 13 May 2020 09:45:58 +0200
From:   Manuele Pesenti 
To: py4web 



Hi!

I wrote this little function trying to re-implementing client side 
caching controller response behavior as the one is available in web2py 
(https://github.com/web2py/web2py/blob/master/gluon/cache.py#L660) using 
the cache.action decorator:


import datetime
from py4web import response as rsp

def asknomore(time_expire=60):
    cache_control = 'max-age=%(time_expire)s, s-maxage=%(time_expire)s' 
% dict(time_expire=time_expire)
    cache_control += ', public' # if not session_ and public_ else ', 
private'
    expires = (datetime.datetime.utcnow() + 
datetime.timedelta(seconds=time_expire)).strftime('%a, %d %b %Y %H:%M:%S 
GMT')

    headers = {
    'Pragma': None,
    'Expires': expires,
    'Cache-Control': cache_control
    }
    rsp.headers.update(headers)

and I'm using it inside a controller function just before returning result:

@action('mycachedaction')
def mycachedaction():
    asknomore(120)
    return dict(message='Hello')

The headers seams correctly set in the response but reloading the page I 
always get a status: 200 instead of 304


What I am missing?

Thanks a lot!

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f205ff51-e515-9405-e425-518f2f5913c0%40gmail.com.


[web2py] [OT] working with spatialite

2020-05-08 Thread Manuele Pesenti

Hi!

In order to work with spatialite I had to patch the Spatialite class in 
this way in my model file (actually in py4web but the pydal is a common 
project dependency):


from unittest import mock

...

# Before declaring first DAL instance

patcher = mock.patch('pydal.adapters.sqlite.Spatialite.SPATIALLIBS', 
{"Linux": "mod_spatialite"})

patcher.start()

...

# At the end of the file after all table definitions

patcher.stop()

The problem is that is changed the name of the geometric extension in 
sqlite3... Any other similar experience? Do you think it's a generic 
solution to submit as an issue to the pydal project? Or does it depends 
on my local package configuration?


Thanks a lot

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b77e0b74-7488-2e8e-c757-4f5c64aa2cdd%40gmail.com.


[web2py] verification required and approval conditioned

2020-04-03 Thread Manuele Pesenti
Hi *!

Would it be possible to setup an application in order that the
verification is always required for registration and the approval would
be required only if an extra auth_user field is leaved blank during
registration?

Thanks a lot

    Manuele

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c265cf94-27e6-7b5b-953d-1b1206aa0f03%40gmail.com.


[web2py] too many requests raise a BrokenPipeError

2020-02-28 Thread Manuele Pesenti

Hi!

I realized with the help of Mapnik a quite raw but interesting tile 
server on top of web2py with the aim of serve some tile layers from some 
Postgis ad-hoc views. The main problem is that when too many requests 
are performed typically by quick zoom on a map some requests remains 
without a response and some messages from the rocket server pop up with 
thease messages:


   2020-02-28 09:35:12,250 - Rocket.Errors.Thread-5 - ERROR - Traceback
   (most recent call last):

  File
   "/home/manuele/development/PLANET/web2py_r-2.18/gluon/rocket.py",
   line 1288, in run
    self.run_app(conn)

  File
   "/home/manuele/development/PLANET/web2py_r-2.18/gluon/rocket.py",
   line 1810, in run_app
    self.conn.sendall(b('0\r\n\r\n'))

   BrokenPipeError: [Errno 32] Broken pipe


   2020-02-28 09:54:02,050 - Rocket.Errors.Thread-6 - ERROR - Tried to
   send "500 Server Error" to client but received socket error


Would it be possible to prevent this problem? Could it be by-passed 
using apache (in proxy or wsgi mode) in a deploy environment?


Thank you in advance for any suggestion.

Cheers

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a18b58cc-d7e5-f014-77bc-bbf353378ea6%40gmail.com.


[web2py] web2py 2.18.3 Daemon problem with ubuntu 18.6 [was:] running two web2py instances on the same server under apache wsgi mod

2020-01-22 Thread Manuele Pesenti

Hi!

At the moment I solved applying a debian daemon script template[1] I 
found with a simplified run script such like the one here under (saved 
in some runscript.sh file):


   NAME=web2py
   PIDDIR=/var/run/$NAME
   PIDFILE=$PIDDIR/$NAME.pid
   /path/to/bin/python /path/to/web2py/web2py.py -a ""
   --pid_filename=$PIDFILE -i 127.0.0.1 -p 8000

So I have substituted as required in the documentation recurrences of 
following tokens:


 * || = |web2py|
 * || = Web framework
 * || = /path/to/runscript.sh
 * || = myuser

My suspect is that there is some incompatibility of the official daemon 
script [2] with my Ubuntu 18.6 LTS environment, I would like to help in 
debugging the script if possible but I won't be able to find any error 
log related to the daemon failure... Let me know how can I would be of 
any help.


[1] https://gist.github.com/naholyr/4275302

[2] https://github.com/web2py/web2py/blob/R-2.18.3/scripts/web2py.ubuntu.sh

Best regards

    Manuele


On 21/01/20 16:29, Manuele Pesenti wrote:


On 21/01/20 15:10, Manuele Pesenti wrote:

So I guess I have to try using the second web2py (R-2.18 under 
python3 virtualenv) instance through mod_proxy... right?


So I'm trying to run a web2py (R-2.18.3) instance for deploy purposes 
using apache mod_proxy.


First I want to install the necessary daemon... I'm following the 
documentation[1] but without success,
it seams the daemon is not running after starting it. How can I log 
errors? I cannot find them, this are the only information I have found:


# service web2py218 stop
# service web2py218 start
# service web2py218 status
● web2py218.service - LSB: web2py initscript
   Loaded: loaded (/etc/init.d/web2py218; generated)
   Active: active (exited) since Tue 2020-01-21 16:20:46 CET; 3s ago
 Docs: man:systemd-sysv-generator(8)
  Process: 31480 ExecStop=/etc/init.d/web2py218 stop (code=exited,
status=1/FAILURE)
  Process: 31514 ExecStart=/etc/init.d/web2py218 start
(code=exited, status=0/SUCCESS)

Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
Starting LSB: web2py initscript...
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]: 
* Starting Web Framework web2py218
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud
web2py218[31514]:    ...done.
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
Started LSB: web2py initscript.

When I try to access the web2py instance through ssh tunneling it says:

channel 3: open failed: connect failed: Connection refused

Looking in syslog I read:

# tail /var/log/syslog
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud web2py218[31480]: 
* Stopping Web Framework web2py218
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud web2py218[31480]:
start-stop-daemon: warning: failed to kill 31269: No such process
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud
web2py218[31480]:    ...done.
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
web2py218.service: Control process exited, code=exited status=1
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
web2py218.service: Failed with result 'exit-code'.
Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
Stopped LSB: web2py initscript.
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
Starting LSB: web2py initscript...
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]: 
* Starting Web Framework web2py218
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud
web2py218[31514]:    ...done.
Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
Started LSB: web2py initscript.

This is my script version: http://paste.debian.net/hidden/e3917c71/

Thank you for any help.

Best regards

    Manuele

[1] 
http://web2py.com/books/default/chapter/29/13/deployment-recipes#Start-as-Linux-daemon




--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/27a986ce-c9b1-9fa0-bb04-aadaccaad187%40gmail.com.


Re: [web2py] Re: running two web2py instances on the same server under apache wsgi mod

2020-01-21 Thread Manuele Pesenti

On 21/01/20 15:10, Manuele Pesenti wrote:

So I guess I have to try using the second web2py (R-2.18 under python3 
virtualenv) instance through mod_proxy... right?


So I'm trying to run a web2py (R-2.18.3) instance for deploy purposes 
using apache mod_proxy.


First I want to install the necessary daemon... I'm following the 
documentation[1] but without success,
it seams the daemon is not running after starting it. How can I log 
errors? I cannot find them, this are the only information I have found:


   # service web2py218 stop
   # service web2py218 start
   # service web2py218 status
   ● web2py218.service - LSB: web2py initscript
   Loaded: loaded (/etc/init.d/web2py218; generated)
   Active: active (exited) since Tue 2020-01-21 16:20:46 CET; 3s ago
 Docs: man:systemd-sysv-generator(8)
  Process: 31480 ExecStop=/etc/init.d/web2py218 stop (code=exited,
   status=1/FAILURE)
  Process: 31514 ExecStart=/etc/init.d/web2py218 start
   (code=exited, status=0/SUCCESS)

   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]: Starting
   LSB: web2py initscript...
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]:  *
   Starting Web Framework web2py218
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]:   
   ...done.
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]: Started
   LSB: web2py initscript.

When I try to access the web2py instance through ssh tunneling it says:

   channel 3: open failed: connect failed: Connection refused

Looking in syslog I read:

   # tail /var/log/syslog
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud web2py218[31480]:  *
   Stopping Web Framework web2py218
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud web2py218[31480]:
   start-stop-daemon: warning: failed to kill 31269: No such process
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud web2py218[31480]:   
   ...done.
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
   web2py218.service: Control process exited, code=exited status=1
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]:
   web2py218.service: Failed with result 'exit-code'.
   Jan 21 16:20:41 Ubuntu-1804-bionic-64-nextcloud systemd[1]: Stopped
   LSB: web2py initscript.
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]: Starting
   LSB: web2py initscript...
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]:  *
   Starting Web Framework web2py218
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud web2py218[31514]:   
   ...done.
   Jan 21 16:20:46 Ubuntu-1804-bionic-64-nextcloud systemd[1]: Started
   LSB: web2py initscript.

This is my script version: http://paste.debian.net/hidden/e3917c71/

Thank you for any help.

Best regards

    Manuele

[1] 
http://web2py.com/books/default/chapter/29/13/deployment-recipes#Start-as-Linux-daemon


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/21c4ff49-b8a3-f41f-0891-b60ba855af00%40gmail.com.


Re: [web2py] Re: running two web2py instances on the same server under apache wsgi mod

2020-01-21 Thread Manuele Pesenti



On 21/01/20 14:59, Manuele Pesenti wrote:

Thank you Tim,

I tried but restarting apache and accessing the instance the browser 
takes a long time to respond and I get this error in log:


ImportError: No module named site


Could it be related to this https://stackoverflow.com/a/41006418/1039510 ?


> When using a Python virtual environment with mod_wsgi, it is very 
important that it has been created using the same Python installation 
that mod_wsgi was originally compiled for. It is not possible to use a 
Python virtual environment to force mod_wsgi to use a different Python 
version, or even a different Python installation.

>
> You cannot for example force mod_wsgi to use a Python virtual 
environment created using Python 3.5 when mod_wsgi was originally 
compiled for Python 2.7. This is because the Python library for the 
Python installation it was originally compiled against is linked 
directly into the mod_wsgi module.

>
> So most likely what is happening is that mod_wsgi is compiled for 
Python 2.6. You cannot in this case force it to use a Python virtual 
environment created from Python 2.7. When you do this, you will get the 
error you see about site module being missing.


So I guess I have to try using the second web2py (R-2.18 under python3 
virtualenv) instance through mod_proxy... right?


Cheers

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e22744f7-e25b-3991-1040-dfb937802d2d%40gmail.com.


Re: [web2py] Re: running two web2py instances on the same server under apache wsgi mod

2020-01-21 Thread Manuele Pesenti

Thank you Tim,

I tried but restarting apache and accessing the instance the browser 
takes a long time to respond and I get this error in log:


ImportError: No module named site

This is how my apache configuration looks like if could be of any help 
to understand the problem:




  ServerAdmin d...@colouree.com
  ServerName lab.mycompany.com

  SSLEngine on

  WSGIDaemonProcess laboratory python-home=/path/to/pyenv36 user=myuser 
group=myuser processes=1 threads=1

  WSGIProcessGroup laboratory
  WSGIScriptAlias / /path/to/web2py/wsgihandler.py
  WSGIPassAuthorization On

  
    AllowOverride None
    Require all denied
    
  Require all granted
    
  

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) 
/path/to/web2py/applications/$1/static/$2


  
    Options -Indexes
    ExpiresActive On
    ExpiresDefault "access plus 1 hour"
    Require all granted
  

  CustomLog /var/log/apache2/ssl-lab-access.log common
  ErrorLog /var/log/apache2/lab-error.log
  ServerAlias laboratory.mycompany.com
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile /etc/letsencrypt/live/lab.mycompany.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/lab.mycompany.com/privkey.pem


On 21/01/20 12:58, Tim Nyborg wrote:

Yes, that should work.


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/12751f8d-1e74-da4f-5479-4d51ab9fde6f%40gmail.com.


[web2py] running two web2py instances on the same server under apache wsgi mod

2020-01-21 Thread Manuele Pesenti

Hi!

If I need to manage on the same server two different web2py instances 
(for example for having two distinct versions of web2py running) what 
are the differences I have to consider with what reported in 
documentation[1]?


At the moment I already have the first instance running through wsgi mod 
using this configuration




  ServerAdmin d...@colouree.com
  ServerName apps.mycompany.com

  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

  CustomLog /var/log/apache2/access-apps.log common
  ErrorLog /var/log/apache2/apps.error.log




  ServerAdmin d...@colouree.com
  ServerName apps.mycompany.com

  SSLEngine on

  WSGIDaemonProcess web2py python-home=/path/to/pyenv27 user=myuser 
group=mygroup processes=1 threads=1

  WSGIProcessGroup web2py
  WSGIScriptAlias / /path/to/web2py/wsgihandler.py
  WSGIPassAuthorization On

  
    AllowOverride None
    Require all denied
    
  Require all granted
    
  

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) 
/path/to/web2py/applications/$1/static/$2


  
    Options -Indexes
    ExpiresActive On
    ExpiresDefault "access plus 1 hour"
    Require all granted
  

  Include /etc/letsencrypt/options-ssl-apache.conf

  CustomLog /var/log/apache2/ssl-apps-access.log common
  ErrorLog /var/log/apache2/apps-error.log
  ServerAlias applications.colouree.com
  SSLCertificateFile /etc/letsencrypt/live/apps.mycompany.com/fullchain.pem
  SSLCertificateKeyFile 
/etc/letsencrypt/live/apps.mycompany.com/privkey.pem



can I simply duplicate it changing essentials informations such 
WSGIDaemonProcess definition (I'd like to specify even the path to a 
different virtualenv based on python 3 in the second case) and other stuff?


Thank you very much

Best regards

    Manuele

[1] http://web2py.com/books/default/chapter/29/13/deployment-recipes

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8c44c54f-4770-21a0-9104-52fe4bc69660%40gmail.com.


Re: [web2py] Re: web2py and reverse proxy. How to expose a single application behind a hostname

2020-01-21 Thread Manuele Pesenti

Yes! It seams the right way... thank you Dave

    M.

On 21/01/20 09:45, Dave S wrote:

Check out routes.py, as described at
http://www.web2py.com/books/default/chapter/29/04/the-core#URL-rewrite>


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e4d55f96-84ba-3298-fb8a-8aa1824be769%40gmail.com.


[web2py] web2py and reverse proxy. How to expose a single application behind a hostname

2020-01-20 Thread Manuele Pesenti

Hi!

For our deploy installation I followed successfully the procedures in 
documentation so now I have my server exposing the web2py root, now I 
tried to configure a second host name using an apache reverse proxy 
configuration to serve directly a specific application, is it possible?


Let's say my application is reachable under apps.mycompany.com/myapp and 
now I want to setup the virtualhost myapp.mycompany.com as a reverse 
proxy to direcly serve the app. I've used this apache proxy configuration:



  ServerName myapp.mycompany.com
  SSLProxyEngine On
  ProxyRequests Off
  SSLProxyCheckPeerName off
  
  Order Deny,Allow
  Allow from all
  

  ProxyPass "/" "https:///myapp/"
  ProxyPassReverse "/" "https:///myapp/"

  SSLCertificateFile 
/etc/letsencrypt/live/analytics.colouree.com/fullchain.pem
  SSLCertificateKeyFile 
/etc/letsencrypt/live/analytics.colouree.com/privkey.pem


  CustomLog /var/log/apache2/ssl-analytics-access.log common
  ErrorLog /var/log/apache2/analytics-error.log



The problem is that every link included in the page contains even the 
application name such as:


https://analytics.colouree.com/welcome/static/css/bootstrap.min.css and 
so on.


Is there a possible way to fix it with some framework configuration?

Thank you very much.

Best regards

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/42c0d7e3-bf6c-e80b-d87c-779c71f0f3b6%40gmail.com.


Re: [web2py] web3py -> py4web

2019-07-31 Thread Manuele Pesenti

I'm loving it!

Thanks again Massimo

    Manuele

On 24/07/19 07:40, Massimo Di Pierro wrote:

OK. I know. I am not good with names.
But there are lots of requirements to be fulfilled.
py4web.com was available and the pypi package was available.
Here is running on google cloud:
http://py4web.com/

Ducking...


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/9d067bf5-9ba8-ab8a-d226-8365f4eae917%40gmail.com.


[web2py] Re: DAL contains query with single quote (with PG backend)

2019-07-15 Thread Manuele Pesenti
Il 15/07/19 14:45, Manuele Pesenti ha scritto:
> "(housenumbers.city ILIKE '%sant\_olcese%' ESCAPE '\'))" with 

I beg your pardon because of the string was passed through GET method it
was encoded and checked so the single quote was substituted by a
underscore. I solved using POST method for witch the passed string are
not encoded or checked so the passed request variable value still
contains the single quote when passed to the controller function.

Thank you for your attention anyway

    Manuele

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/81dbdafa-5f17-9727-29f0-2d7d8d7e8362%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] DAL contains query with single quote (with PG backend)

2019-07-15 Thread Manuele Pesenti
Hi! I have some trouble looking for records in PostgreSQL DB filtering 
using "contains" DAL method with substring containing single quote...


I found the raw solution sobstituting the resulting query filter
"(housenumbers.city ILIKE '%sant\_olcese%' ESCAPE '\'))" with
"(housenumbers.city ILIKE E'%sant\'olcese%' ESCAPE '\'))"
but it exclude the use of any DAL method I guess...

I don't know why in the original query string the single quote is 
substituted with \_
anyway the use of \' is already incorrect as far as I can see using psql 
if I don't use the "E" at the beginning of the substring template.


Thank you in advance for any suggestion.

Cheers

    Manuele

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c160808d-1822-39f9-78f0-70d52e8563bb%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] just a thought

2018-12-17 Thread Manuele Pesenti

Hi everybody!

I'd like just to share a thought I had browsing around last week... I 
found this web site https://spark.laravel.com and I realize how great 
would be to have modular plugins to build hi level scaffolding 
applications... don't you agree? :)



    M.

--
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: creating report using xhtml2pdf

2018-12-05 Thread Manuele Pesenti

We have found a simple solution... this code do the trick:

{{
import xhtml2pdf.pisa as pisa
filename = '%s/%s.html' % (request.controller,request.function)
html = response.render(filename)
pdf = pisa.CreatePDF(html, dest = response.body)
}}


We hope to be of any help to other people with the same problem

Cheers

    Manuele

On 05/12/2018 12:13, Manuele Pesenti wrote:

Hi!

we are trying to build up printable report from a view. We'd like to 
use xhtml2pdf instead using the web2py embedded library fpdf.


How the view template file should look like?
Essentially we tried something like the following without success:

{{
from xhtml2pdf import pisa
from StringIO import StringIO

filename = '%s/%s.html' % (request.controller,request.function)
html=response.render(filename)

dest = StringIO()

# convert HTML to PDF
pisaStatus = pisa.CreatePDF(html, dest=dest)

="ERROR" if not pisaStatus else dest.getvalue()
}}


--
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] creating report using xhtml2pdf

2018-12-05 Thread Manuele Pesenti

Hi!

we are trying to build up printable report from a view. We'd like to use 
xhtml2pdf instead using the web2py embedded library fpdf.


How the view template file should look like?
Essentially we tried something like the following without success:

{{
from xhtml2pdf import pisa
from StringIO import StringIO

filename = '%s/%s.html' % (request.controller,request.function)
html=response.render(filename)

dest = StringIO()

# convert HTML to PDF
pisaStatus = pisa.CreatePDF(html, dest=dest)

="ERROR" if not pisaStatus else dest.getvalue()
}}

--
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: env

2018-11-19 Thread Manuele Pesenti

Hi Anthony,

thanks for your replay.


On 17/11/2018 16:01, Anthony wrote:
What do you mean by "returns None"? I do not think the function env() 
can return None, so where are you seeing None?


I see the string None in the browser when I try to access the 
controller. I guess the code exits in this[*] line, because for some 
reason a RestrictedError is raised


[*] 
https://github.com/web2py/web2py/blob/d7624b95f8beef0ac9e07fcf443a5a0d99f0d953/gluon/shell.py#L176


But the same code run by command line works perfectly and load the other 
environment in the variable.


Presumably there is some code you are not showing, as the code below 
creates an environment but then simply returns an empty dictionary.


No other code... I tested the call exits before I can use the new 
environment in my other_env variable




Note, if you want to run models, you need to specify env(..., 
import_models=True).




That's what I've done ;)

Thanks again
Cheers
    Manuele

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

2018-11-16 Thread Manuele Pesenti

Hi!

Is there any good reason why thees few code lines that perfectly run on 
a python interpreter returns None if called in a controller?



from gluon.shell import env

def index():

    other_env = env("my_other_application", True)

    return dict()


I would like to access a complete model of another application, is it a 
deprecable behaviour?



Thanks a lot


    Manuele

--
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] Mixed login (openid and default auth)

2018-10-29 Thread Manuele Pesenti

Hi!

Is there a way to let a web2py application support both openid and 
standard authentication in parallel?


Applying what mentioned in the documentation[*] the standard login form 
is substituted with the openid form and there's no way to login the 
application using username and password. An I right? Or Did I 
misunderstand the doc?


Thank you very mutch in advance

Cheers

    Manuele


[*] http://web2py.com/books/default/chapter/29/09/access-control#OpenID

--
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: update_or_insert doesn't always return the corresponding row id

2018-08-08 Thread Manuele Pesenti

or just let you be inspired from the update_or_insert method itself:

https://github.com/web2py/pydal/blob/70929a6dc03e6296c34944d2d232f257b78337d7/pydal/objects.py#L822

something like the following lines maybe will fit your needs:

def update_or_insert(self, _key=DEFAULT, **values):
    if _key is DEFAULT:
    record = self(**values)
    elif isinstance(_key, dict):
    record = self(**_key)
    else:
    record = self(_key)
    if record:
    record.update_record(**values)
    newid = record.id # <- Here is the only code modification 
you need

    else:
    newid = self.insert(**values)
return newid


for example you can define it and call it passing the table to update or 
insert into as _first argument_



On 01/08/2018 17:20, Anthony wrote:

On Wednesday, August 1, 2018 at 6:46:09 AM UTC-4, Matthew J Watts wrote:

Hi all

I'm having the same problem, i'm trying to return an ID after an
'update_or_insert', but I need the ID whether it inserts or
updates to add as a forign key to a related table.


Yes, the workaround is simple -- don't use .update_or_insert(). It is 
a simple function and you can easily replicate the logic on your own. 
See https://stackoverflow.com/a/51634265/440323.


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.


--
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] Postpone a scheduler action

2018-07-11 Thread Manuele Pesenti




On 09/07/2018 09:56, Martin Weissenboeck wrote:

What I want to do:

I have a running scheduler action and I want to interrupt this action 
and postpone it for a later time. What would be the best solution?

consider to:

1. Setup the task in order to be re-tried till it will end up with success
2. Check if it's the case to postpone the task
3. if yes raise an exception an let fail the task

eventually if the task is retried too early raise another exception in 
order to wait the two minutes.


Could it fit your needs?

Cheers

    Manuele



Why? The scheduler starts to send a message by Telegram, but at this 
moment there is a dialog between the Telegram bot and the client (who 
is the receiver of message). Therefore the scheduler should not send 
the message and should try it e.g. 2 minutes later. And may repeat 
this process if necessary.


Thanks in advance, Martin


--
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: scheduler trouble

2018-07-06 Thread Manuele Pesenti

Hi Dave,

thanks for your reply, I'm actually debugging but I found that the 
problem was a callback I added after scheduler_run update event in order 
to be advised by email for failed tasks.


Is there a more correct way of doing it? Maybe should be a good feature 
for schduler.


Cheers

    Manuele


On 06/07/2018 00:30, Dave S wrote:

Never happens to me, so I can only guess:\

- you're waiting for a locked file ... IIRC, you're not using sqlite, 
though, right?

I'm using PostgreSQL
- you have a process that blocks waiting for results (like a response 
from a remote system) and there are no results


I think I can exclude things like seg faults, because those terminate 
and would be logged as errors.


--
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] scheduler trouble

2018-07-05 Thread Manuele Pesenti

Hi!

I'm in a trouble with the web2py (2.14.6 on python 2.7) scheduler that 
seams stop to run correctly... the tasks get the RUNNING status but 
nothing is performed and the task stay in the running status forever. I 
cannot understand how can it be possible.


Any idea?

Thanks a lot

    Manuele

--
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] web2py Requires gitpython module

2018-05-13 Thread Manuele Pesenti
Il 13/05/18 16:31, Andrea Fae' ha scritto:
> When I try to "push git " i See the error "requires gitpython module"
Have you tried
https://gitpython.readthedocs.io/en/stable/intro.html#installing-gitpython ?
> -- 
> 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] on delete event callbacks and versioned tables

2018-03-30 Thread Manuele Pesenti
Il 29/03/18 21:13, Richard Vézina ha scritto:
> They are intent to be used to specify something before or after the
> delete... I mean even if there is no "pure" deletion occuring your
> record doesn't exist anymore for the end user once you "deleted" it
> even if versioning mechanism keep trace of it for the purpose of the
> audit trail integrity...
>
> Do you have any issue related to how those callbacks operate in
> context of the version table web2py functionality?
I just wanted to figure out the behaviour in that case.
Thank you very mutch!

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


[web2py] on delete event callbacks and versioned tables

2018-03-29 Thread Manuele Pesenti


Are actually _before_delete and _after_delete callbacks called on record 
delete event even if on versioned tables?


I mean on versioned tables records are just updated from is_active True 
to False and not really deleted... right? So what is in thees cases the 
called list of callback function?


Thak you very mutch

Cheers

    Manuele

--
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-25 Thread Manuele Pesenti
Il 25/03/18 00:51, Patrick Rodrigues ha scritto:
> I was developing the same feature for my website today, and this help
> me a lot.
> In my case I was using Dango Rest Framework, and I was using
> request.data and parsing it to JSON, insted of using request.body.
> But now it works, thank you about this conversation.

Hi Patrick!

Happy to had been useful in some way :)

    M.

-- 
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-17 Thread Manuele Pesenti
Il 16/03/18 15:59, Anthony ha scritto:
> 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

Thanks Anthony for your attention,

now I've solved... there was no problem in the procedure but in the
tested data I copied from web services (such as requestb.in or directly
from the woocommerce event log web page) that I didn't notice they were
converting string such as "" into the character €. That's why I
didn't get the correct encoded string.
Directly using what I get from request.body.read() everything worked fine.

Best regards

    Manuele


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


Re: [web2py] Re: How to verify woocommerce webhook signature in web2py auth decorator

2018-03-15 Thread Manuele Pesenti
Il 15/03/18 20:21, Anthony ha scritto:
> Hard to say what's wrong. Where did you get that signature and request
> body? 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.

-- 
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-15 Thread Manuele Pesenti

On 01/03/2018 00:50, Anthony wrote:

I think you're on the right track. If you need the original request 
body to verify the signature, request.body.read() should do it. Does 
that not work?

Hi Anthony,
actually no :( it doesn't work, here[1] I tried to extrapolate the very 
essential code in order to test a use case.
To obtain the data I used such a web service like "requestb.in" as a 
webhook url and saved the woocommerce product.


running the test the result is:

$ python -m test
E
==
ERROR: test_authenticate (__main__.TestWoo)
--
Traceback (most recent call last):
  File "[...]/woohook/test.py", line 16, in test_authenticate
    res = WooHook.check(body, signature, secret)
  File "woohook.py", line 23, in check
    raise AuthenticationError(result)
AuthenticationError: WNeVWlUGBX6pSusRngDavUWlck6eAhVpTRoTYBbJdYM=

--
Ran 1 test in 0.000s

FAILED (errors=1)

Any idea or suggestion will be appreciated!

Cheers
    Manuele

[1] https://gist.github.com/manuelep/b6f6c00b4dec5234ab97229199bb223d

--
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] google analytics integration

2018-03-15 Thread Manuele Pesenti

Hi!

What's the difference between thees two (different?) approaches:

* https://support.google.com/analytics/answer/1008080?hl=en

* 
http://web2py.com/books/default/chapter/29/05/the-views?search=analytics#Default-page-layout


the script integrated in the web2py framework it's not so easy to 
analyze because it's minimized and at the moment we use a framework 
version equal to 2.14.6 for the deployment, any suggest about it?


Thanks a lot

    Manuele


--
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: prevent multiple session at the same time

2018-03-15 Thread Manuele Pesenti



On 12/03/2018 15:08, Anthony wrote:


What if I cache on disk the result of a function that returns the
session id and I check if it corresponds to the real value?


Not sure what you mean. Where does the session ID produced by the 
function come from, and how is the "real value" defined? What are you 
suggesting different from Massimo's approach.


Anthony


Hi Anthony,
thanks for your replay, I read the message from Massimo now and I 
realize that I misunderstood something... Massimo said to create a uuid 
and store it in database. I thought that `session.id` could be used 
instead and it could be considered as a "real value" or better as the 
real current session identifier. That's the check I was thinking about:


if session.id != cache.disk('session_id_%s' % user.id, lambda: 
session.id, time_expire=3600):

    auth.logout()

On the other hand I'm not sure that not to perform a database select 
query on every request but use the filesystem it's a better choice. Is it?


Cheers
    Manuele

--
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: prevent multiple session at the same time

2018-03-12 Thread Manuele Pesenti
Il 07/03/18 15:51, Anthony ha scritto:
> Be aware, that will require a database select on every request. If you
> want to minimize the database hits, you could also store in the
> session the time of the last database lookup, and then only check the
> database every X minutes (the tradeoff being that it could take up to
> X minutes to disable the first session after the second session has
> begun -- if you must ensure zero overlap of sessions, then you'll have
> to do the database check on every request).

What if I cache on disk the result of a function that returns the
session id and I check if it corresponds to the real value? In this case
how can I force to logout all other user logged in with the same
username? I would prefer to give precedence to the last one who login.

Cheers

    Manuele

-- 
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: prevent multiple session at the same time

2018-03-07 Thread Manuele Pesenti

Thanks a lot Massimo! As precious as ever.
:)

    M.


On 07/03/2018 07:02, Massimo Di Pierro wrote:

it is possible.

when a user first logs in, store a uuid in the session and write it in 
the database (in a new custom field in the auth_user table). When a 
request arrives if the uuid in the session does not match the uuid in 
the database call auth.logout()


--
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] prevent multiple session at the same time

2018-03-06 Thread Manuele Pesenti
Hi!

Is there a way not to let users to be connected to the application with
diffrerent session at the same time?

We are thinking of way how to prevent and limit the account sharing so
even suggestion on how to take care of devices used for connections
would be appreciated.

Best regards

    Manuele

-- 
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-01 Thread Manuele Pesenti



On 01/03/2018 03:25, Dave S wrote:


Don't you want a dummy parameter on verify_signature(), to prevent it 
being a URL-visible function? 
well actually it can even stay inside the models not a controller... in 
that case if it's not decorate as a service it cannot be visible. right?


       M.

--
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-02-28 Thread Manuele Pesenti
Il 28/02/18 17:10, Anthony ha scritto:
> You could parse the request body yourself, but web2py will do it
> automatically and put the variables in request.post_vars (if JSON is
> posted, its keys will become the keys of request.post_vars).
>
> I'm not sure what you mean by "check the request.post_vars". If there
> are variables you are expecting in the posted body, they will be in
> request.post_vars. Looking at the example log here
> , it looks like you
> might expect request.post_vars.action and request.post_vars.arg. The
> "action" value will also be in one of the request headers. Not sure if
> you need or care about "arg".

A little step backward... I want to verify the call origin and authenticity.

Each time a call is performed by a webhook it is signed with a signature
in the header obtained by encoding the body and I want to verify this
signature in order to be sure from where the call comes from. I've found
something similar for other languages and environments but not for
python and web2py, for example this one
https://stackoverflow.com/q/42182387/1039510. The concept is quite easy
but there are some details I miss.

Hereunder I tryied to rewrite the example code[*] in a more clear way (I
hope).

Does anybody tryied it before or somebody with some woocommerce webhook
experiencecan point me to what's wrong in it?


def compute(body):
    secret = ''
    dig = hmac.new(secret.encode(),
    msg = body.encode(),
    digestmod = hashlib.sha256
    ).digest()
    computed = base64.b64encode(dig).decode()
    return computed   

def hookCheck(func):
    def wrapper(*args, **kw):
    signature = request.env.http_x_wc_webhook_signature
    body = request.body.read() # ??
    computed = compute(body)
    if signature==computed:
    return func(*args, **kw)
    raise HTTP(403)
    return wrapper

@service.json
def listenToHooks():
    @hookCheck
    def _main_():
    # do stuff
    return {}
    return _main_()


Best regards

    Manuele


[*] https://gist.github.com/manuelep/4b64492ceeaa07f095302f94956ea554

-- 
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-02-28 Thread Manuele Pesenti

Thank Antony,


On 28/02/2018 15:50, Anthony wrote:
The webhook request headers will be in 
request.env.http_x_wc_webhook_[specific header] (e.g., 
request.env.http_x_wc_webhook_signature).


ok got it!



It looks like WooCommerce makes a POST request, so the values posted 
should end up in request.post_vars.


maybe I don't understand... what I think I need to check is the raw body 
of the request... isn't it? How should I check the request.post_vars? 
Isn't it a dictionary or a Storage object?




As an aside, you can probably simplify your code to just be a function 
rather than a class,


ok I agree


and I don't think there is much gained by putting it inside


ok... but why not?

an @auth.requires decorator -- just run the relevant code directly in 
the listenToHooks function.


Anthony


Cheers
    Manuele

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

2018-02-28 Thread Manuele Pesenti

Hi!

I need to develop a web service that listen to webhook calls from a 
woocommerce site, I thought to write a little check class to pass to 
auth.requires decorator like the following:



class HookCheck(object):
    secret = ''

    def __init__(self):
    super(HookCheck, self).__init__()
    self()

    def compute(self, body):
    dig = hmac.new(self.secret.encode(),
    msg = body.encode(), # your_bytes_string
    digestmod = hashlib.sha256
    ).digest()
    computed = base64.b64encode(dig).decode()
    return computed

    def __call__(self):
    signature = ''    # <- how can I get from 
the request headers?

    body = request.body.read() # <- Is it the right string to encode?
    computed = self.compute(body)
    print signature, computed, signature==computed
    return signature==computed


@service.json
@auth.requires(HookCheck(), requires_login=False)
def listenToHooks():
    return {}


can somebody help me to get the correct values of the hook signature and 
the raw call body to check?


As far as I know the signature contained in the header field 
"X-Wc-Webhook-Signature" and I'm not sure if the string from which get 
the hmac hash is just what I get from the read method of the 
request.body object.


thank a lot

    Manuele

--
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: Use web2py as a reverse proxy

2018-02-14 Thread Manuele Pesenti

Hi Anthony and LoveWeb2py,

I used this controller exactly to let authenticated and authorized users 
access to a third part application not exposed to the web, I shared in 
order to collect opinions from experts, any suggest appreciated.


Cheers

    Manuele


On 14/02/2018 13:37, Anthony wrote:

On Tuesday, February 13, 2018 at 10:15:13 PM UTC-5, LoveWeb2py wrote:

Where did you use this or how did you use your version of the
proxy Manuele? Thank you for sharing!

Anthony - we want web2py to be the only interface to docker
containers.


Is there some web2py specific operations you need to happen between 
the client and the destination server (e.g., web2py 
authentication/authorization)? Otherwise, web2py is probably not the 
most efficient way to proxy HTTP requests. How are you serving web2py 
itself?


--
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: Use web2py as a reverse proxy

2018-02-13 Thread Manuele Pesenti

I wrote something like that few years ago... maybe you can start from here:

https://gist.github.com/manuelep/81ffe8ce57de4dc9b2d80a99c08992cc

please let me know if you find any interest in it.

Cheers

    Manuele


On 13/02/2018 13:10, Anthony wrote:

On Monday, February 12, 2018 at 9:43:53 PM UTC-5, LoveWeb2py wrote:

Django has a reverse proxy module... Wondering if web2py has
something similar?
https://djangopackages.org/grids/g/reverse-proxy/



I don't think so.

I want to make web2py the single interface to multiple applications.


Can you explain further what you are trying to do? Why not use 
something like Nginx as a reverse proxy?


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] How to activate google analytics

2018-02-02 Thread Manuele Pesenti

Dear all,

is it indeed sill a good and updated choice to setup the variable 
response.google_analytics_id (in menu.py) in order to activate GA[1]?
I mean reading the offical GA documentation[2] it seams that GA is 
activated with such different js code and I was thinking if would be a 
better choice follow the official reference of the service.


Thanks for any suggest

Cheers

    Manuele

[1] 
http://web2py.com/books/default/chapter/29/05/the-views?search=google_analytics_id


[2] https://support.google.com/analytics/answer/1008080?hl=it

--
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: serve static files in deployment on pythonanywhere

2017-12-06 Thread Manuele Pesenti

Hi Anthony,

thank you for your reply,


On 06/12/2017 15:36, Anthony wrote:


I followed what indicated in the web configuration panel setting
up two
static configuration considering that my application is accessible
both
as init and as .


First, what do you mean by this -- do you have two exact copies of the 
same application, one in /applications/init and one in 
/applications/appname? If so, why?


I simply create a local symlink in the application folder called init 
that point to the parallel application folder in order to let the web 
server respond to the requests with no specified application with the 
one I want.



In order to be sure the configuration takes effect I used a broken
path
for one of the two configuration as follows:

1. '/init/static/'             ->    '/home//web2py/applications//static/'
2. '/init//' ->    '/home//web2py/applications//static_broken/'



errata corrige:

2. '//static/' ->    '/home/user>/web2py/applications//static_broken/'




web2py will not generate any URLs matching /init/ to point to 
static files (or for any requests). What is the point of that mapping?


as far as I can see in the headers of my web application pages static 
files are linked accordingly to the requested path, so:


if http://myhost/app/default is requested static file links looks like: 
http://myhost/app/static/...
on the other hand if http://myhost/init/default is requested static file 
links looks like: http://myhost/init/static/...


isn't it correct??



than (after reloaded the application) I tried to access the same
static
file from the browser using the two options:

1. http:///init/static//.js
2. http:static//.js


Mapping #2 above is for /init/, so it will not affect 
requests to //static. If you want to re-route requests for 
//static, then you need a mapping for that pattern.


you're right... I wrote an errata corrige for that above. Sorry.



What exactly are you trying to achieve? Why are you trying to map some 
static requests to a non-existent folder?


I just wanted to check the effect of my configuration.



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.


--
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] serve static files in deployment on pythonanywhere

2017-12-06 Thread Manuele Pesenti

Hi!

I'm trying to setup static files mapping for my application loaded on 
pythonanywhere service.
I followed what indicated in the web configuration panel setting up two 
static configuration considering that my application is accessible both 
as init and as .


In order to be sure the configuration takes effect I used a broken path 
for one of the two configuration as follows:


1. '/init/static/'             ->    '/home/user>/web2py/applications//static/'
2. '/init//' ->    '/home/user>/web2py/applications//static_broken/'


than (after reloaded the application) I tried to access the same static 
file from the browser using the two options:


1. http:///init/static//.js
2. http:static//.js

but (even after reloading file using ctrl+F5) I get the same correct result.

Is there some other configuration or changes to be made on the web2py 
side to be made for thees porpuses?


Thanks a lot.

    Manuele

--
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: to be or not to be... run by scheduler

2017-10-30 Thread Manuele Pesenti

Ok that's the problem, I'm using a 2.14.6 release.

Thanks Anthony and others


On 28/10/2017 13:14, Anthony wrote:

That was a bug but should be fixed in web2py 2.15.

If you can't upgrade, as an alternative, see:

https://groups.google.com/d/msg/web2py/JeE6jLP-qjI/MXS0MVdOCQAJ

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: to be or not to be... run by scheduler

2017-10-26 Thread Manuele Pesenti
It seams that the parameter request.is_scheduler is always set to false 
on my colleague windows system


could it be a possible bug? Any other experience?

    M.


On 20/10/2017 17:20, Anthony wrote:

If it is a scheduler execution, request.is_scheduler will be True.

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: sistemExit during scheduler execution

2017-10-25 Thread Manuele Pesenti
Il 25/10/17 08:56, Dave S ha scritto:
> Line 166 is the error handler after a try: run_models_in() .  Anything
> unusual about the models for this app?
> Do you see an exception printed (on the console -- sys.stderr is used)
> with the stack trace?
>
> /dps

Thank you Dave for your answare. I'm still looking for the cause of this
problem but I think it could be related to the trouble I got with the
database max number connections (look the thread "[...] too many db
connections to db [...]" for details).

Best regards

    Manuele

-- 
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: maybe too many db connections todb on pythonanywhere

2017-10-24 Thread Manuele Pesenti
Il 24/10/17 13:47, Giles Thomas ha scritto:
> Hi Manuele,
>
> PythonAnywhere dev here: there's no extra cost if you want to increase
> the maximum number of Postgres connections -- just follow the
> instructions on this help
> page: https://help.pythonanywhere.com/pages/PostgresConnections/.  
> Don't forget to contact us once you've increased the connection count
> so that we can bounce your Postgres instance.
>
Hi Giles!
Good to know I'll try it and contact you immediatly.
Best regards

    M.
>
> All the best,
>
> Giles


-- 
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] sistemExit during scheduler execution

2017-10-24 Thread Manuele Pesenti
Hi *!

What could be the reason of the subsequant traceback during a scheduler
function execution?

"Traceback (most recent call last):  File
"/home/colouree/web2py/gluon/scheduler.py", line 293, in executor   
_env = env(a=a, c=c, import_models=True)  File
"/home/colouree/web2py/gluon/shell.py", line 166, in env   
sys.exit(1)SystemExit: 1"

Cheers

    Manuele

-- 
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: maybe too many db connections todb on pythonanywhere

2017-10-23 Thread Manuele Pesenti

Thanks Alex,

that's what I get from the db engine about my maximum number of connections:

psql (9.4.11, server 9.4beta3)
Type "help" for help.
postgres=# SHOW max_connections;
 max_connections
-
 20
(1 row)

reading the suggested wiki page I found this: "PostgreSQL on good 
hardware can support *a few hundred connections*. If you want to have 
thousands instead..." so it seams something can be done on the side of 
the db configuration... if permitted from the service (maybe paying 
something more).


Cheers

    Manuele


On 21/10/2017 00:20, Alex Glaros wrote:
there are a lot of fixes if search on your error string, plus 
max_connections parm info is at 
Postgres https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server


what is your max_connections set to now?

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.


--
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] maybe too many db connections todb on pythonanywhere

2017-10-20 Thread Manuele Pesenti
I often get this error from the db engine of my pythonanywhere account 
service


OperationalError: FATAL:  remaining connection slots are reserved for 
non-replication superuser connections


is there something quick to solve or by-pass it or do I need some 
profiling to limitate requests to the db?


thank you in advance

    M.

--
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] to be or not to be... run by scheduler

2017-10-20 Thread Manuele Pesenti

Hi *!

Is there a way to distinguish from within a function if it's run from 
the scheduler or not?


thanks a lot

    M.

--
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: deploy with scheduler

2017-08-04 Thread Manuele Pesenti
Il 04/08/17 16:08, Manuele ha scritto:
> Dear all,
>
> I'm bound to decide which service to use for the deploy of a brand new
> web application, at the moment I'm trying Openshift but I'm open to
> alternatives, the first mandatory requirement is that the service must
> support the web2py scheduler, does anybody knows if is it supported by
> openshift?
>
> Thank you very much
>
> Cheers
>
> Manuele
>
>
Just a tricky idea... the scheduler can be runned together with the web
server using the -K app -X options as explained in the manual, is it
possible to "easily" modify the web2py code in order to get always the
same result even without the two options?

Best regards

Manuele

-- 
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] web site down??

2017-06-07 Thread Manuele Pesenti
Hi,

from some time (days but maybe weeks) the web2py web site seams not
reacheable for me... anybody has the same trouble?

Cheers

Manuele

-- 
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: Customize grid ondelete warning message

2017-04-11 Thread Manuele Pesenti
Il 08/04/17 09:43, Manuele Pesenti ha scritto:
> What if I want a customization for a specific grid and not for all the
> application?

I solved changing the value of the js variable in the header of the page
where the message has to be different from the others defining again the
variable and overwriting the value.

Thanks a lot

M.

-- 
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: Customize grid ondelete warning message

2017-04-08 Thread Manuele Pesenti
Il 07/04/17 14:37, Leonel Câmara ha scritto:
> You can change it in the web2py_ajax.html view it's the
> w2p_ajax_confirm_message var.

Thanks Leonel,

What if I want a customization for a specific grid and not for all the
application?

Is there other way?

Thank a lot

Cheers

Manuele

-- 
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] Customize grid ondelete warning message

2017-04-07 Thread Manuele Pesenti
Hi!

Is there an easy way to customize the warning message that pops up when
I try to delete a record from a table using gird?

Both from grid and from edit interface, hopefully from the same place ;)

Thanks a lot

M.

-- 
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] initialize component via js

2017-03-06 Thread Manuele Pesenti
Il 06/03/17 17:27, Richard Vézina ha scritto:
> See at the end of LOAD section in the book
> : 
> http://web2py.com/books/default/chapter/29/12/components-and-plugins?search=web2py_component#LOAD

Wow! Thanks... I'll give it a try.

M.

-- 
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] initialize component via js

2017-03-06 Thread Manuele Pesenti
Hi!

Would it be possible to initialize a new component via javascript?

I would like to dinamically define a component inside a bootstrap modal
object and than initialize it.

I've tryied with reload command but it does not work... it gave me this
error:

TypeError: jQuery(...).get(...).reload is not a function

Any suggestion?

Thanks

Cheers

Manuele


-- 
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: get a file path instead retrieving it

2016-12-27 Thread Manuele Pesenti
Il 27/12/16 17:22, Anthony ha scritto:
> I'm not sure it's considered part of the public API (it's not in the
> book), but you can do:
>
> |
> filepath
> =db.mytable.myupload.retrieve_file_properties(row.myupload)['path']
> |
>
> The returned dictionary also includes a "filename" key, which holds
> the decoded (i.e., original) filename.
I was just bound to answer the same :)
Thank you Anthony

Cheers
M.
>
> More generally, when uploadseparate=True, the filepath is
> /path/to/uploadfolder/tablename/fieldname/uuid[:2], where uuid is the
> 16-character UUID segment in the stored filename (i.e.,
> tablename.fieldname.uuid.base64encoded_filename).
>
> 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] get a file path instead retrieving it

2016-12-27 Thread Manuele Pesenti
Hi!

Other than the methods "store" and "retrieve" of a field is there a
programmatic way to get from a row just the path where a file is stored
on the filesystem (expecially when uploadseparate option is set to True)?


Thank you very much

Manuele

-- 
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: install plugin via batch procedure

2016-11-28 Thread Manuele Pesenti
Il 28/11/16 13:07, Anthony ha scritto:
> .w2p files (including plugin files) are just .tar.gz files, so
> ultimately you just need to unzip it over the application folder. To
> do that, you can use the gluon.fileutils.w2p_unpack_plugin function
> (or just the gluon.fileutils.w2p_unpack function, which is called by
> the former). They are simple functions, so have a look at how they work.

Thank you Anthony! I tried plugin_install from the python shell and it
worked like a charm!

Regards

Manuele

-- 
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] install plugin via batch procedure

2016-11-28 Thread Manuele Pesenti
Hi!

I'm trying to figure out how to install a web2py plugin without using
the admin web interface but a batch procedure running a script or
command... any idea?

Thank you very mutch

Cheers

Manuele

-- 
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: pydal bug or odd behaviour

2016-11-08 Thread Manuele Pesenti
Il 08/11/16 02:55, Massimo Di Pierro ha scritto:
> Please open a pydal issue.

Ok done https://github.com/web2py/pydal/issues/428

Thank Massimo :)

M.

-- 
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: Which data type for latitude and longitude?

2016-11-07 Thread Manuele Pesenti
Il 07/11/16 18:11, Alex Glaros ha scritto:
> Thanks guys. Will probably use GIS later but for now, can you help me
> with the field definition syntax for float?  Is this correct?
>
> Field('longtitude', 'FLOAT((5,2))'),
> Field('latitude',  'FLOAT((5,2))'),

uhm it seams you want decimal ;)

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types

M.

-- 
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] Which data type for latitude and longitude?

2016-11-07 Thread Manuele Pesenti
Il 07/11/16 05:35, Alex Glaros ha scritto:
> Which web2py data type for latitude and longitude?
>
> Am using Postgres database
>
> thanks,
>
> Alex Glaros

It depends... for enjoing the full power of GIS capabilities you can
consider of using a geometry() field[1] but in this case a PostGIS
installation is required, otherwise float type could be another easier
option.


[1]
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#PostGIS--SpatiaLite--and-MS-Geo--experimental-

-- 
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] pydal bug or odd behaviour

2016-11-07 Thread Manuele Pesenti
Hi!

Something odd seams happen passing from pydal 16.03 to a newer version
using json field and postgresql adapter.

This is the traceback I get from the newer version when exploring table
data through admin:

Traceback (most recent call last):
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/restricted.py",
line 227, in restricted
exec ccode in environment
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/applications/ValisBuggerTracker/controllers/appadmin.py",
line 703, in 
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/globals.py",
line 417, in 
self._caller = lambda f: f()
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/applications/ValisBuggerTracker/controllers/appadmin.py",
line 325, in update
2)).select().first()
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/objects.py",
line 2045, in select
return adapter.select(self.query, fields, attributes)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/adapters/base.py",
line 746, in select
return self._select_aux(sql, fields, attributes, colnames)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/adapters/base.py",
line 727, in _select_aux
return processor(rows, fields, colnames, cacheable=cacheable)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/adapters/base.py",
line 305, in parse
for row in rows
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/adapters/base.py",
line 229, in _parse
value = self.parse_value(value, fit, ft, blob_decode)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/adapters/base.py",
line 196, in parse_value
return self.parser.parse(value, field_itype, field_type)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/parsers/__init__.py",
line 101, in parse
return self.registered[field_itype](value, field_type)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/parsers/__init__.py",
line 76, in __call__
return self.call(value, field_type)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/parsers/__init__.py",
line 73, in _call
return self.f(self.parser, value)
  File
"/home/manuele/development/web/web2py/web2py_R-2.14.6/gluon/packages/dal/pydal/parsers/base.py",
line 129, in _json
raise RuntimeError('json data not a string')
RuntimeError: json data not a string

The same table downgrading the pydal to v16.03 give absolutely no problems.

The strange thing is that reloading the webserver I can reload the page
with no errors but an exception is raised exploring a single record...
again if I reload the framework I can see the single record data but
going back to the tabular view the previous exception is raised.

Please ask for details if needed.

Cheers

Manuele


-- 
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] matching a Week day in query

2016-11-02 Thread Manuele Pesenti
Il 02/11/16 09:27, icodk ha scritto:
> Ex. on Manday I want to select all record where the Monday field is true.
maybe something like that?

|fromdatetime importdate importcalendar my_date =date.today()dow =
calendar.day_name[my_date.weekday()].lower()
db(db.time_rule[dow]==True).select() |

||M.|
|

||

-- 
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] A simple request for the "so old and so good admin"

2016-10-01 Thread Manuele Pesenti
Il 30/09/16 19:47, António Ramos ha scritto:
> Hello, i would like to suggest the ability to duplicate a record in
> admin.
>
> It would make me happy :)
what about doing it in your web2py console with something like:
db.table[0] = {k: v for k,v in db.table[id].iteritems() if k!='id'}

M.
>  
> Regards
> António


-- 
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] st_within example

2016-09-08 Thread Manuele Pesenti
Il 08/09/16 10:57, Gael Princivalle ha scritto:
> Hello.
>
> Could someone give me an example of the postgis st_within function?
>
> http://postgis.org/docs/ST_DWithin.html
>
> Model
> |
> db.define_table('places',Field('loc','geometry()'))
> |
> Where I insert 3 geoPoints:
> |
> geoPoint(1,1)geoPoint(3,2)geoPoint(6,5)
> |
>
> |
> query =db.places.loc.st_within(geoPoint(0,0),3)
> |
> geoPoint(0, 0) is my geometry 3 is the max. distance from this geometry
> |
> results =db(query).select(sp.id,sp.loc)
> |
> Ticket is:
> |
> st_within()takes exactly 2arguments (3given)
> |
|Hi Gael,
the st_within and st_dwithin are two different method, the second one is
the only you want now :)
|
>
> That's strange because I have 2 arguments:
> |
> geoPoint(0,0)3
> |
> Can someone give a hand? 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.


-- 
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] Best way to pre-populate a database on start-up

2016-08-31 Thread Manuele Pesenti
Il 30/08/16 21:40, Niphlod ha scritto:
> +1 for Dave .
>
> with isempty() in a model you're executing a query for each and every
> request for absolutely NO REASON.

I usually create a script directory and put there scripts with commands
to be performed only once, such in the case of pre-populating or more in
general of application initialization with the sintax:

$ python web2py.py -S myapp -M -R applications/myapp/scripts/myscript.py

in case of model is not needed (and it's not the case of pre-population)
you can even not use the -M option.

Do you think it could be a good way to suggest?

Cheers


Manuele

-- 
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] Do not show None

2016-07-08 Thread Manuele Pesenti
Il 08/07/16 08:54, Kenneth ha scritto:
> Hello,
>
> I fetch a number on records from the database and show it on the
> screen. Is there a way to not print the text None for fields that are
> in the state None. I could use if field != None but I'd rather not use
> IF if there is an other way.
I would say that it depends on what result you want to accieve:
1. You don't want results with no values for the field in object, in
that case it's better to cat out them with an adequate query (i.e.:
...&(myfield!=None));
2. You want to see "" (empty string) instead of "None" for the records
that has no value for the field in object, in that case you can fix the
represent function of the field with something like field.represent =
lambda v: "" if v is None else v;

I hope it could help.
Cheers

Manuele
>
>
> Kenneth
>
> -- 
> 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] simple file uploader to database as a plugin

2016-06-17 Thread Manuele Pesenti
Il 14/06/16 20:50, Vic Ding ha scritto:
> It works when I directly access the index page, however when I LOAD it
> to other pages it stops working. No ticket, no error. 
> |
> {{=LOAD('plugin_upload_file','index',args=('item',item_id),user_signature=True)}}
> |
>
>
> Any idea?

maybe it could help:
http://www.web2py.com/books/default/chapter/29/12/components-and-plugins#Ajax-post-does-not-support-multipart-forms

>From a vary fast reading I think it's just about a case like yours...

M.

-- 
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 do I redirect to a different application from one application?

2016-06-17 Thread Manuele Pesenti
Il 17/06/16 14:31, Steve Joe ha scritto:
> I know how redirect works. But I am not sure how to redirect to
> another app on the same web2py site. 
> i dont want to put long url , something like this:
> redirect("http://127.0.0.1:8000/port/;)
> as it looks so naive
> [...]
>
>
>
> http://www.web2py.com/books/default/chapter/29/04/the-core#URL
> 
>
So this is what you are looking for ^
:)

M.
>
>
>
> Cheers
>
> M.
>
> -- 
> 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] How do I sort a list containing the rows of a db query according to a db table field?

2016-06-17 Thread Manuele Pesenti
Il 17/06/16 11:06, Steve Joe ha scritto:
> def index():
> skills=db(db.skills.id>0).select()
> pro_lang=[]
> fake=[]
> for skill in skills:
> if skill.skilltype=="Programming Languages":
> pro_lang.append(skill)
> else:
> fake.append(skill)
> # how do i sort both the arrays as per the field skill.comfort ?
> return locals()

why do not simply do db(db.skills.id>0).select(orderby=db.skills.comfort) ?

:)

M.

-- 
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 do I redirect to a different application from one application?

2016-06-17 Thread Manuele Pesenti
Il 17/06/16 08:20, Steve Joe ha scritto:
> exact syntax? 

Have you looked for it in the doc?

http://www.web2py.com/books/default/chapter/29/04/the-core?#HTTP-and-redirect

http://www.web2py.com/books/default/chapter/29/04/the-core#URL

Cheers

M.

-- 
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: show map on grid view

2016-06-17 Thread Manuele Pesenti
Il 05/06/16 00:06, 黄祥 ha scritto:
> what i want to achieve is showing a map in each row of
> SQLFORM.smartgrid links (looks like in the attached file)
> thanks massimo, tried your suggestion, but got the same result. any
> idea or suggestion to achieve it in web2py?
>
Hi Stifan,
what about introducing some code like that in your SQLFORM.grid object...

assuming your coordinates are stored in columns lat and lng of your table...

scriptbody = """
function initMap() {
var myLatLng = {lat: %(lat)s, lng: %(lng)s};

var map = new
google.maps.Map(document.getElementById('map_%(id)s'), {
  zoom: 4,
  center: myLatLng
});

var marker = new google.maps.Marker({
  position: myLatLng,
  map: map,
  title: 'Hello World!'
});
  }
""" % r

grid = SQLFORM.grid(
links = [dict(header="Map", body=lambda r: SPAN(DIV(_id="map_%(id)s"
% r, _style="width: 100%; height: 100%"), SCRIPT(scriptbody,
_type="text/javascript")))],
)

some useful reference documentation:
1)
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#Virtual-fields-in-SQLFORMgrid-and-smartgrid
2)
https://developers.google.com/maps/documentation/javascript/examples/marker-simple

Cheers

Manuele
> thanks and 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 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: ReferenceError: web2py is not defined

2016-06-14 Thread Manuele Pesenti
Il 14/06/16 23:22, Manuele Pesenti ha scritto:
>
> Yes! It fixes the bug. I'll open the issue.
>
> Thanks to Everyone! :)
>
> M.
>
just opened: https://github.com/web2py/web2py/issues/1364

Best regards

M.

-- 
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: ReferenceError: web2py is not defined

2016-06-14 Thread Manuele Pesenti
Il 14/06/16 21:19, Anthony ha scritto:
> es, looks like a bug here:
> https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py-bootstrap3.js#L14.
> Should be:
>
> |
> $.web2py.validate_entropy($(this));
> |
>
> See if that change works, and please file a Github issue.
>
> Thanks.
>
> Anthony

Yes! It fixes the bug. I'll open the issue.

Thanks to Everyone! :)

M.

-- 
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] ReferenceError: web2py is not defined

2016-06-14 Thread Manuele Pesenti
Il 14/06/16 17:56, Richard Vézina ha scritto:
> You miss web2py-bootstrap3.js in your app? Was that error with default
> welcome or your app?

First I got in my app (in wich I rewrote all the layout) but I noticed
that I get the same error using the appadmin... the error is raised in
web2py-bootstrap3.js so it is loaded... and so it is web2py.js (before
web2py-bootstrap3.js) as you can see in the source of the page I
linked... so I can't understand what is the problem...

thanks a lot

Cheers

M.

-- 
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] ReferenceError: web2py is not defined

2016-06-14 Thread Manuele Pesenti
Hi!

I found some client side trouble using the validator IS_STRONG.

Using this validator for such a field of a table and then visiting the
admin and trying to add a new record the debugger console shows thi error:

ReferenceError: web2py is not defined1 web2py-bootstrap3.js:14:6

At this link you can find the page source I got:
http://paste.debian.net/739046/

Maybe it's a bug?

Thanks a lot
Cheers

Manuele

-- 
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: multi component form loaded in the same page

2016-06-08 Thread Manuele Pesenti
Il 07/06/16 22:25, Niphlod ha scritto:
> for future lurkers of threads, posting the code, or even better a
> minimal app, it's not something Anthony (or the occasional helper)
> asks for his own amusement...that simple requirement forces your brain
> to reevaluate all the steps, in a clean environment.
>
> 50% of the cases, your brain was stuck on an anomaly and it knew how
> to solve it already ^_^

Thank you Niphlod (too) :)

I will re-build the controllers step by step, maybe there's a formname
overwriting somewhere... unfortunately it's an application refactoring
and I'm copy and paste from one app to another. This not helps.

Cheers

Manuele

-- 
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: multi component form loaded in the same page

2016-06-07 Thread Manuele Pesenti
Please forgive and forget! My fault!
In the example I forgot to pass the name of the form as query string
argument... the LOAD command would have to be this one:

{{=LOAD(request.controler, "myform.load", args=(name,), ajax=True, 
targer="cmp-%s" % name)}}

In this way everything works as expected... At this point I have to
check what I missed in the original code...
Thanks a lot

M.


Il 07/06/16 21:31, Manuele Pesenti ha scritto:
> Il 07/06/16 15:24, Anthony ha scritto:
>> Again, it might help to see more code. For example, are you calling
>> session.forget() at any point? What does the session look like at each
>> stage (i.e., as each form is created and as each is submitted)? It
>> sounds like the formkey for each form is not in the session, but not
>> clear why.
>>
>> Anthony
> Ok just try this simple code:
>
> * controllers/test.py
>
> # -*- coding: utf-8 -*-
>
> # try something like
>
> def index(): return dict(message="hello from test.py")
>
> def myform():
>
> form = SQLFORM.factory(
>
> Field("name")
>
> )
>
> if form.validate(formname=request.args(0)):
>
> print "Yes"
>
> else:
>
> print "No"
>
> return dict(form=form)
>
> * views/test/index.html
>
> {{extend 'layout.html'}}
> This is the test/index.html template
>
> {{for name in ("foo", "bar", "spam",):}}
> {{=LOAD(request.controler, "myform.load", ajax=True, targer="cmp-%s" % 
> name)}}
> {{pass}}
>
> {{=BEAUTIFY(response._vars)}}
>
> You'll notice that:
>
> 1. Each time you'll reload the whole page the first two forms will need
> TWO submit to get a success message.
> The first time the form validation fails because the formkey submitted
> does not match with the one in session (even if I have specified
> different formname for each form loaded)
>
> 2. After every reload of the whole page only the third component loaded
> get a success message after a single submit.
>
> It seams to mean that only a formkey is saved in session and each form
> refers to the same formname to match the formkey passed in request.
>
> Is it a correct behaviour? Have I missed something in my code to get the
> expected result?
>
> Thank you very mutch
>
> Cheers
>
> Manuele
>

-- 
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: multi component form loaded in the same page

2016-06-07 Thread Manuele Pesenti
Il 07/06/16 15:24, Anthony ha scritto:
> Again, it might help to see more code. For example, are you calling
> session.forget() at any point? What does the session look like at each
> stage (i.e., as each form is created and as each is submitted)? It
> sounds like the formkey for each form is not in the session, but not
> clear why.
>
> Anthony

Ok just try this simple code:

* controllers/test.py

# -*- coding: utf-8 -*-

# try something like

def index(): return dict(message="hello from test.py")

def myform():

form = SQLFORM.factory(

Field("name")

)

if form.validate(formname=request.args(0)):

print "Yes"

else:

print "No"

return dict(form=form)

* views/test/index.html

{{extend 'layout.html'}}
This is the test/index.html template

{{for name in ("foo", "bar", "spam",):}}
{{=LOAD(request.controler, "myform.load", ajax=True, targer="cmp-%s" % 
name)}}
{{pass}}

{{=BEAUTIFY(response._vars)}}

You'll notice that:

1. Each time you'll reload the whole page the first two forms will need
TWO submit to get a success message.
The first time the form validation fails because the formkey submitted
does not match with the one in session (even if I have specified
different formname for each form loaded)

2. After every reload of the whole page only the third component loaded
get a success message after a single submit.

It seams to mean that only a formkey is saved in session and each form
refers to the same formname to match the formkey passed in request.

Is it a correct behaviour? Have I missed something in my code to get the
expected result?

Thank you very mutch

Cheers

Manuele

-- 
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: multi component form loaded in the same page

2016-06-07 Thread Manuele Pesenti
Il 07/06/16 13:07, Anthony ha scritto:
> We may need to see more code. Do all the forms load on the page? If
> so, what happens in the browser network tab when you submit one of
> them? If the Ajax calls are being made properly, what happens on the
> server in the controller (i.e., where in the code does it fail, and
> what does the session look like at each stage)?
>
> Anthony

well, it does not really fail... if I submit one of the forms all
parameters are correctly sent to the controller but I the form
validation silently fails (i.e. form.validate(...) returns False with an
empty form.vars.errors storage object).

The only way I found just now to make it run as expected (to me, off
course ;) ) is setting up the session parameter of the validate method
of the form to None. But I understand from the manual it's not a safe
practice...

M.

-- 
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 do I host my web2py app on openshift?

2016-06-07 Thread Manuele Pesenti
Il 07/06/16 09:28, Steve Joe ha scritto:
> any stepwise procedure?

Just look here:
http://stackoverflow.com/questions/19215201/how-do-you-get-an-existing-web2py-app-deployed-on-openshift

I've done it only once and I can't remember now how :)

but I remember it was very easy.


M.

-- 
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] multi component form loaded in the same page

2016-06-07 Thread Manuele Pesenti
Hi guys!

What's the right way to use multiple components in a page that poit to
different forms?

It seams I have a problem with the _formkey... I tyied this way:

* in the component controller that is called many times I have defined:

def _iface():

iface = request.args(0)

...

form = SQLFORM.factory(...)

if form.validate(keepvalues=True, hidden=dict(name=iface),
formname='form_'+iface):

...


* in the main view that performs the multiple call I have written
something like:


{{for n,name in enumerate(net_conf._siter()):}}

{{=LOAD(request.controller, "_iface", extension="load",
args=(name,), ajax=True, target="iface_"+name)}}

{{pass}}


if I limit, in the main view, the multiple load to a single one every
thing works fine... If more than one form are loaded only the last
loaded works fine at the first submit.

I hope I've given enough information to understand.

Thank you very mutch.

Cheers


Manuele Pesenti

-- 
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] html helper A with delete attribute not working, the div is not removed

2016-05-17 Thread Manuele Pesenti
Il 16/05/16 15:43, Vic Ding ha scritto:
> |
> defremoveProduct():pid =request.args(0,cast=long)form
> =crud.delete(db.product,pid)response.js
> ='document.getElementById("product%s" %request.args(0,
> cast=int)).remove();'
> |
the first problem I see is that the last line has to be something like
this instead:

response.js = 'document.getElementById("product%s").remove();' %
request.args(0, cast=int)

:)

M.

-- 
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] html helper A with delete attribute not working, the div is not removed

2016-05-16 Thread Manuele Pesenti
Do you get any output in the browser console? Maybe some error in the
javascript code passed in the header response?

Cheers

M.

Il 16/05/16 12:23, Vic Ding ha scritto:
> Hi Manuele,
> Tried the later one. Did not work for me. 
>
> <https://lh3.googleusercontent.com/-K5C1uw54dM4/Vzmfc4xTbuI/Hv0/lRnRpSbL6UM8sygk7lVIJML3lXmJ-GyhgCLcB/s1600/Screen%2BShot%2B2016-05-16%2Bat%2B12.19.30.png>
>
> The delete button flipped to "working..." for split second then back
> to delete. I get a flash message says record deleted, but the div is
> still not. I even tried to hard code the div id in the response.js,
> did not do the trick either. 
>
> Any other idea?
>
> Cheers,
> Vic
>
> On Monday, May 16, 2016 at 11:54:33 AM UTC+2, Manuele wrote:
>
> Il 16/05/16 11:52, Manuele Pesenti ha scritto:
>> response.js = " document.getElementById("product%s" %
>> request.args(0, cast=int)).remove();"
> uhm try this one instead:
>
> response.js = 'document.getElementById("product%s" %
> request.args(0, cast=int)).remove();'
>
> M.
>
> -- 
> 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
> <mailto: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] html helper A with delete attribute not working, the div is not removed

2016-05-16 Thread Manuele Pesenti
Il 16/05/16 11:52, Manuele Pesenti ha scritto:
> response.js = " document.getElementById("product%s" % request.args(0,
> cast=int)).remove();"
uhm try this one instead:

response.js = 'document.getElementById("product%s" % request.args(0,
cast=int)).remove();'

M.

-- 
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] html helper A with delete attribute not working, the div is not removed

2016-05-16 Thread Manuele Pesenti
try to set in the removeProduct controller something like this (not tested):

response.js = " document.getElementById("product%s" % request.args(0,
cast=int)).remove();"

cheers

Manuele

Il 15/05/16 17:49, Vic Ding ha scritto:
> Hi all,
>
> I am new to web2py. 
> I have a HTML helper
> |
> DIV(   
> DIV(A('delete',callback=URL('removeProduct/'+str(row.id)),delete='div#product'+str(row.id)),_class='delete_button'),
>  
>   _class='product',_id='product'+str(row.id))
> |
>
> The callback to removeProuct/id is working well, however, the actual
> content is not removed after deletion. I am trying to tackle the issue
> by using delete attribute as read in the online book at web2py
> website. It is not working either. 
>
> Any idea? did I miss something here?
>
> Thanks!
>
> Vic
>
> -- 
> 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] Re: Not Authorized - but I don't know why

2016-05-09 Thread Manuele Pesenti
Il 08/05/16 20:34, Simon Carr ha scritto:
> I found the problem, I had to add
>
> |
> user_signature=False
> |
>
> to the SQLFORM.grid i.e. (SQLFORM.grid(.,user_signature=False)
>
> This sorted out the problem
Now I think you can just decorate your controller function to prevent
not logged user to cerate/edit records...

M.

-- 
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] Serialize object having js-function()

2016-04-28 Thread Manuele Pesenti
Il 28/04/16 00:26, Val K ha scritto:
> Hi! 
> I made mini but useful and universal class to hold json-serializable
> objects.
> Main goal - serialize objects having items-function() as js-objects
>
It looks very interesting to me :)
Thank you for sharing!
I'll notice here if I use it for a little project I have in my mind ;)
Cheers

Manuele

>
> |
> |
> from types import MethodType
> from gluon.contrib  import simplejson as sj
>
> class Smart_Storage(dict):
> """
> A Smart_Storage object is like a dictionary but:
> - set/get value:
> obj['foo'] == obj.foo
> - set/get attribute:
> # use `._.` or `._['attr_name']`  to set attribute
> obj._.attr = 'I`m attribute but not data!!!'
> obj._['another_attr'] = 'I`m another one'
> # set/update many attributes
> obj._.update(dict(...))
>
> # use dot only to get attribute
> print obj.attr
> # remember that
> obj['any_attr'] == None
> # but don't forget
> obj.__dict__['any_attr'] == obj.any_attr
>
> - bind/call method:
> # use `._['@...']` to bind method
> obj._['@my_meth'] = lambda self: 'I`m method of %s' % self
> # nothing new
> obj.my_meth()
>
> - finally obj.__json__():
> # works recursively
> # for item that is Smart_Storage instance - item.__json__()
> will be applied
> obj.__json__(only = None, exclude = None, values_only = False)
>
> - and obj.__formatters__():
> # use __formatters__ to control serialization *(note double
> quote)*
> obj.__formatters__['key_name'] = lambda self, k, v:
> self.check_access(k) and v or '"-access denied-"'
> # or just
> obj.__formatters__['key_name'] = '"key = %(k)s,  value =
> %(v)s"'
> # serialize web2py helpers
> obj.html = DIV()
> obj.__formatters__['html'] = lambda self, k, v: '"%s"' %
> v.xml()
> # serialize js-function/object for embedding as script
> obj.name='John'
> obj.surname='Smith'
> obj.who_are_you = "function(){ console.log( 'I`m',
> this.name, this.surname );}"
> obj.__formatters__['who_are_you'] = '%(v)s' # not '"%(v)s"'
> obj._['@xml'] = lambda self: \
> SCRIPT( '\n'.join([
> 'var obj = %s;',
> 'obj.who_are_you();',
>  ]) % self.__json__()
> ).xml()
> ...
> # in the view just
> {{ =obj }}
> # that will be
> 
> """
>
> __getattr__ = dict.get
> __getitem__ = dict.get
> __delattr__ = dict.__delitem__
> __repr__ = lambda self: '' % dict.__repr__(self)
>
> class Add_Attr:
>
> def __init__(self, mystor_obj, args=None):
> self.__dict__['mystor_obj'] = mystor_obj
> if args:
> self.update(args)
>
> def __setattr__(self, k, v):
> if k in self.mystor_obj:
> raise RuntimeError('"%s" is in keys' % k)
> self.mystor_obj.__dict__[k] = v
>
> def __setitem__(self, k ,v):
> if k[0] in 

[web2py] Internal error @ web2pyslices

2016-04-22 Thread Manuele Pesenti
doh! http://www.web2pyslices.com/home

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


  1   2   3   4   5   6   >