[web2py] web2py 2.25.1 - bug when running interactive shell?

2023-10-27 Thread Tom Clerckx
I believe web2py/gluon/shell.py", line 238 should use os.path.*abspath* 
instead of *absdir*?

Unpacked and ran a clean version of web2py:

command: python web2py.py -B -S welcome -M

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2023
Version 2.25.1-stable+timestamp.2023.10.08.18.44.43
Database drivers available: sqlite3, imaplib, pymysql, pyodbc
Traceback (most recent call last):
  File "/odindrive/temp/web2pytest/web2py/web2py.py", line 58, in 
gluon.widget.start()
  File "/odindrive/temp/web2pytest/web2py/gluon/widget.py", line 746, in 
start
run(options.shell, plain=options.plain, bpython=options.bpython,
  File "/odindrive/temp/web2pytest/web2py/gluon/shell.py", line 238, in run
adir = os.path.absdir(os.path.join('applications', a))
AttributeError: module 'posixpath' has no attribute 'absdir'. Did you mean: 
'isdir'?

-- 
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/59150263-5851-4adc-9645-2f5c12082834n%40googlegroups.com.


[web2py] Re: app not loading external python library

2023-10-27 Thread Tom Clerckx
I think this is the same issue as was discussed a few months ago:
See this 
thread: https://groups.google.com/g/web2py/c/xYVWpDGLuzY/m/t9sBabWOAgAJ

Seems some issue between the custom importer and the urllib3 module.
Can you  try once more, but also explicitly pip install *urllib3_secure_extra 
*in your virtual env?




On Thursday, October 26, 2023 at 7:33:25 AM UTC+2 Massimo Di Pierro wrote:

> Hello Alex,
>
> thank for reporting this problem. Is it only occurring with web2py 2.25.1? 
>
> On Monday, 23 October 2023 at 14:05:15 UTC-7 alex wrote:
>
>> Hi, 
>>
>> I am running web2py Version 2.25.1-stable in virtualenv (python 3.9.5, it 
>> happens also in python 3.10.10)
>>
>> After activating the virtualenv, I installed requests
>>
>> $ pip install request
>> $ pip show requests
>> Name: requests
>> Version: 2.31.0
>> Summary: Python HTTP for Humans.
>> Home-page: https://requests.readthedocs.io
>> Author: Kenneth Reitz
>> Author-email: m...@kennethreitz.org
>> License: Apache 2.0
>> Location: 
>> /Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages
>> Requires: certifi, charset-normalizer, idna, urllib3
>> Required-by:
>>
>> Importing requests from bpython gives no errors.
>>
>> Importing requests in myapp gives an error.
>> I also tried with other external libraries, some of them do work, some 
>> others cannot be imported.
>>
>> About this case, I have tried the following: 
>>
>> In "web2py/applications/myapp/models/0.py":
>>
>> # - - - - - - - - - - - - - - -
>>
>> # added the virtualenv path to sys.path
>>
>> site_package_path = 
>> "/Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages"
>>
>> if site_package_path not in sys.path:
>> sys.path.append(site_package_path)
>>
>> try:
>> import requests
>> except:
>> raise Exception('import error: "requests" not found')
>>
>>
>> # - - - - - - - - - - - - - - -
>>
>> I am running web2py with: 
>>
>> $python web2py.py -a 'pwd'
>>
>> Error log:
>>
>> # - - - - - - - - - - - - - - -
>> Ticket ID
>> 127.0.0.1.2023-10-24.05-48-51.a557dcfb-55a3-4063-ac27-879cad8fe799
>>
>>  import error: "requests" not found
>> Version
>> web2py™ Version 2.25.1-stable+timestamp.2023.10.08.18.44.43
>> Python Python 3.9.5: /Users/z/dev/web2py/.direnv/python-3.9/bin/python 
>> (prefix: /Users/z/dev/web2py/.direnv/python-3.9)
>>
>> ...
>>
>> Traceback (most recent call last):
>>   File "/Users/z/dev/web2py/gluon/custom_import.py", line 78, in 
>> custom_importer
>> result = sys.modules[modules_prefix]
>> KeyError: 'applications.wh.modules.requests'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "/Users/z/dev/web2py/applications/wh/models/0.py", line 29, in 
>> 
>> import requests
>>   File "/Users/z/dev/web2py/gluon/custom_import.py", line 80, in 
>> custom_importer
>> raise ImportError("No module named %s" % modules_prefix)
>> ImportError: No module named applications.wh.modules.requests
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "/Users/z/dev/web2py/gluon/restricted.py", line 219, in restricted
>> exec(ccode, environment)
>>   File "/Users/z/dev/web2py/applications/wh/models/0.py", line 31, in 
>> 
>> raise Exception('import error: "requests" not found')
>> Exception: import error: "requests" not found
>> Error snapshot help
>> Exception(import error: "requests" not found)
>>
>> inspect attributes
>>
>> Exception instance attributes
>> __cause__ None
>> __class__ 
>> __context__ ImportError('No module named 
>> applications.wh.modules.requests')
>> __delattr__ 
>> __dict__ {}
>> __dir__ 
>> __doc__ 'Common base class for all non-exit exceptions.'
>> __eq__ 
>> __format__ 
>> __ge__ 
>> __getattribute__ 
>> __gt__ 
>> __hash__ 
>> __init__ 
>> __init_subclass__ 
>> __le__ 
>> __lt__ 
>> __ne__ 
>> __new__ 
>> __reduce__ 
>> __reduce_ex__ 
>> __repr__ 
>> __setattr__ 
>> __setstate__ 
>> __sizeof__ 
>> __str__ 
>> __subclasshook__ 
>> __suppress_context__ False
>> __traceback__ 
>> args ('import error: "requests" not found',)
>> with_traceback 
>> Frames
>> File /Users/z/dev/web2py/gluon/restricted.py in restricted at line 219 
>> code arguments variables
>>
>> File /Users/z/dev/web2py/applications/wh/models/0.py in  at line 
>> 31 code arguments variables
>>
>> Function argument list
>> ()
>>
>> Context locals
>>
>> ...
>>
>>
>> 
>> iteritems : 
>> >
>> local_import : 
>> .>
>> myconf : 
>> {'app': {'name': 'WH', 'author': 'Your Name > 'bootstrap3_inline', 'separator': ''}}
>> redirect : 
>> 
>> reduce : 
>> 
>> request : 
>> , 
>> '_custom_import_track_changes': True}>
>> response : 
>> > 'view': 'default/index.html'}>
>> session : 
>> 
>> site_package_path : 
>> "'/Users/z/dev/web2py/.direnv/python-3.9/lib/python3.9/site-packages'"
>> sys : 
>> 
>> to_bytes : 
>> 
>> to_native : 
>> 
>> track_changes : 
>> 
>> xmlescape : 
>> 
>> xrange : 
>> 
>> session
>> 

[web2py] Re: uwsgi with web2py hard crash/locking with nginx

2023-10-17 Thread Tom Clerckx
Maybe you should review the 'high calculation/high plotly' pages for memory 
usage?
As the 'OOM killer' kicked in, it looks like the process is using too much 
memory.

One thing to verify this is to monitor the VmRSS of the processes involved 
(VmRSS is one of the fields in the output when you do 'cat 
/proc//status') 
VmRSS gives you an idea about the amount of RAM memory your process is 
using.

If it's growing out of proportion, you're claiming too much memory and the 
process will be killed by the OOM-killer.


On Monday, October 16, 2023 at 8:15:20 PM UTC+2 lucas wrote:

> hello one and all,
>
> i'm using web2py 2.25.1 with uwsgi 2.0.22 which was downloaded and 
> compiled using pip3 under python 3.10.12 under ubuntu 22.04.  the nginx is 
> apt installed version 1.18.
>
> with that being said, if i install and run my high calculation / high 
> plotly plot pages about 6 to 12 times, the whole damn system comes to a 
> crash.  hard crash.  this also seems to be the case under redhat / amazon 
> linux 2023 similar setup and config.
>
> so i tried crashing the system under just "python3 web2py.py -i 0.0.0.0 -p 
> 80 --no_gui" and also under "uwsgi --http :80 --chdir 
> /opt/web2py_apps/web2py -w wsgihandler:application" but i could NOT get 
> either to crash.  it is only when i nginx daemon it with uwsgi and web2py 
> layered/socketed under nginx that it DOES crash hard.  i think i found 
> under the systemctl logs for uwsgi a logging of the crash, or:
>
> Oct 16 13:48:30 iquanta.info systemd[1]: uwsgi.service: A process of this 
> unit has been killed by the OOM killer.
> Oct 16 13:48:30 iquanta.info uwsgi[1264]: [emperor] *** RAGNAROK EVOKED 
> ***
> Oct 16 13:48:30 iquanta.info uwsgi[1265]: SIGINT/SIGTERM 
> received...killing workers...
> Oct 16 13:48:30 iquanta.info uwsgi[1264]: Mon Oct 16 13:48:30 2023 - 
> [emperor] stop the uwsgi instance web2py.ini
> Oct 16 13:48:30 iquanta.info uwsgi[1265]: Mon Oct 16 13:48:30 2023 - 
> received message 0 from emperor
> Oct 16 13:48:31 iquanta.info uwsgi[1265]: worker 5 buried after 1 seconds
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: worker 1 buried after 2 seconds
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: worker 2 buried after 2 seconds
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: worker 3 buried after 2 seconds
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: worker 4 buried after 2 seconds
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: goodbye to uWSGI.
> Oct 16 13:48:32 iquanta.info uwsgi[1265]: VACUUM: unix socket 
> /run/uwsgi/web2py.sock removed.
> Oct 16 13:48:33 iquanta.info uwsgi[1264]: Mon Oct 16 13:48:33 2023 - 
> [emperor] removed uwsgi instance web2py.ini
> Oct 16 13:48:34 iquanta.info uwsgi[1264]: Mon Oct 16 13:48:34 2023 - The 
> Emperor is buried.
> Oct 16 13:48:34 iquanta.info systemd[1]: uwsgi.service: Failed with 
> result 'oom-kill'.
> Oct 16 13:48:34 iquanta.info systemd[1]: uwsgi.service: Consumed 10.241s 
> CPU time.
> Oct 16 13:48:34 iquanta.info systemd[1]: uwsgi.service: Scheduled restart 
> job, restart counter is at 1.
> Oct 16 13:48:34 iquanta.info systemd[1]: Stopped uWSGI Emperor service.
> Oct 16 13:48:34 iquanta.info systemd[1]: uwsgi.service: Consumed 10.241s 
> CPU time.
>
> with not much to say under the nginx logs.  so, does anyone know what i 
> can be dealing with?  thank you in advance, lucas
>

-- 
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/af50af3f-2764-4cbf-8bfd-06c802d0ff93n%40googlegroups.com.


Re: [web2py] Why am I getting "unable to import requests" in web2py even though requests is accessible directly through python

2023-05-30 Thread Tom Clerckx
gt;
>>>>>>>> apt update
>>>>>>>> apt install curl git
>>>>>>>>
>>>>>>>> install pyenv:
>>>>>>>>
>>>>>>>> curl https://pyenv.run | bash
>>>>>>>>
>>>>>>>> setup the build environment to build python version, from pyenv 
>>>>>>>> docs 
>>>>>>>> <https://github.com/pyenv/pyenv/wiki#suggested-build-environment>:
>>>>>>>>
>>>>>>>> apt install build-essential libssl-dev zlib1g-dev \
>>>>>>>> libbz2-dev libreadline-dev libsqlite3-dev curl \
>>>>>>>> libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev 
>>>>>>>> libffi-dev liblzma-dev
>>>>>>>>
>>>>>>>> Installing python 3.7.16:
>>>>>>>>
>>>>>>>> pyenv install 3.7.16
>>>>>>>>
>>>>>>>> wait for the build process... 
>>>>>>>>
>>>>>>>> adding this in .profile 
>>>>>>>>
>>>>>>>> export PYENV_ROOT="$HOME/.pyenv"
>>>>>>>> command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
>>>>>>>> eval "$(pyenv init -)"
>>>>>>>> eval "$(pyenv virtualenv-init -)"
>>>>>>>>
>>>>>>>>
>>>>>>>> restart the shell or logout... 
>>>>>>>>
>>>>>>>> create an virtual env based on 3.7.16:
>>>>>>>>
>>>>>>>> pyenv virtualenv 3.7.16 testvenv
>>>>>>>>
>>>>>>>> getting web2py:
>>>>>>>>
>>>>>>>> git clone https://github.com/web2py/web2py.git
>>>>>>>> cd web2py/
>>>>>>>> git submodule update --init --recursive
>>>>>>>>
>>>>>>>> Activate the venv:
>>>>>>>>
>>>>>>>> pyenv local testvenv
>>>>>>>> pip install requests
>>>>>>>>
>>>>>>>> (testvenv) max@d11:~/web2py$ ./web2py.py -S welcome
>>>>>>>> web2py Web Framework
>>>>>>>> Created by Massimo Di Pierro, Copyright 2007-2023
>>>>>>>> Version 2.24.1-stable+timestamp.2023.03.22.21.39.14
>>>>>>>> Database drivers available: sqlite3, imaplib, pymysql
>>>>>>>> WARNING:web2py:import IPython error; use default python shell
>>>>>>>> Python 3.7.16 (default, May 28 2023, 09:25:55)
>>>>>>>> [GCC 10.2.1 20210110] on linux
>>>>>>>> Type "help", "copyright", "credits" or "license" for more 
>>>>>>>> information.
>>>>>>>> (InteractiveConsole)
>>>>>>>> >>> import requests
>>>>>>>> >>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Il giorno dom 28 mag 2023 alle ore 01:25 vald...@gmail.com <
>>>>>>>> vald...@gmail.com> ha scritto:
>>>>>>>>
>>>>>>>>> I'm using pipenv to run the virtual environment.
>>>>>>>>>
>>>>>>>>> So I install pyenv first and then python 3.7 with it and set it to 
>>>>>>>>> the default.
>>>>>>>>>
>>>>>>>>> Then I install pipenv so that it uses the python 3.7 as its 
>>>>>>>>> default.
>>>>>>>>>
>>>>>>>>> Then I activate the virtual environment  with *pipenv shell* and 
>>>>>>>>> then run *python web2py/web2py.py -a pwd -p 7000*.
>>>>>>>>>
>>>>>>>>> To get the web2py shell, I run *python web2py/web2py.py -S init*
>>>>>>>>>
>>>>>>>>> I pretty much got the same results -- see below
>>>>>>>>>
>>>>>>>>> I actually have. I'm running a virtual environment with Pipenv.
>>>&

Re: [web2py] Why am I getting "unable to import requests" in web2py even though requests is accessible directly through python

2023-05-27 Thread Tom Clerckx
With pyenv itself it goes OK, it's only when using a pyenv-virtualenv that 
things fail.
I tried on two different machines.

Newly created pyenv (3.10.6)
Newly  created virtualenv
Newly unzipped web2py directory (2.24.1)

Same result.
When launching the web2py-shell in the virtualenv, the import fails.

Have you also tried with a virtualenv?

Regards,
Tom.



On Saturday, May 27, 2023 at 2:38:28 PM UTC+2 Massimiliano wrote:

> I'm also using pyenv and having the same paths order, ma importing 
> requests is working with no problem, on macos and on linux.
>
> Have you already tried to get rid of all pyc files and or to uninstall and 
> reinstall requests?
>
> Il giorno sab 27 mag 2023 alle ore 14:20 Tom Clerckx  
> ha scritto:
>
>> See below. In both tests the requests library is in the last element of 
>> the path.
>>
>> TEST1, plain python shell - import OK
>>
>> (test) tclerckx@stark:~/temp/test$ python
>> Python 3.10.6 (main, Jan 14 2023, 23:48:13) [GCC 11.3.0] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import requests
>> >>> requests.__file__
>>
>> '/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages/requests/__init__.py'
>> >>> import sys
>> >>> sys.path
>> ['', '/home/tclerckx/.pyenv/versions/3.10.6/lib/python310.zip', 
>> '/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10', 
>> '/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10/lib-dynload', 
>> '/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages']
>> >>> 
>>
>> TEST2, python web2py shell - import FAILS
>>
>> (test) tclerckx@stark:~/temp/test/web2py$ python web2py.py -S welcome -M 
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2023
>> Version 2.24.1-stable+timestamp.2023.03.23.05.07.17
>> Database drivers available: sqlite3, imaplib, pymysql
>> WARNING:web2py:import IPython error; use default python shell
>> Python 3.10.6 (main, Jan 14 2023, 23:48:13) [GCC 11.3.0] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>> import requests
>> Traceback (most recent call last):
>>   File "/home/tclerckx/temp/test/web2py/gluon/custom_import.py", line 78, 
>> in custom_importer
>> result = sys.modules[modules_prefix]
>> KeyError: 'applications.welcome.modules.requests'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "/home/tclerckx/temp/test/web2py/gluon/custom_import.py", line 80, 
>> in custom_importer
>> raise ImportError("No module named %s" % modules_prefix)
>> ImportError: No module named applications.welcome.modules.requests
>> >>> import sys
>> >>> sys.path
>> ['', '/home/tclerckx/temp/test/web2py/site-packages', 
>> '/home/tclerckx/temp/test/web2py', 
>> '/home/tclerckx/temp/test/web2py/gluon/packages/yatl', 
>> '/home/tclerckx/temp/test/web2py/gluon/packages/dal', 
>> '/home/tclerckx/.pyenv/versions/3.10.6/lib/python310.zip', 
>> '/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10', 
>> '/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10/lib-dynload', 
>> '/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages']
>> >>> 
>>
>> On Saturday, May 27, 2023 at 12:11:19 PM UTC+2 Massimiliano wrote:
>>
>>> Maybe one thing you can do is to launch web2py shell and check paths.
>>>
>>> ./web2py.py -S  
>>>
>>> import sys
>>> print(sys.path)
>>>
>>>
>>>
>>>
>>> Il giorno ven 26 mag 2023 alle ore 16:02 vald...@gmail.com <
>>> vald...@gmail.com> ha scritto:
>>>
>>>> <https://stackoverflow.com/posts/76341290/timeline>
>>>>
>>>> Asked this one on SO here 
>>>> <https://stackoverflow.com/questions/76341290/unable-to-import-requests-in-web2py-even-though-requests-is-accessible-directl>
>>>>  
>>>> as I was just reminded of how much nicer this community tends to be to 
>>>> newb 
>>>> questions.
>>>>
>>>> I'm attempting to integrate MSAL which requires the requests module.
>>>>
>>>> I'm running python 3.7 on Linux and using pipenv to manage the 
>>>> environment. I'm also using web2py 2.24.1 from source (as in I downloa

Re: [web2py] Why am I getting "unable to import requests" in web2py even though requests is accessible directly through python

2023-05-27 Thread Tom Clerckx
See below. In both tests the requests library is in the last element of the 
path.

TEST1, plain python shell - import OK

(test) tclerckx@stark:~/temp/test$ python
Python 3.10.6 (main, Jan 14 2023, 23:48:13) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__file__
'/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages/requests/__init__.py'
>>> import sys
>>> sys.path
['', '/home/tclerckx/.pyenv/versions/3.10.6/lib/python310.zip', 
'/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10', 
'/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10/lib-dynload', 
'/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages']
>>> 

TEST2, python web2py shell - import FAILS

(test) tclerckx@stark:~/temp/test/web2py$ python web2py.py -S welcome -M 
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2023
Version 2.24.1-stable+timestamp.2023.03.23.05.07.17
Database drivers available: sqlite3, imaplib, pymysql
WARNING:web2py:import IPython error; use default python shell
Python 3.10.6 (main, Jan 14 2023, 23:48:13) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import requests
Traceback (most recent call last):
  File "/home/tclerckx/temp/test/web2py/gluon/custom_import.py", line 78, 
in custom_importer
result = sys.modules[modules_prefix]
KeyError: 'applications.welcome.modules.requests'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/tclerckx/temp/test/web2py/gluon/custom_import.py", line 80, 
in custom_importer
raise ImportError("No module named %s" % modules_prefix)
ImportError: No module named applications.welcome.modules.requests
>>> import sys
>>> sys.path
['', '/home/tclerckx/temp/test/web2py/site-packages', 
'/home/tclerckx/temp/test/web2py', 
'/home/tclerckx/temp/test/web2py/gluon/packages/yatl', 
'/home/tclerckx/temp/test/web2py/gluon/packages/dal', 
'/home/tclerckx/.pyenv/versions/3.10.6/lib/python310.zip', 
'/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10', 
'/home/tclerckx/.pyenv/versions/3.10.6/lib/python3.10/lib-dynload', 
'/home/tclerckx/.pyenv/versions/test/lib/python3.10/site-packages']
>>> 

On Saturday, May 27, 2023 at 12:11:19 PM UTC+2 Massimiliano wrote:

> Maybe one thing you can do is to launch web2py shell and check paths.
>
> ./web2py.py -S  
>
> import sys
> print(sys.path)
>
>
>
>
> Il giorno ven 26 mag 2023 alle ore 16:02 vald...@gmail.com <
> vald...@gmail.com> ha scritto:
>
>> 
>>
>> Asked this one on SO here 
>> 
>>  
>> as I was just reminded of how much nicer this community tends to be to newb 
>> questions.
>>
>> I'm attempting to integrate MSAL which requires the requests module.
>>
>> I'm running python 3.7 on Linux and using pipenv to manage the 
>> environment. I'm also using web2py 2.24.1 from source (as in I download the 
>> web2py framework via the source button on the web2py website).
>>
>> When I am in pipenv shell and go into the python shell, I can access the 
>> requests, however when I try to access it from web2py (running in same 
>> shell), I get the "module not found" error.
>>
>> When I check the site-packages folder the requests packages is present. I 
>> have checked the pythonpath and seen that the path from the virtual 
>> environment is present.
>>
>> When attempting to load the web2py python shell, it gives the same error.
>>
>> I'm probably missing something, but it sometimes appears as if web2py 
>> does some code compilation and then uses the compiled stuff and ignores 
>> code changes after a certain point. Asking as I have commented out all the 
>> code involving the requests module in an effort to get the web2py shell 
>> working, but still get the error and now the entire app is not working even 
>> on the master branch which was previously working.
>>
>> Not sure what to try next. Any ideas are appreciated.
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/83b8a4ab-120a-4106-83f2-d37652c23093n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Massimiliano
>

-- 
Resources:
- http://web2py.com
- 

[web2py] Re: Why am I getting "unable to import requests" in web2py even though requests is accessible directly through python

2023-05-26 Thread Tom Clerckx
Good point, I'm curious as well.

I did a few experiments and I noticed that:

Running a virtualenv built on python *2.7.18* and using web2py (python2 
version) "Version 2.24.1-stable+timestamp.2023.03.23.05.07.17", the import 
goes *OK *within a web2py shell.
Running a virtualenv built on python *3.10.10* and using web2py (python3 
version) "Version 2.24.1-stable+timestamp.2023.03.23.05.07.17", the import 
*FAILS *within a web2py shell*.*

In both cases the import of the requests library works fine when running 
just the python interpreter.



On Friday, May 26, 2023 at 4:02:36 PM UTC+2 vald...@gmail.com wrote:

> 
>
> Asked this one on SO here 
> 
>  
> as I was just reminded of how much nicer this community tends to be to newb 
> questions.
>
> I'm attempting to integrate MSAL which requires the requests module.
>
> I'm running python 3.7 on Linux and using pipenv to manage the 
> environment. I'm also using web2py 2.24.1 from source (as in I download the 
> web2py framework via the source button on the web2py website).
>
> When I am in pipenv shell and go into the python shell, I can access the 
> requests, however when I try to access it from web2py (running in same 
> shell), I get the "module not found" error.
>
> When I check the site-packages folder the requests packages is present. I 
> have checked the pythonpath and seen that the path from the virtual 
> environment is present.
>
> When attempting to load the web2py python shell, it gives the same error.
>
> I'm probably missing something, but it sometimes appears as if web2py does 
> some code compilation and then uses the compiled stuff and ignores code 
> changes after a certain point. Asking as I have commented out all the code 
> involving the requests module in an effort to get the web2py shell working, 
> but still get the error and now the entire app is not working even on the 
> master branch which was previously working.
>
> Not sure what to try next. Any ideas are appreciated.
>

-- 
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/3560a15f-32d4-4e2c-9738-036b435d38aan%40googlegroups.com.


[web2py] Re: Web2py deployment on a local so all computers in the network can acess it

2022-08-24 Thread Tom Clerckx
Not sure what information you're looking for.
There is no dependency on having an internet connection to deploy your 
web2py service.

With respect to deployment itself, you can follow the deployment recipes in 
the web2py manual.

Tom.

On Wednesday, August 24, 2022 at 11:49:13 AM UTC+2 silvia...@gmail.com 
wrote:

> I would like to deploy web2py on a local server but I dont know what to do 
> exactly it will be the local server will not be connected to the Internet 
> so it will be more used as an intranet. Would be great if someone can help 
> me out.

-- 
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/b5c25d33-c7ea-48f2-817f-de9fdaac9255n%40googlegroups.com.


[web2py] Re: Bug in gluon/scheduler.py

2022-08-20 Thread Tom Clerckx
Our tasks are added using scheduler.queue_task(...) function.

By default, we set the period to 0 
Later on we added to the defaults : prevent_drift = True

It's this last change that triggered the observed error.







On Friday, August 19, 2022 at 12:49:05 PM UTC+2 snide...@gmail.com wrote:

> On Monday, August 8, 2022 at 3:50:26 AM UTC-7 Tom Clerckx wrote:
>
>> Version:
>> Version 2.22.5-stable+timestamp.2022.06.04.18.13.51
>>
>> There is a problem with the calculation of next_run_time in 
>> gluon/scheduler.py at line 1024
>>
>> It calculates:
>> steps = secondspassed // task.period + 1
>>
>> However, there is no check done for task.period being 0
>>
>> This can cause the following scheduler error:
>> ZeroDivisionError: float divmod()
>>
>> I think it would be better to initialize next_run_time and change the 
>> last else condition to "elif task.period".
>>
>
> How did you get task.period == 0?
>
> I'm wondering if this is a valid use-case; the scheduler has quite a test 
> suite.
>
> /dps
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/26297db5-d87a-4810-bcaf-bb8711edbf0dn%40googlegroups.com.


[web2py] Bug in gluon/scheduler.py

2022-08-08 Thread Tom Clerckx
Version:
Version 2.22.5-stable+timestamp.2022.06.04.18.13.51

There is a problem with the calculation of next_run_time in 
gluon/scheduler.py at line 1024

It calculates:
steps = secondspassed // task.period + 1

However, there is no check done for task.period being 0

This can cause the following scheduler error:
ZeroDivisionError: float divmod()

I think it would be better to initialize next_run_time and change the last 
else condition to "elif task.period".

-- 
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/0dafdff8-a64b-47a9-8e5b-98336517a296n%40googlegroups.com.


[web2py] About migrate and fake_migrate

2022-03-16 Thread Tom Clerckx
I was a bit confused about the explanation of the fake_migrate option in 
the web2py documentation. After some experimenting, I wrote up the 
following information for myself, just sharing it here with you. Maybe 
someone can merge this information in the web2py documentation, if you 
think it contributes to making this topic more clear.
--

The explanation here assumes sqlite as a database, but I believe holds also 
for other databases.

When changing a model, e.g. adding a field there are two places where 
information is updated.

   - In the database-metadata files. These files are located in the 
   database folder. For each table a metadata file is created. If you want to 
   inspect these files, you can inspect them by unpickling them
   

   - In the database.sqlite file. This is the database itself.The new field 
   will be added to the sqlite schema
   
The database parameter *migrate* (=True by default) pushes changes that are 
made in your model back into the meta-data file and in the sqlite file.
Another option *fake_migrate* (=False by default) pushes changes that are 
made in your model back into the meta-data file, *but not in the sqlite 
database file.*
Note also that this option will only push new Fields back into the 
meta-data file. *It does not remove fields from the metadata file that you 
may have removed in your model!!*

For each field described in your model (and thus also in the metadata 
file), you should have a corresponding element in the sqlite schema.
If that is not the case, you can have one of two errors:
Error 1: 
The field is present in the sqlite database, it also exists in your model 
file, but for some reason it does not exist in the metadata file. Because 
it is defined in the model and it is not yet present in the metadata file, 
web2py wants to create it by doing a migrate.
This migrate, includes updating both the metadata file *and* the sqlite 
schema. The problem however, is that in the sqlite schema, this field 
already exists!
This will cause an error similar as:
*sqlite3.OperationalError: duplicate column name: blablabla*
Solution:
We can fix this by telling web2py to do a 'fake_migrate'.
This is done by adding the parameter *fake_migrate=True* in the table 
definition.
By doing a fake migrate, web2py will only update the metadata file and NOT 
the sqlite database. As such, the fields in the database and in the 
metadata file will get back in sync.
*It is important* to remove the fake_migrate parameter again after the data 
sources are back in sync!

Error 2: 
The field is in the metadata file, it also exists in your model file, but 
for some reason it does not exist in the sqlite schema. Because it is 
defined in the model and in the metadata file, web2py will try to load this 
field from the database.
But because it is not defined in the database, you will get an error such 
as:
*sqlite3.OperationalError: no such column: person.blablabla*
Solution 2:
In this case we cannot do the fake-migrate directly, because the 
fake-migrate option can add the new fields to the metadata file, but it 
won't push the field to the database. So what we should do is:

   1. First remove again the field in question from our model.
   2. Set the fake_migrate=True option
   3. Remove the meta-data file (keep a backup of it elsewhere, just to 
   make sure)
   4. Reload the database (e.g. by doing a screen refresh in the page where 
   you use the table in question)... this will recreate the meta-data file 
   based on your current model.
   5. Set fake_migrate=False (or just remove it, as False is the default 
   value)
   6. Put back the field in question in the model 
   7. Reload the database once more
   8. By reloading the database, web2py will now push the new field again 
   in the metadatafile and it will also update the sqlite schema. Now all data 
   is back in sync.
   

Sidenote: Why you should not have fake_migrate=True in a normal situation
If you would leave fake_migrate=True, you would actually cause Error 2 
above to happen when you add a new field to your table, because in that 
case the new field
is only committed to the metadata-file and not to the sqlite database.

-- 
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/eeaa9cc2-c759-4ecf-819e-09cc658fe007n%40googlegroups.com.


[web2py] Re: Why web2py App performance has degraded all of sudden with SQLLITE

2021-11-08 Thread Tom Clerckx
Hi Sandeep,

A bit a late reply, but it may be useful for someone later-on.

I recently had the exact same issue, quite suddenly, things started to 
become slow.
Here's what I did to solve it:

*First thing to do:* make a backup of your project!

*Second thing* to do is to vacuum your db, which does some optimizations 
that gets rid of some garbage in your db.
You can just do:   db.executesql('VACUUM') 

Ref: https://www.sqlite.org/lang_vacuum.html

*Third thing* you can do is to:
0) Make sure all your tables have a uuid field 
1) Export all your data to a csv file: 
with open('somefile.csv', 'wb') as dumpfile: db.export_to_csv_file(dumpfile)
2) Remove your db tables
3) Import again all your data from the csv file: 
with open('somefile.csv', 'rb') as dumpfile: 
db.import_from_csv_file(dumpfile, id_map={})

Ref: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV-all-tables-at-once-

In my case the export/import of the data finally did the trick.
I'm still not sure why this seems to speed up everything, maybe someone in 
this forum here has a good explanation for that?
Hope it works for you too!

On Saturday, May 2, 2020 at 12:57:27 PM UTC+2 eudor...@gmail.com wrote:

> Hi Sandeep,
>
> Would be good if you can supply a bit more information in order to help 
> you find the solution.
>
> questions:
> 1: Has your database grown recently?
> 2: Is web2py slow on all queries or just on some tables? 
> 3: Can you use _lasesql to see your sql calls and timings?
> 4: Are you using SQLFORM.grid or custom forms to do your queries?
> 5: Some genric idea of what you are trying to do?
>
> BR
> John 
>
>
>
> On Saturday, 2 May 2020 12:20:44 UTC+2, Sandeep Bondre wrote:
>
>> I do not see a solution to this problem .
>>
>> Can some one really help what is the solution to this 
>>
>> Regards
>>
>> Sandeep
>>
> sandee...@gmail.com
>>
>

-- 
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/5b842cdb-d49f-4491-b761-246559334998n%40googlegroups.com.


[web2py] Re: SQLFORM.grid and user_signature - unexpected behavior

2021-05-24 Thread Tom Clerckx
Can someone confirm my reasoning... or correct it if it's wrong?

Thanks,
Tom.

On Monday, May 10, 2021 at 3:22:24 PM UTC+2 Tom Clerckx wrote:

> I was running into some issue with SQLFORM.grid and after going through 
> the code, I realized that the grid does not include request.vars when 
> calculating the URL signature (ref: v2.21.1, gluon/sqlhtml.py @ 2440). 
>
> Please correct me if I would be wrong,... else it may be useful to add 
> something about this behavior in the web2py documentation:
>
>
> SQLFORM.grid validates the signature without taking into account 
> request.vars
>
> As such, any constructed URL that contains a user_signature and that is 
> pointing to the page that uses the controller function which creates this 
> grid, should have this signature created without including request.vars! 
>
> Thus, hash_vars should be set to False in that case. If not, you may get a 
> ‘not authorized’ flash message and you will be redirected.
>
> E.g. a signed URL pointing to such page should look like:
>
> URL(‘mypage_with_grid’, args=[‘a’, ‘b’, ‘c’], vars={‘var1’:’val1’}, 
> *user_signature=True,* *hash_vars=False*)
>
>
>

-- 
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/b83b2d77-6f11-47ba-a382-5c7b07f3047en%40googlegroups.com.


[web2py] SQLFORM.grid and user_signature - unexpected behavior

2021-05-10 Thread Tom Clerckx
 

I was running into some issue with SQLFORM.grid and after going through the 
code, I realized that the grid does not include request.vars when 
calculating the URL signature (ref: v2.21.1, gluon/sqlhtml.py @ 2440). 

Please correct me if I would be wrong,... else it may be useful to add 
something about this behavior in the web2py documentation:


SQLFORM.grid validates the signature without taking into account 
request.vars

As such, any constructed URL that contains a user_signature and that is 
pointing to the page that uses the controller function which creates this 
grid, should have this signature created without including request.vars! 

Thus, hash_vars should be set to False in that case. If not, you may get a 
‘not authorized’ flash message and you will be redirected.

E.g. a signed URL pointing to such page should look like:

URL(‘mypage_with_grid’, args=[‘a’, ‘b’, ‘c’], vars={‘var1’:’val1’}, 
*user_signature=True,* *hash_vars=False*)


-- 
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/4de8ab7e-497a-4bc7-8ee8-872fec9ea49en%40googlegroups.com.


Re: [web2py] Re: Update dropdown list in SQLFORM.grid based on selection in another dropdown list

2020-11-25 Thread Tom Clerckx
Thanks for sharing this.

Best regards,
Tom.

On Wednesday, November 25, 2020 at 4:44:40 AM UTC+1 roge...@gmail.com wrote:

> Glad you got it working.
>
> I send javascript from my controller back to the view for some custom 
> control widgets. That sounds similar to what you want to do.
>
> I dont know where i found the original code sample to do that - not in the 
> book I dont think. This page 
> http://www.web2pyslices.com/slice/show/1446/widget-select-or-add-option 
> you will see an example of how it can be done. To be honest I dont fully 
> understand how the wrapper works. But i got some nice custom controls 
> working nonetheless :)
>
>
> def widget(self, field, value):
> #generate the standard widget for this field
> select_widget = OptionsWidget.widget(field, value)
>
> #get the widget's id (need to know later on so can tell receiving 
> controller what to update)
> my_select_id = select_widget.attributes.get('_id', None) 
> add_args = [my_select_id] 
> #create a div that will load the specified controller via ajax
> form_loader_div = DIV(LOAD(c=self.controller, f=self.function, 
> args=add_args,ajax=True), _id=my_select_id+"_dialog-form", 
> _title=self.form_title)
> #generate the "add" button that will appear next the options widget 
> and open our dialog
> activator_button = A(T(self.button_text), 
> _id=my_select_id+"_option_add_trigger")
> #create javascript for creating and opening the dialog
> js = '$( "#%s_dialog-form" ).dialog({autoOpen: false, show: "blind", 
> hide: "explode", width: %s});' % (my_select_id, self.dialog_width)
> js += '$( "#%s_option_add_trigger" ).click(function() { $( 
> "#%s_dialog-form" ).dialog( "open" );return false;}); ' % (my_select_id, 
> my_select_id)#decorate our activator button for good measure
> js += '$(function() { $( "#%s_option_add_trigger" ).button({text: 
> true, icons: { primary: "ui-icon-circle-plus"} }); });' % (my_select_id) 
> jq_script=SCRIPT(js, _type="text/javascript")
> wrapper = DIV(_id=my_select_id+"_adder_wrapper")
> wrapper.components.extend([select_widget, form_loader_div, 
> activator_button, jq_script])
> return wrapper
>
>
>
>
>
> ___
> *www.TenOutOfTen.org* <https://www.TenOutOfTen.org>
> roge...@gmail.com
> (+95) 09 250018669 <+95%209%20250%20018%20669> (Myanmar)
>
>
>
> On Fri, 20 Nov 2020 at 19:09, Tom Clerckx  wrote:
>
>> OK, I was able to do it with SQLFORM.grid(), using jQuery by:
>> * registering a change function on the #shelves_genre field
>> * execute an XMLHttpRequest upon a change of #shelves_genre that updates 
>> the innerHTML of #shelves_shelve_items
>>
>> It would be nice however if something similar (registering form-events 
>> onchange/onselect/...) could be achieved when e.g. creating the form, so 
>> that you can do it in python instead of having to add the javascript 
>> functions.
>>
>>
>>
>> On Friday, November 13, 2020 at 3:53:23 PM UTC+1 Tom Clerckx wrote:
>>
>>> Hi,
>>>
>>> Considering the sample code below.
>>> I have manually populated the books table with a number of books for 
>>> different genres.
>>> Now I can create an entry in the shelves table, using the SQLFORM.grid
>>> The shelve_items will be shown as a dropdown list with the books that 
>>> I've added
>>>
>>> What I would like is to update the contents of the shelve_items dropdown 
>>> list in the form, based on the selected genre in that same form.
>>>
>>> In the past I did something similar, using a SELECT() box and adding an 
>>> onchange=ajax(...) call to update a DIV elsewhere in the page.
>>>
>>> I was wondering however, if there is a better way to do this directly in 
>>> the SQLFORM.grid()
>>>
>>>
>>> ===
>>> index.html
>>> ===
>>> {{extend 'layout.html'}}
>>> {{=form}}
>>>
>>> ===
>>> default.py
>>> ===
>>>
>>> def index():
>>> form = SQLFORM.grid(db.shelves, user_signature=False)
>>> return dict(form=form)
>>>
>>> ==
>>> db.py
>>> ==
>>> genres = ['thriller', 'sf', 'roman', 'fantasy']
>>> db.define_table('books',
>>>   Field('name', 'string'),
>>>   Field('author',

[web2py] Re: Update dropdown list in SQLFORM.grid based on selection in another dropdown list

2020-11-20 Thread Tom Clerckx
OK, I was able to do it with SQLFORM.grid(), using jQuery by:
* registering a change function on the #shelves_genre field
* execute an XMLHttpRequest upon a change of #shelves_genre that updates 
the innerHTML of #shelves_shelve_items

It would be nice however if something similar (registering form-events 
onchange/onselect/...) could be achieved when e.g. creating the form, so 
that you can do it in python instead of having to add the javascript 
functions.



On Friday, November 13, 2020 at 3:53:23 PM UTC+1 Tom Clerckx wrote:

> Hi,
>
> Considering the sample code below.
> I have manually populated the books table with a number of books for 
> different genres.
> Now I can create an entry in the shelves table, using the SQLFORM.grid
> The shelve_items will be shown as a dropdown list with the books that I've 
> added
>
> What I would like is to update the contents of the shelve_items dropdown 
> list in the form, based on the selected genre in that same form.
>
> In the past I did something similar, using a SELECT() box and adding an 
> onchange=ajax(...) call to update a DIV elsewhere in the page.
>
> I was wondering however, if there is a better way to do this directly in 
> the SQLFORM.grid()
>
>
> ===
> index.html
> ===
> {{extend 'layout.html'}}
> {{=form}}
>
> ===
> default.py
> ===
>
> def index():
> form = SQLFORM.grid(db.shelves, user_signature=False)
> return dict(form=form)
>
> ==
> db.py
> ==
> genres = ['thriller', 'sf', 'roman', 'fantasy']
> db.define_table('books',
>   Field('name', 'string'),
>   Field('author', 'string'),
>   Field('genre', 'string', requires=IS_IN_SET(genres)),
>   format='%(name)s'
>   )
> db.define_table('shelves',
>   Field('genre', 'string', requires=IS_IN_SET(genres)),
>   Field('shelve_items', 'reference books'),
>   )
>
>

-- 
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/61c5b124-cf09-4df5-aa58-dd6589bc63b8n%40googlegroups.com.


[web2py] Update dropdown list in SQLFORM.grid based on selection in another dropdown list

2020-11-13 Thread Tom Clerckx
Hi,

Considering the sample code below.
I have manually populated the books table with a number of books for 
different genres.
Now I can create an entry in the shelves table, using the SQLFORM.grid
The shelve_items will be shown as a dropdown list with the books that I've 
added

What I would like is to update the contents of the shelve_items dropdown 
list in the form, based on the selected genre in that same form.

In the past I did something similar, using a SELECT() box and adding an 
onchange=ajax(...) call to update a DIV elsewhere in the page.

I was wondering however, if there is a better way to do this directly in 
the SQLFORM.grid()


===
index.html
===
{{extend 'layout.html'}}
{{=form}}

===
default.py
===

def index():
form = SQLFORM.grid(db.shelves, user_signature=False)
return dict(form=form)

==
db.py
==
genres = ['thriller', 'sf', 'roman', 'fantasy']
db.define_table('books',
  Field('name', 'string'),
  Field('author', 'string'),
  Field('genre', 'string', requires=IS_IN_SET(genres)),
  format='%(name)s'
  )
db.define_table('shelves',
  Field('genre', 'string', requires=IS_IN_SET(genres)),
  Field('shelve_items', 'reference books'),
  )

-- 
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/64655170-786e-4d3d-bd39-6d2fa75f89c5n%40googlegroups.com.


[web2py] Re: web2py scripts (homemade task queues) and python2 compatibility

2019-07-16 Thread Tom Clerckx
That's clear, thanks for the update.

On Tuesday, July 16, 2019 at 6:48:41 PM UTC+2, Leonel Câmara wrote:
>
> You're right, you must use the print function because web2py now has a "
> from __future__ import print_function" which forces you to use the print 
> function even in python2
>

-- 
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/c3d5b073-7ea9-4f03-9e3d-fba8b9c329af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] web2py scripts (homemade task queues) and python2 compatibility

2019-07-11 Thread Tom Clerckx
Anyone else that can shed some light on this?

On Friday, July 5, 2019 at 3:01:11 PM UTC+2, Tom Clerckx wrote:
>
> Hi Nico,
>
> I tried explicitly with python2.7, by executing: 
> python2.7 web2py.py -S examples -M -R 
> applications/examples/private/script01.py
>
> On a fresh downloaded version of web2py.
> Same result.
>
> In web2py/gluon/shell.py, I notice the following first line:
> from __future__ import print_function
>
> Funny enough, it's only trough an external script that I'm getting this 
> error.
> Using the print statement in a controller function, everything works as 
> expected.
> So I believe it's only when running an 'external' script 
> through web2py/gluon/shell.py that the print() function must be used.
>
> Or am I missing something/making a mistake?
>
> Best, Tom.
>
>
> On Thursday, July 4, 2019 at 10:45:30 PM UTC+2, Nico Zanferrari wrote:
>>
>> Hi Tom,
>>
>> even the latest  2.18.5 version of web2py is still fully compatible with 
>> Python 2.7.
>>
>> I think you're running both of your tests with python 3 ;-) 
>> Another possibility is that you've first run your web2py framework with 
>> python 3 and then with python 2 -  you cannot mix them without cleaning up 
>> caches and dbs... Try test02 a fresh copy of the web2py sources, after 
>> being sure to use python2!
>>
>> Nico
>>
>> Il giorno gio 4 lug 2019 alle ore 17:41 Tom Clerckx  
>> ha scritto:
>>
>>> Can anyone confirm that backward compatibility with python2 is broken 
>>> with respect to web2py scripts (or homemade task queueus)?
>>> I just downloaded version "2.18.5-stable+timestamp.2019.04.08.04.22.03" 
>>> and it looks like the python3 print() function must be used.
>>>
>>> Is there any plan to fix this? If not, it would be good to include this 
>>> information in the web2py book.
>>>
>>>
>>> Test01:
>>> =
>>> script "applications/examples/scrips/script01.py" containing only one 
>>> line:
>>> print("Test print")
>>>
>>> This one executes fine when running:
>>> python web2py.py -S examples -M -R 
>>> applications/examples/scrips/script01.py
>>>
>>>
>>> Test02:
>>> ==
>>> script "applications/examples/scrips/script01.py" containing only one 
>>> line:
>>> print "Test print"
>>>
>>> This one fails fine when running:
>>> python web2py.py -S examples -M -R 
>>> applications/examples/scrips/script01.py
>>>
>>> Traceback (most recent call last):
>>>   File "/home/tclerckx/Downloads/web2py/gluon/shell.py", line 275, in run
>>> execfile(startfile, _env)
>>>   File "applications/examples/scrips/script01.py", line 1
>>> print "Test print"
>>>  ^
>>> SyntaxError: invalid syntax
>>>
>>> -- 
>>> 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 web...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/web2py/4c095bb7-1cd8-47a2-9b71-94a735dd5681%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/web2py/4c095bb7-1cd8-47a2-9b71-94a735dd5681%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/cfd586b7-89dd-4a17-a16e-e65abd9a1c4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] web2py scripts (homemade task queues) and python2 compatibility

2019-07-05 Thread Tom Clerckx
Hi Nico,

I tried explicitly with python2.7, by executing: 
python2.7 web2py.py -S examples -M -R 
applications/examples/private/script01.py

On a fresh downloaded version of web2py.
Same result.

In web2py/gluon/shell.py, I notice the following first line:
from __future__ import print_function

Funny enough, it's only trough an external script that I'm getting this 
error.
Using the print statement in a controller function, everything works as 
expected.
So I believe it's only when running an 'external' script 
through web2py/gluon/shell.py that the print() function must be used.

Or am I missing something/making a mistake?

Best, Tom.


On Thursday, July 4, 2019 at 10:45:30 PM UTC+2, Nico Zanferrari wrote:
>
> Hi Tom,
>
> even the latest  2.18.5 version of web2py is still fully compatible with 
> Python 2.7.
>
> I think you're running both of your tests with python 3 ;-) 
> Another possibility is that you've first run your web2py framework with 
> python 3 and then with python 2 -  you cannot mix them without cleaning up 
> caches and dbs... Try test02 a fresh copy of the web2py sources, after 
> being sure to use python2!
>
> Nico
>
> Il giorno gio 4 lug 2019 alle ore 17:41 Tom Clerckx  > ha scritto:
>
>> Can anyone confirm that backward compatibility with python2 is broken 
>> with respect to web2py scripts (or homemade task queueus)?
>> I just downloaded version "2.18.5-stable+timestamp.2019.04.08.04.22.03" 
>> and it looks like the python3 print() function must be used.
>>
>> Is there any plan to fix this? If not, it would be good to include this 
>> information in the web2py book.
>>
>>
>> Test01:
>> =
>> script "applications/examples/scrips/script01.py" containing only one 
>> line:
>> print("Test print")
>>
>> This one executes fine when running:
>> python web2py.py -S examples -M -R 
>> applications/examples/scrips/script01.py
>>
>>
>> Test02:
>> ==
>> script "applications/examples/scrips/script01.py" containing only one 
>> line:
>> print "Test print"
>>
>> This one fails fine when running:
>> python web2py.py -S examples -M -R 
>> applications/examples/scrips/script01.py
>>
>> Traceback (most recent call last):
>>   File "/home/tclerckx/Downloads/web2py/gluon/shell.py", line 275, in run
>> execfile(startfile, _env)
>>   File "applications/examples/scrips/script01.py", line 1
>> print "Test print"
>>  ^
>> SyntaxError: invalid syntax
>>
>> -- 
>> 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 web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/4c095bb7-1cd8-47a2-9b71-94a735dd5681%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/4c095bb7-1cd8-47a2-9b71-94a735dd5681%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e3cb8b21-1708-47bd-a776-4d594b432a46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py scripts (homemade task queues) and python2 compatibility

2019-07-04 Thread Tom Clerckx
Can anyone confirm that backward compatibility with python2 is broken with 
respect to web2py scripts (or homemade task queueus)?
I just downloaded version "2.18.5-stable+timestamp.2019.04.08.04.22.03" and 
it looks like the python3 print() function must be used.

Is there any plan to fix this? If not, it would be good to include this 
information in the web2py book.


Test01:
=
script "applications/examples/scrips/script01.py" containing only one line:
print("Test print")

This one executes fine when running:
python web2py.py -S examples -M -R applications/examples/scrips/script01.py


Test02:
==
script "applications/examples/scrips/script01.py" containing only one line:
print "Test print"

This one fails fine when running:
python web2py.py -S examples -M -R applications/examples/scrips/script01.py

Traceback (most recent call last):
  File "/home/tclerckx/Downloads/web2py/gluon/shell.py", line 275, in run
execfile(startfile, _env)
  File "applications/examples/scrips/script01.py", line 1
print "Test print"
 ^
SyntaxError: invalid syntax

-- 
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/4c095bb7-1cd8-47a2-9b71-94a735dd5681%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Compile controller and module files only

2017-10-09 Thread Tom Clerckx
Update:
It works fine on the latest web2py release - that works for me.

Thanks.


On Monday, October 9, 2017 at 10:26:20 AM UTC+2, Tom Clerckx wrote:
>
> That does not seem to work for me  I'm getting an "invalid view" error 
> after removing the compiled view files
>
> FYI, I'm runnning version 
>
> 2.9.5-stable+timestamp.2014.03.16.02.35.39
>
> On Friday, October 6, 2017 at 4:23:53 PM UTC+2, Anthony wrote:
>>
>> On Friday, October 6, 2017 at 4:10:57 AM UTC-4, Tom Clerckx wrote:
>>>
>>> Is it possible to compile an application, but keep the views and the CSS 
>>> 'uncompiled'?
>>> The idea is that other people can change the look and feel without 
>>> having access to the code of the controllers and the models.
>>>
>>
>> Sure, just compile that app and delete all the compiled view files. CSS 
>> files aren't compiled, so no need to do anything with them.
>>
>> Anthony
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Compile controller and module files only

2017-10-09 Thread Tom Clerckx
That does not seem to work for me  I'm getting an "invalid view" error 
after removing the compiled view files

FYI, I'm runnning version 

2.9.5-stable+timestamp.2014.03.16.02.35.39

On Friday, October 6, 2017 at 4:23:53 PM UTC+2, Anthony wrote:
>
> On Friday, October 6, 2017 at 4:10:57 AM UTC-4, Tom Clerckx wrote:
>>
>> Is it possible to compile an application, but keep the views and the CSS 
>> 'uncompiled'?
>> The idea is that other people can change the look and feel without having 
>> access to the code of the controllers and the models.
>>
>
> Sure, just compile that app and delete all the compiled view files. CSS 
> files aren't compiled, so no need to do anything with them.
>
> 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] Compile controller and module files only

2017-10-06 Thread Tom Clerckx
Is it possible to compile an application, but keep the views and the CSS 
'uncompiled'?
The idea is that other people can change the look and feel without having 
access to the code of the controllers and the models.

Best regards,
Tom.

-- 
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] Suggestion to add in documantation about reference fields

2017-05-24 Thread Tom Clerckx
The web2py documentation indicates that a reference field has the following 
default validator:
IS_IN_DB(db, table.field, format)

I suggest the default validator to be described as:
IS_IN_DB(db, table._id, table._format)

If you use any other field besides *table._id* in the validator, this 
causes errors when trying to insert a new row (e.g. via the admin interface)
Maybe it is worth indicating that when -for whatever reason- you want to 
change the validator, you must refer back to the *id* and not to another 
field of the referring table?

Or am I wrong in this reasoning?

-- 
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] Documentation: update requires writable=False

2015-10-15 Thread Tom Clerckx
Today I was struggling with why the following did not work for me in one of 
my tables:

Field('modified_on', 'datetime', default=request.now, update=request.now)


After some fiddling I found that writable=False must be explicitly added for 
this to work properly.


--> Field('modified_on', 'datetime', default=request.now, update=request.now, 
writable=False)


I understand that it does not make sense to have writable=True when you added 
update=... to a field (same counts if you use compute), but I believe it does 
make sense to add this in the documentation (in the DAL chapter describing the 
Field constructor) - just so other people don't waste time figuring this out.


Best regards,

Tom.

-- 
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: Team of admin/devellopers with different permissions

2015-03-28 Thread Tom Clerckx
You can always create multiple instances of web2py (each with their own 
applications directory).
But for developers, wouldn't it be easier if they just have there local 
version of web2py and the application they're working on and use 
subversion/git/or any other version control system to check in updates?

Best regards,
Tom.

On Thursday, March 26, 2015 at 12:04:24 AM UTC+1, Ramos wrote:

 First web2py admin/developer are the same.
 Should it be?

 Also 
 my server can get crowded in the future with one or more developers. As i 
 have some apps i dont to share with then, how can i limit their access.

 Thank u


-- 
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: import_from_csv_file and id_map={}

2015-03-17 Thread Tom Clerckx
Thanks.

I will try to make some time and contribute in that way.

Note:
You may want to update the link to your profile 
on http://web2py.com/init/default/who
-- it results in a page not found.

Best regards,
Tom.

On Wednesday, March 11, 2015 at 7:07:04 PM UTC+1, Tom Clerckx wrote:

 I recently learned (by searching through the google-group) the usefulness 
 of the id_map={} parameter in the db.import_from_csv_file function.
 I was wondering why this is not included in the documentation of web2py?

 Is this on the 'todo' list or is there another reason why it is not 
 included?

 Best regards,
 Tom.


-- 
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] import_from_csv_file and id_map={}

2015-03-11 Thread Tom Clerckx
I recently learned (by searching through the google-group) the usefulness 
of the id_map={} parameter in the db.import_from_csv_file function.
I was wondering why this is not included in the documentation of web2py?

Is this on the 'todo' list or is there another reason why it is not 
included?

Best regards,
Tom.

-- 
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] TV Centric websites

2014-07-11 Thread Tom Clerckx
Hi all,

I've been working with web2py for a few months now and I must say: I'm a 
big fan.
Nowadays, I'm looking more into building TV-centric sites and I was 
wondering if this is/will be supported in web2py.

I'm talking about websites that you can directly load on the browser of a 
TV or set top box and that are designed for the TV set.

Good examples of such site are:
http://gtv.uinterview.com/
http://www.nytimes.com/gtv/

It's important that the UI is made to run full-screen and the navigation 
can be done using solely arrow-keys and the enter key (which map to the 
remote control arrow-keys and OK key)

If this is/will be supported I would be very interested.
Other suggestions are very welcome as well.

Best regards,
Tom.

-- 
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: Undesired redirect to other page after submitting a form

2014-06-26 Thread Tom Clerckx
Sorry being persistent on this, but has somebody any idea why the observed 
behavior is in place?


Best regards,
Tom.

On Thursday, June 19, 2014 9:46:06 AM UTC+2, Tom Clerckx wrote:

 Hi,

 I have some undesired behavior in my app that I was able to resolve, but I 
 would like to understand what goes wrong.
 I could easily reproduce the problem with a simple test-application, 
 containing two pages and two forms (I'm skipping the boilerplate code that 
 is created when making a new application):

 menu.py
 response.menu = [
 (T('Home'), False, URL('default', 'index'), []),
 (T('Secondpage'), False, URL('default', 'secondpage'), []),
 ]

 controller
 def index():
 form = SQLFORM.grid(db.contact, create=True, user_signature=False, )
 return dict(form=form)

 def secondpage():
 form = SQLFORM.grid(db.activity, create=True, user_signature=False, )
 return dict(form=form)

 index.html
 {{extend 'layout.html'}}
 h1Index page/h1
 {{=form}}

 secondpage.html
 {{extend 'layout.html'}}
 h1Welcome to the 2nd page/h1
 {{=form}}

 db.py
 contact = db.define_table('contact',
   Field('first_name', 'string'),
   Field('last_name', 'string'),
   )
 
 activity = db.define_table('activity',
 Field('what_you_plan_to_do', 'string'),
 )

 The problem occurs as follows:

 * I go to the index page
 * I press the add button opening up the contacts form (which I don't fill 
 in at this point)
 * In the menu I now press the link to the secondpage
 * When the secondpage is loaded I press the browser's back-button
 * Now I see the contacts form again which I fill in
 * When I now press the Submit button, I am redirected to the secondpage as 
 opposed to staying on the index page, which is not the desired outcome.

 I could resolve this by giving the forms a formname, but I would like to 
 understand why this behavior occurs.
 In this specific example the undesired behavior is not critical, but it 
 was really a problem in my app as the redirect went to a .load page that 
 did not contain any css styling.


 Updated controller resolving the problem
 def index():
 form = SQLFORM.grid(db.contact, create=True, user_signature=False, 
 formname='contact')
 return dict(form=form)

 def secondpage():
 form = SQLFORM.grid(db.activity, create=True, user_signature=False, 
 formname='activity')
 return dict(form=form)


 web2py version info
 2.8.2-stable+timestamp.2013.11.28.13.54.07
 (Running on Rocket 1.2.6, Python 2.7.5)


 Thanks!


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Undesired redirect to other page after submitting a form

2014-06-23 Thread Tom Clerckx
Anyone has observed this as well?
Is this expected behavior?

I understood the importance of giving a formname when you're dealing with 
two grids on one single  page.

This however concerns one single grid per page in which case I believe the 
formname is not required. 
It looks however that the link associated to the redirect after submitting 
a form is influenced by using the browser's back-button in the case when no 
formname paramater is used in the grid.

Best regards,
Tom.

On Thursday, June 19, 2014 9:46:06 AM UTC+2, Tom Clerckx wrote:

 Hi,

 I have some undesired behavior in my app that I was able to resolve, but I 
 would like to understand what goes wrong.
 I could easily reproduce the problem with a simple test-application, 
 containing two pages and two forms (I'm skipping the boilerplate code that 
 is created when making a new application):

 menu.py
 response.menu = [
 (T('Home'), False, URL('default', 'index'), []),
 (T('Secondpage'), False, URL('default', 'secondpage'), []),
 ]

 controller
 def index():
 form = SQLFORM.grid(db.contact, create=True, user_signature=False, )
 return dict(form=form)

 def secondpage():
 form = SQLFORM.grid(db.activity, create=True, user_signature=False, )
 return dict(form=form)

 index.html
 {{extend 'layout.html'}}
 h1Index page/h1
 {{=form}}

 secondpage.html
 {{extend 'layout.html'}}
 h1Welcome to the 2nd page/h1
 {{=form}}

 db.py
 contact = db.define_table('contact',
   Field('first_name', 'string'),
   Field('last_name', 'string'),
   )
 
 activity = db.define_table('activity',
 Field('what_you_plan_to_do', 'string'),
 )

 The problem occurs as follows:

 * I go to the index page
 * I press the add button opening up the contacts form (which I don't fill 
 in at this point)
 * In the menu I now press the link to the secondpage
 * When the secondpage is loaded I press the browser's back-button
 * Now I see the contacts form again which I fill in
 * When I now press the Submit button, I am redirected to the secondpage as 
 opposed to staying on the index page, which is not the desired outcome.

 I could resolve this by giving the forms a formname, but I would like to 
 understand why this behavior occurs.
 In this specific example the undesired behavior is not critical, but it 
 was really a problem in my app as the redirect went to a .load page that 
 did not contain any css styling.


 Updated controller resolving the problem
 def index():
 form = SQLFORM.grid(db.contact, create=True, user_signature=False, 
 formname='contact')
 return dict(form=form)

 def secondpage():
 form = SQLFORM.grid(db.activity, create=True, user_signature=False, 
 formname='activity')
 return dict(form=form)


 web2py version info
 2.8.2-stable+timestamp.2013.11.28.13.54.07
 (Running on Rocket 1.2.6, Python 2.7.5)


 Thanks!


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Undesired redirect to other page after submitting a form

2014-06-19 Thread Tom Clerckx
Hi,

I have some undesired behavior in my app that I was able to resolve, but I 
would like to understand what goes wrong.
I could easily reproduce the problem with a simple test-application, 
containing two pages and two forms (I'm skipping the boilerplate code that 
is created when making a new application):

menu.py
response.menu = [
(T('Home'), False, URL('default', 'index'), []),
(T('Secondpage'), False, URL('default', 'secondpage'), []),
]

controller
def index():
form = SQLFORM.grid(db.contact, create=True, user_signature=False, )
return dict(form=form)

def secondpage():
form = SQLFORM.grid(db.activity, create=True, user_signature=False, )
return dict(form=form)

index.html
{{extend 'layout.html'}}
h1Index page/h1
{{=form}}

secondpage.html
{{extend 'layout.html'}}
h1Welcome to the 2nd page/h1
{{=form}}

db.py
contact = db.define_table('contact',
  Field('first_name', 'string'),
  Field('last_name', 'string'),
  )

activity = db.define_table('activity',
Field('what_you_plan_to_do', 'string'),
)

The problem occurs as follows:

* I go to the index page
* I press the add button opening up the contacts form (which I don't fill 
in at this point)
* In the menu I now press the link to the secondpage
* When the secondpage is loaded I press the browser's back-button
* Now I see the contacts form again which I fill in
* When I now press the Submit button, I am redirected to the secondpage as 
opposed to staying on the index page, which is not the desired outcome.

I could resolve this by giving the forms a formname, but I would like to 
understand why this behavior occurs.
In this specific example the undesired behavior is not critical, but it was 
really a problem in my app as the redirect went to a .load page that did 
not contain any css styling.


Updated controller resolving the problem
def index():
form = SQLFORM.grid(db.contact, create=True, user_signature=False, 
formname='contact')
return dict(form=form)

def secondpage():
form = SQLFORM.grid(db.activity, create=True, user_signature=False, 
formname='activity')
return dict(form=form)


web2py version info
2.8.2-stable+timestamp.2013.11.28.13.54.07
(Running on Rocket 1.2.6, Python 2.7.5)


Thanks!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Scheduler: next_run_time is initially set to time-date of scheduling

2014-05-12 Thread Tom Clerckx
Hi,

When  adding a new task via queue_task, the next_run_time is initially set 
to the time the task is added to the queue. Is there a specific reason for 
this and is there a way to set the first_run_time correctly immediately 
when adding a new task to the queue?
I would expect that the first_run_time would be initialized to the 
start_time of the task.

The problem is that if I show the queue in a grid, from a user perspective, 
the initial next_run_time of a created task seems to be in the past which 
may create confusion.

Only after the time the task has actually ran for the first time, the 
next_run_time field is properly updated.


My web2py version.
Version

2.8.2-stable+timestamp.2013.11.28.13.54.07
(Running on Rocket 1.2.6, Python 2.7.5)

Best regards, 
Tom.

-- 
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: 'reference auth_user' in Data base tables?

2014-04-02 Thread Tom Clerckx
auth_user is a table used in web2py with respect to access control.

You'll find a good overview about this on:
http://web2py.com/books/default/chapter/29/09/access-control?search=auth_user

Best regards,
Tom.

On Tuesday, April 1, 2014 8:01:20 PM UTC+2, Shubham Rathi wrote:

 Hi, I am a novice to web2py development. I stumbled across a piece of code 
 which uses something like: reference auth_user
 I am following a book which is telling how to build a facebook type web2py 
 app. It uses the following:
 # a table to link two people
 db.define_table('link', Field('source', 'reference auth_user'), 
 Field('target', 'reference auth_user'), Field('accepted', 'boolean', 
 default=False))
 What is this *reference auth_user*?
 Please see Page 86 of the attached document. 


-- 
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: Keep menu floating on top

2014-03-31 Thread Tom Clerckx
Fantastic!

Thanks for the responses!

Best regards,
Tom.

On Thursday, March 27, 2014 4:50:29 PM UTC+1, Tom Clerckx wrote:

 Is there an easy way to keep the menu 'floating' on top.
 I.e. when a user scrolls down that the menu stays visible at the top of 
 the page

 Best regards,
 Tom.


-- 
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] Keep menu floating on top

2014-03-27 Thread Tom Clerckx
Is there an easy way to keep the menu 'floating' on top.
I.e. when a user scrolls down that the menu stays visible at the top of the 
page

Best regards,
Tom.

-- 
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] Book - some pictures don't show

2014-03-12 Thread Tom Clerckx
I was browsing through the web2py online book and noticed that some 
pictures were not rendering in the browser.

Looking a bit deeper into it, I noticed that it concerns picture links over 
HTTPS and that the certificate is not valid.
Example: On
http://web2py.com/books/default/chapter/29/09/access-control#Integration-with-OpenID--Facebook--etc-

There is an image link to:
https://web2py.com/books/default/image/29/en6900.png

The browser reports a certificate issue (Server certificate doesn't match 
the URL).
Indeed, the certificate is issued for pythonanywhere.com whereas the images 
is on web2py.com


Just to let you know.

Best regards,
Tom.

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