[web2py] Re: new free toys

2019-06-03 Thread rāma
Can the taskutils be used to replace nssm with web2py?

On Wednesday, 27 January 2016 13:49:26 UTC+8, Massimo Di Pierro wrote:
>
> # a library to convert units and propagate errors in math
> https://github.com/mdipierro/buckingham
>
> # a library to automatically install modules when imported
> https://github.com/mdipierro/autoinstaller
>
> # a multithreaded task scheduler (originally created for a crawler)
> https://github.com/mdipierro/taskutils
>

-- 
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/97caf055-a5f5-4d22-8bf2-f94b2201202e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] strange error pydal_connection

2019-06-03 Thread 黄祥
*first attempt*
Traceback (most recent call last):
  File "/Users/sugizo/learn/python/web2py/gluon/restricted.py", line 219, in 
restricted
exec(ccode, environment)
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/controllers/install_demo.py"
, line 630, in 
  File "/Users/sugizo/learn/python/web2py/gluon/globals.py", line 421, in 

self._caller = lambda f: f()
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/controllers/install_demo.py"
, line 413, in index
'nav_per_unit' : 1317.3918, 'previous_nav_per_unit' : 1316.93},
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 875, in bulk_insert
for f in self._after_insert]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 875, in 
for f in self._after_insert]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 874, in 
[f(el, ret[k]) for k, el in enumerate(data)]
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/modules/mutualfunds_callback.py"
, line 206, in after_insert_nav
if row_account.investor.notification:
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/helpers/classes.py"
, line 220, in __getattr__
self.__allocate()
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/helpers/classes.py"
, line 209, in __allocate
self._record = self._table[long(self)]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 546, in __getitem__
orderby_on_limitby=False
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 2395, in select
return adapter.select(self.query, fields, attributes)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/sqlite.py"
, line 82, in select
return super(SQLite, self).select(query, fields, attributes)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/base.py"
, line 763, in select
return self._select_aux(sql, fields, attributes, colnames)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/base.py"
, line 719, in _select_aux
rows = self._select_aux_execute(sql)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/base.py"
, line 713, in _select_aux_execute
self.execute(sql)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/__init__.py"
, line 63, in wrap
if not args[0].connection:
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/connection.py", 
line 38, in connection
return getattr(THREAD_LOCAL, self._connection_uname_)
AttributeError: '_thread._local' object has no attribute 
'_pydal_connection_4363584456_2285'

*second attempt*
Traceback (most recent call last):
  File "/Users/sugizo/learn/python/web2py/gluon/restricted.py", line 219, in 
restricted
exec(ccode, environment)
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/controllers/install_demo.py"
, line 630, in 
  File "/Users/sugizo/learn/python/web2py/gluon/globals.py", line 421, in 

self._caller = lambda f: f()
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/controllers/install_demo.py"
, line 413, in index
'nav_per_unit' : 1317.3918, 'previous_nav_per_unit' : 1316.93},
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 875, in bulk_insert
for f in self._after_insert]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 875, in 
for f in self._after_insert]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 874, in 
[f(el, ret[k]) for k, el in enumerate(data)]
  File 
"/Users/sugizo/learn/python/web2py/applications/mutualfunds/modules/mutualfunds_callback.py"
, line 206, in after_insert_nav
if row_account.investor.notification:
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/helpers/classes.py"
, line 220, in __getattr__
self.__allocate()
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/helpers/classes.py"
, line 209, in __allocate
self._record = self._table[long(self)]
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 546, in __getitem__
orderby_on_limitby=False
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/objects.py", 
line 2395, in select
return adapter.select(self.query, fields, attributes)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/sqlite.py"
, line 82, in select
return super(SQLite, self).select(query, fields, attributes)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/base.py"
, line 763, in select
return self._select_aux(sql, fields, attributes, colnames)
  File 
"/Users/sugizo/learn/python/web2py/gluon/packages/dal/pydal/adapters/base.py"
, line 

[web2py] Re: Web3py

2019-06-03 Thread 黄祥
face same error too on mac python3.7
*steps*
./web3py-start -p password.txt -a 0.0.0.0:8000 apps
cat << EOF >> apps/_scaffold/models.py
db.define_table('thing', Field('name') )
db.commit()
db.define_table('think', Field('name') )
db.commit()
EOF
open http://localhost:8000/_dashboard

error traceback on terminal (appears when 'reload apps' button hit)
[FAILED] loading _scaffold 
Traceback (most recent call last):
  File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 614, in 
import_apps
importlib.reload(sys.modules[name])
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/importlib/__init__.py"
, line 169, in reload
_bootstrap._exec(spec, module)
  File "", line 630, in _exec
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "/Users/sugizo/learn/python/web3py/apps/_scaffold/common.py", line 37
, in 
groups = Tags(db.auth_user, 'groups')
  File "/Users/sugizo/learn/python/web3py/web3py/utils/tags.py", line 14, in 
__init__
Field('record_id', table))
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/pydal/base.py"
, line 581, in define_table
raise SyntaxError('table already defined: %s' % tablename)
  File "", line None
SyntaxError: table already defined: auth_user_tag_groups

strange things, error traceback above not occured on _dashboard (recent 
tickets), no ticket id shown yet on terminal
after hit 'reload apps' sometimes stuck in gears animation not in previous 
_dashboard content (installed applications, recent tickets, system)

best regards,
stifan

On Monday, June 3, 2019 at 10:16:27 PM UTC+7, John Bannister wrote:
>
> Hi All,
>
> Finally gotten round to playing again on the latest Web3py.
>
> On _scaffold app .. if I add new tables to model file and then reload from 
> the dashboard .. I get errors as follows:-
>
> File "C:\Users\johhb\py3\lib\site-packages\pydal\base.py", line 581, in 
> define_table
> raise SyntaxError('table already defined: %s' % tablename)
>   File "", line None
> SyntaxError: table already defined: auth_user_tag_groups
>
> Only way around it seems to be to delete contents of database folder and 
> restart.
>
> Dashboard app hangs on reload sometimes (I think it has to do the with 
> same issue above) and only way to get round it is to restart the server and 
> refresh the _dashboard app. 
>
> I really want to start using it to create a few new apps I am due to start 
> working on shortly even though I am well aware that it is not yet 
> production ready so will keep testing and assist wherever I can. Thanks 
> again for all the hard work put in so far I am sure its gonna be a really 
> cool solution.
>
> Best Regards
> John
>
>
> On Thursday, 16 May 2019 17:15:44 UTC+2, John Bannister wrote:
>>
>> Hi All,
>>
>> Had a first real 'play' with web3py' today and have a few questions the 
>> biggest of which I am hoping the gurus will be able to answer:-
>>
>> 1: Is there any way to not to have to restart the app every time changes 
>> are made to actions in the controller or new actions added etc? I 
>> understand that controllers are basically being imported when the app fires 
>> up but is any there any way to occasionally reload instead of having to 
>> restart the app? This is a fairly big one for me as sometimes tweaks will 
>> need to be made in production and restarting the web server is not really 
>> an option so hopefully I am missing something really simple.
>>
>> Thanks in advance
>> John
>>
>>
>>
>>
>>
>>
>>   
>>
>

-- 
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/34c36d8c-85d8-4565-a40e-db5fc97ac2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How can I check if an application is installed from within routes.py?

2019-06-03 Thread Lisandro
In my production environment, new web2py apps are installed every day. 
In fact, it is the same app that it is installed several times with a 
different name. 
Each installed application corresponds to a website that has its own domain.

In the root folder of web2py, I have a file called "domains_apps" where I 
store which domain corresponds to which application. 
The file looks like this:

domain1.com!app1
domain2.com!app2
domain3.com!app3


Then, in my routes.py file I read the domains_apps file to construct the 
"domains" dictionary that is provided for the routers.
My routes.py file looks like this:

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

domains = {}
archivo = open('domains_apps', 'r')
lines = archivo.readlines()
archivo.close()
for line in lines:
if line:
domain, app = line.split('!')
if domain and app:
domains[domain] = app

routers = dict(
  BASE=dict(
default_controller='default',
default_function='index',
domains=domains,
root_static=['robots.txt', 'ads.txt'],
map_static=True,
exclusive_domain=True,
  )
)


This works smoothly. 
Now I'm trying to add a checkpoint: before adding an domain/app, I would 
like to check that the application is indeed installed in web2py. *How do I 
do that?*

I've tried checking if the folder exists inside applications folder, but it 
doesn't work (I created an empty dir and it does pass the validation, but 
then web2py throws an error saying application doesn't exist).
I've also tried checking if the folder exists and it has an __init__.py 
file inside it, but it doesn't work (again, I tried creating a folder with 
an __init__.py file inside, it passes validation but web2py throws error 
saying application doesn't exist).

You may wonder why do I need to check that in routes.py? 
Well, as applications are installed/removed by an external process, 
something could break during this process. And if for some reason my 
domains_apps file ends up including an application that was removed, my 
uWSGI instance will fail loading the application, and all my requests will 
fail. 

So, considering the routes.py I previously showed, how can I check if an 
application exists? 
Does this approach make any sense?



-- 
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/ddb1a05a-b5ea-4ab4-ba73-9c95243d052b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: pyDAL "adapter" for Pandas syntax (phylosophical)

2019-06-03 Thread Leonel Câmara
Sorry to dig this thread up, but I had to take a look at this recently.  
  
I think the most efficient way is to use pydal to make the sql query and 
then have pandas do it. As an example say you want a dataframe which has 
the user's id and their first_name

import pandas as pd
conn = db._adapter.connection
sqlquery = pd.read_sql_query(db(db.auth_user.id > 0)._select(db.auth_user.id
, db.auth_user.first_name), conn)
df = pd.DataFrame(sqlquery, columns=["id", "first_name"])

This uses the connection to the database already done by pydal, it uses sql 
produced by pydal, however pydal does not process the result as it goes 
directly to pandas.

-- 
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/e99631fd-a5bd-41f5-904b-57a0b2b1d67a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-06-03 Thread John Bannister
Hi All,

Finally gotten round to playing again on the latest Web3py.

On _scaffold app .. if I add new tables to model file and then reload from 
the dashboard .. I get errors as follows:-

File "C:\Users\johhb\py3\lib\site-packages\pydal\base.py", line 581, in 
define_table
raise SyntaxError('table already defined: %s' % tablename)
  File "", line None
SyntaxError: table already defined: auth_user_tag_groups

Only way around it seems to be to delete contents of database folder and 
restart.

Dashboard app hangs on reload sometimes (I think it has to do the with same 
issue above) and only way to get round it is to restart the server and 
refresh the _dashboard app. 

I really want to start using it to create a few new apps I am due to start 
working on shortly even though I am well aware that it is not yet 
production ready so will keep testing and assist wherever I can. Thanks 
again for all the hard work put in so far I am sure its gonna be a really 
cool solution.

Best Regards
John


On Thursday, 16 May 2019 17:15:44 UTC+2, John Bannister wrote:
>
> Hi All,
>
> Had a first real 'play' with web3py' today and have a few questions the 
> biggest of which I am hoping the gurus will be able to answer:-
>
> 1: Is there any way to not to have to restart the app every time changes 
> are made to actions in the controller or new actions added etc? I 
> understand that controllers are basically being imported when the app fires 
> up but is any there any way to occasionally reload instead of having to 
> restart the app? This is a fairly big one for me as sometimes tweaks will 
> need to be made in production and restarting the web server is not really 
> an option so hopefully I am missing something really simple.
>
> Thanks in advance
> John
>
>
>
>
>
>
>   
>

-- 
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/bff5857a-e7a8-417e-a973-4f588bb19cdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] ignore_common filters not applied to left join table

2019-06-03 Thread icodk
Not sure if it is a bug, feature or inconsistancy but ignore_common filters 
not applied to left join table in query with left join.
I would expect that ignore is for all.
Not a big issue because you can set the commonfilter on the respected 
tables to None just before query execution.

-- 
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/612be6ea-f83b-4e18-89b4-2678a70c889c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] nssm does not work

2019-06-03 Thread rāma
I am using the latest version of NSSM - the Non-Sucking Service Manager; 
both 2.24 and the prelease build 2.2.4-101 .

Unfortunately for me, NSSM sucked big time and trying to get it working 
with web2py was an utter waste of time.

Tried
-K; nothing and tried
-X; nothing anyways

Env:
Python3.7
Windows 10

Can anyone advise what is supposed to happen after issuing -K app1 ? A 
windows pop-up or the local webserver starts ? There is no outcome clearly 
explained in any material I have gone through so far.

-- 
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/57c77e5c-7467-4275-8f1c-e34320c8568b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.