Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Eliezer (Vlad) Tseytkin
Oh, no problem, I've adjusted it for my case. My problem was that I wasn't
aware about subqueries (_select vs. select), so that was the main take away
:)

On Wed, May 15, 2019, 1:28 AM Massimo Di Pierro 
wrote:

> Something is wrong. You are searching that the id of one table is not the
> id of another table. But that is not a reference.
>
> On Tuesday, 14 May 2019 19:49:32 UTC-7, Vlad wrote:
>>
>> works like a charm!
>> thank you !
>>
>> On Tue, May 14, 2019 at 7:16 PM Val K  wrote:
>>
>>> should help:
>>>
>>> sql_str = db()._select(db.tbl2.id)  #note underscore before `select`
>>> db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name)
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, Vlad wrote:

 What would be an equivalent of the following?

 SELECT ID, Name
 FROM   Table1
 WHERE  ID NOT IN (SELECT ID FROM Table2)

 --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/web2py/B1zikfQE8GI/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/e1e7ba43-70bd-4dc1-8029-21d0959cd023%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/B1zikfQE8GI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/09fc266e-ebd0-4920-9a9b-bdd68caba1d4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Https Apache Problem

2019-05-14 Thread Massimo Di Pierro
Please. Use nginx. There is no reason to use Apache any more in 2019.

On Tuesday, 14 May 2019 22:28:55 UTC-7, Cris Fad wrote:
>
> Hello, 
>
> I am trying to run w2p on apache. I do so by running the script 
> setup-web2py-ubuntu.sh in the folder web2py/scripts. It works fine for the 
> address http: but not for the https. Furthermore, due to this situation I 
> cannot access the admin page.
> I am using server with Ubuntu 18.04 installed.
>
> Please help me! 
> Thanks in advance
> Cristina
>

-- 
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/70496136-cf61-4ee4-b2a6-9bfcca90cabc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] https and apache

2019-05-14 Thread Cris Fad
Dear all, 

I have problems to access web2py on apache throught https. I run 
setup-web2py-ubuntu.sh, in the folder web2py/scripts and while the http is 
responding correctly the https is not. In this way I cannot start the admin 
page. 
The server is running Ubuntu 18.04.

Thanks in advance
Cristina

-- 
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/b21465c5-a131-4e18-b93f-5acf41ed556a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Massimo Di Pierro
Something is wrong. You are searching that the id of one table is not the 
id of another table. But that is not a reference.

On Tuesday, 14 May 2019 19:49:32 UTC-7, Vlad wrote:
>
> works like a charm! 
> thank you ! 
>
> On Tue, May 14, 2019 at 7:16 PM Val K  wrote:
>
>> should help:
>>
>> sql_str = db()._select(db.tbl2.id)  #note underscore before `select`
>> db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name)  
>>
>>
>>
>>
>>
>>
>> On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, Vlad wrote:
>>>
>>> What would be an equivalent of the following?
>>>
>>> SELECT ID, Name 
>>> FROM   Table1 
>>> WHERE  ID NOT IN (SELECT ID FROM Table2)
>>>
>>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/B1zikfQE8GI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/e1e7ba43-70bd-4dc1-8029-21d0959cd023%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[web2py] Re: self-reference not showing dropdown on form field

2019-05-14 Thread Isaac Batista
thxs, same problem. it has worked for me

Em segunda-feira, 4 de março de 2013 10:34:14 UTC-3, Anthony escreveu:
>
> db.category.parent.requires = IS_EMPTY_OR(IS_IN_DB(db, 'category.category'
> ))
>
> On Sunday, March 3, 2013 9:34:59 PM UTC-5, 黄祥 wrote:
>>
>> a, thank you so much for your detail explaination anthony. it's work fine 
>> now by add :
>>
>> db.category.parent.requires=IS_IN_DB(db, 'category.category')
>>
>> btw, with this, i still have a problem for input the parent category. 
>> because in form there is not allowed to put an empty value. i have 2 ideas 
>> for this problem :
>> 1. put the parent category directly to database via database input command
>> 2. create the root category above parent category :
>> for example
>> root category
>> |
>> parent category
>> | 
>> child category
>>
>> do you have better idea or suggestion about this?
>>
>> thanks a lot before
>>
>

-- 
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/e127fa6a-e03a-45c7-aa02-f651970e912f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Relate data in two different databases

2019-05-14 Thread Érique Moreira


Good afternoon

I have 3 different databases that relate the risk stratification in the 
patient's oral health.

1) Patient registration

2) Stratification data (eg smoking, pain, cavities, water with fluoride, etc.)

3) stratification result (Low Risk, Medium Risk, High Risk)

the BD 2 and 3 are referenced by the patient

I am creating graphs, but I can not relate, for example, to the smoker with the 
degree of risk. There are 36 stratified smokers, I would like to know how many 
are Low Risk, Medium Risk and High Risk.

Stratification Db

   
   


-- 
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/fd312b9f-b68a-4986-a536-273f13cfc10d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-

db.define_table('estratifica',
Field ('paciente', 'reference paciente'),
Field ('data', 'date', default = request.now),
Field ('condicao', 'string', default ="n.d.n"),
Field ('cronica', 'integer', default = 0),
Field ('intelectual', 'integer', default = 0),
Field ('acamado', 'integer', default = 0),
Field ('tabaco', 'integer', default = 0),
Field ('cri', 'integer', default = 0),
Field ('dor', 'integer', default = 0),
Field ("mb", 'integer', default = 0),
Field ('seca', 'integer', default = 0),
Field ('car3', 'integer', default = 0),
Field ('car4', 'integer', default = 0),
Field ('car8', 'integer', default = 0),
Field ('ferida', 'integer', default = 0),
Field ('sangue', 'integer', default = 0),
Field ('mole', 'integer', default = 0),
Field ('total', 'integer', default = 0),
Field ('parcial', 'integer', default = 0),
Field ('perda', 'integer', default = 0),
Field ('endo', 'integer', default = 0),
Field ('perio', 'integer', default = 0),
Field ('cirurgia', 'integer', default = 0),
Field ('diag', 'integer', default = 0),
Field ('esp', 'integer', default = 0),
Field ('escol', 'integer', default = 0),
Field ('doce', 'integer', default = 0),
Field ('fluor', 'integer', default = 0),
Field ('pasta', 'integer', default = 0),
Field ('escovar', 'integer', default = 0),
Field ('servico', 'integer', default = 0),
Field ('mamadeira', 'integer', default = 0),
Field ('chupeta', 'integer', default = 0),
Field ('comportamento', 'integer', default = 0),
Field ('supervisao', 'integer', default = 0),
Field ('defeito', 'integer', default = 0),
format = "%(data)s")

db.define_table('estratificacao',
Field ('paciente', 'reference paciente', label = "Nome do Paciente:"),
Field ('data', 'date', label = "Exame Data: ", requires = IS_DATE(format = '%d/%m/%Y', error_message="Data Inválida Ex.: 27/07/1984")),
Field ('condicao', 'string', label = "Condição : ", requires = IS_IN_SET(['n.d.n.', 'gestante', '< 3 anos', "36 anos", "> 6 anos", "612 anos", "adolescente", "idoso", "paciente especial",'diabético', 'saúde mental'])),
Field ('risco', 'string', label = "Risco : ", requires = IS_IN_SET(['Baixo Risco ', 'Médio Risco', 'Alto Risco'])),
Field ('escore', 'integer', label = "Escore : "),
format = "%(date)s")


db.estratifica.data.requires = IS_DATE(format = '%d/%m/%Y', error_message="Data Inválida Ex.: 27/07/1984")
db.estratifica.condicao.requires = IS_IN_SET(['n.d.n.', 'gestante', '< 3 anos', "36 anos", "> 6 anos", "612 anos", "adolescente", "idoso", "paciente especial",'diabético', 'pós-parto'])


[web2py] Https Apache Problem

2019-05-14 Thread Cris Fad
Hello, 

I am trying to run w2p on apache. I do so by running the script 
setup-web2py-ubuntu.sh in the folder web2py/scripts. It works fine for the 
address http: but not for the https. Furthermore, due to this situation I 
cannot access the admin page.
I am using server with Ubuntu 18.04 installed.

Please help me! 
Thanks in advance
Cristina

-- 
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/2afeea6d-b850-4f8e-a151-8d8410b03291%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Vue2pyj - alternative web IDE

2019-05-14 Thread Massimo Di Pierro
Thanks. :-)


On Tuesday, 14 May 2019 16:23:17 UTC-7, Val K wrote:
>
> I moved vue3pyj to separate repo :
> https://github.com/valq7711/vue3pyj
>
> Delimiters are changed as you suggested  
>
> On Tuesday, May 14, 2019 at 10:00:14 AM UTC+3, Massimo Di Pierro wrote:
>>
>> I've think we should adopt the convention that [[ ]] are yatl delimiters 
>> and {{ }} are Vue delimiters.
>>
>

-- 
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/e47a0009-7445-4341-bcfc-c2717e758617%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-14 Thread Massimo Di Pierro
web2py uses:

(all defined in web3py/core.py)
[100% done] pydal for DB
[100%] pluralize for T
[100%] yatl for template and helpers
[100%] tornado as default web server (when no --number_workers)
[100%] gevent + gunicorn when --number_workers is specified
[100%] bottle for routing, request, response, abort, and redirect (but has 
its own decorator instead the bottle one)
[100%] has its own new session object (support cookies, db, memcache, 
redis, and user defined)
[100%] has its own O(1) least recently used cache/memoize function (used 
for example to cache templates in ram)
[100%] web3py/form.py replaces SQLFORM

[75%]  "_dashboard" instead of "admin" (same purpose)
[75%] "_dashboard dbadmin" instad of appadmin (same purpose)
[75%] "_scaffold" instead of welcome (same purpose)
[75%] applications/_dashboard/components/mtable.* replaces 
SQLFORM.smartgrid 
[50%] applications/_scaffold/components/auth.*  + web3py/utils/auth.py 
replace Auth + user.html

It uses the concept of "Fixtures" which are like bottle plugins but can 
have dependencies. DAL, Session, T, templates are fixtures. 

For every action they must be declared as in:

@action('index', method=['GET','POST'])
@action.uses('my-template.html', mysession, T , mydb)
def index():
  return dict()

It is important to declare them to avoid a shortcoming of web2py and other 
frameworks, to avoid doing work when it is not necessary. So if an action 
does not need session, there is no need to even try parse cookies, hence 
you do not declare the fixture. 

You can define aliases:

myaction = action.uses('my-template.html', mysession, T , mydb)

and then do

@action('index', method=['GET','POST'])
@myaction
def index():
  return dict()

Unlike web2py the models.py, controllers.py and all the other files are 
just regular files. You can call them what you like, and they are imported, 
not executed. This means web3py is much faster and also you can use pylint 
and code completion without tweaks. No custom_importer that can cause weird 
behavior. This also means there will be some nu-expected behavior for 
web2py users and needs to be documented. Every module in the applications 
folder is an app. Apps does not need to expose any action, they can just be 
a collection of modules, or static files, or templates. 

_dashboard and _scaffold use vue.js and the grid (mtable) and auth are vue 
component but you can use them even if the rest of your app does not use 
vue. Components have their own html templates in vue and they can easily be 
customized for different CSS. This requires a much longer explanation and I 
will write it when it is finalized.

We ditched the web2py Storage object. People like it but the profiler 
showed Storage.__getitem__ is the single most called function in web2py and 
causes loss in performance. In web3py we stick to regular python dict 
objects.

This is work in progress so things will change.

Massimo




On Tuesday, 14 May 2019 08:42:16 UTC-7, En Ware wrote:
>
> So I'm trying to figure out web3py libs and how everything works together. 
> Web3py uses bottle for request, routes, and response. Web3py uses DAL or 
> PyDAL for database abstraction. 
>
> Is this still valid for Storage class ? 
> https://web2py.readthedocs.io/en/latest/_modules/gluon/storage.html , I 
> was looking up information on how "dict" was formed.
>
> On Tuesday, May 14, 2019 at 9:20:00 AM UTC-5, En Ware wrote:
>>
>> The editing is very fast and reloads on the fly. This is pretty 
>> impressive. 
>>
>> On Tuesday, May 14, 2019 at 9:05:58 AM UTC-5, En Ware wrote:
>>>
>>> Ok very good, I created the directories and launched again and i can get 
>>> to the _dashboard instance, thanks
>>>
>>> On Tuesday, May 14, 2019 at 8:58:44 AM UTC-5, 黄祥 wrote:

 pls try:
 *need an extra steps to make web3py start in latest commit (101)*
 git clone https://github.com/web2py/web3py
 cd web3py
 pip3 install -r requirements.txt
 mkdir applications/_dashboard/translations
 mkdir applications/_scaffold/databases
 mkdir applications/toys/databases
 ./web3py-start applications/

 directory creation to eliminate the error produced on console when 
 execute web3py-start

 best regards,
 stifan

>>>

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


[web2py] Re: Block pages on time

2019-05-14 Thread Massimo Di Pierro
Intreresting 

raise redirect(...) 

and

redirect()

behave the same because the redirect function raises HTTP so the other 
raise is never excuted

On Tuesday, 14 May 2019 07:40:47 UTC-7, Val K wrote:
>
> Yes, but without raise

-- 
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/951694b9-c449-4dfa-94bb-6887d6b873ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-14 Thread Massimo Di Pierro
We can change the name but api is too ambiguous. Any other idea?

On Tuesday, 14 May 2019 05:34:33 UTC-7, Anthony wrote:
>
> Looks great. You might want to consider an alternative name to avoid 
> confusion with the Python DB-API 
>  specification (maybe 
> just call the class API -- i.e., pydal.API rather than pydal.DBAPI).
>
> On Tuesday, May 14, 2019 at 2:18:42 AM UTC-4, Massimo Di Pierro wrote:
>>
>> You may have missed this but there is a new functionality in PyDAL that 
>> allows you to create very powerful APIs. It is called DBAPI.
>> It is still not 100% stable but it is working and I could use some help 
>> testing it.
>> web3py's equivalent of appadmin will be called dbadmin (90% done) and it 
>> is based on DBAPI.
>> Even if primarily designed for web3py it works for web2py too and you can 
>> find some preliminary examples below.
>> Hope it is self-explanatory.
>>
>> DBAPI EXAMPLES 
>>
>> Inspired by GraphQL but not quite the same
>>
>> Less powerful but simpler to use
>>
>> Self descriptive (@model=True) and policy based (policy set serverside)
>>
>> Support complex queries like: 
>>
>>- name.eq=Clark Kent
>>- name.ne=Clark Kent
>>- name.gt=Clark Kent
>>- name.lt=Clark Kent
>>- name.ge=Clark Kent
>>- name.le=Clark Kent
>>- name.startswith=Clark
>>- name.contains=Kent
>>- not.real_identity.name.contains=Wayne
>>- not.superhero.tag.superpower.description.eq=Flight
>>
>> Support de-normalization: 
>>
>>- @lookup=real_identity
>>- @lookup=real_identity[name]
>>- @lookup=real_identity[name,job]
>>- @lookup=identity:real_identity[name,job]
>>- @lookup=identity!:real_identity[name,job]
>>- @lookup=superhero.tag
>>- @lookup=superhero.tag[strength]
>>- @lookup=superhero.tag[strength].superpower
>>- @lookup=superhero.tag[strength].superpower.description
>>
>> Fast. Even the most complex query is implemented with at most 2 selects + 
>> 1 select for each denormalized link table
>> Example Model 
>>
>> db.define_table(
>> 'person',
>> Field('name'),
>> Field('job'))
>>
>> db.define_table(
>> 'superhero',
>> Field('name'),
>> Field('real_identity', 'reference person'))
>>
>> db.define_table(
>> 'superpower',
>> Field('description'))
>>
>> db.define_table(
>> 'tag',
>> Field('superhero', 'reference superhero'),
>> Field('superpower', 'reference superpower'),
>> Field('strength', 'integer'))
>>
>> Example Controller 
>>
>> from pydal.dbapi import DBAPI, Policy
>> policy = Policy()
>> policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
>> post_vars:True, allowed_patterns=['*'])
>> policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>> policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>> policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
>> post_vars:False)
>>
>> def api():
>> return DBAPI(db, policy)(request.method, request.args(0), 
>> request.args(1),
>>  request.get_vars, request.post_vars)
>>
>> Example GET URLs 
>> /superheroes/default/api.json/superhero 
>>
>> {
>> "count": 3,
>> "status": "success",
>> "code": 200,
>> "items": [
>> {
>> "real_identity": 1,
>> "name": "Superman",
>> "id": 1
>> },
>> {
>> "real_identity": 2,
>> "name": "Spiderman",
>> "id": 2
>> },
>> {
>> "real_identity": 3,
>> "name": "Batman",
>> "id": 3
>> }
>> ],
>> "timestamp": "2019-05-14T06:14:06.764966",
>> "api_version": "0.1"
>> }
>>
>> /superheroes/default/api.json/superhero&@model=true 
>>
>> {
>> "status": "error",
>> "timestamp": "2019-05-14T06:14:06.997662",
>> "message": "Invalid table name: superhero_amp_@model=true",
>> "code": 400,
>> "api_version": "0.1"
>> }
>>
>> /superheroes/default/api.json/superhero?@lookup=real_identity 
>>
>> {
>> "count": 3,
>> "status": "success",
>> "code": 200,
>> "items": [
>> {
>> "real_identity": {
>> "name": "Clark Kent",
>> "job": "Journalist",
>> "id": 1
>> },
>> "name": "Superman",
>> "id": 1
>> },
>> {
>> "real_identity": {
>> "name": "Peter Park",
>> "job": "Photographer",
>> "id": 2
>> },
>> "name": "Spiderman",
>> "id": 2
>> },
>> {
>> "real_identity": {
>> "name": "Bruce Wayne",
>> "job": "CEO",
>> "id": 3
>> },
>> "name": "Batman",
>> "id": 3
>> }
>> ],
>> "timestamp": "2019-05-14T06:14:06.931746",
>> "api_version": 

Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Eliezer (Vlad) Tseytkin
works like a charm!
thank you !

On Tue, May 14, 2019 at 7:16 PM Val K  wrote:

> should help:
>
> sql_str = db()._select(db.tbl2.id)  #note underscore before `select`
> db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name)
>
>
>
>
>
>
> On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, Vlad wrote:
>>
>> What would be an equivalent of the following?
>>
>> SELECT ID, Name
>> FROM   Table1
>> WHERE  ID NOT IN (SELECT ID FROM Table2)
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/B1zikfQE8GI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/e1e7ba43-70bd-4dc1-8029-21d0959cd023%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Vue2pyj - alternative web IDE

2019-05-14 Thread Val K
I moved vue3pyj to separate repo :
https://github.com/valq7711/vue3pyj

Delimiters are changed as you suggested  

On Tuesday, May 14, 2019 at 10:00:14 AM UTC+3, Massimo Di Pierro wrote:
>
> I've think we should adopt the convention that [[ ]] are yatl delimiters 
> and {{ }} are Vue delimiters.
>

-- 
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/e4641ac7-23a0-4174-9134-22f37d2258f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Val K
should help:

sql_str = db()._select(db.tbl2.id)  #note underscore before `select`
db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name)  






On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, Vlad wrote:
>
> What would be an equivalent of the following?
>
> SELECT ID, Name 
> FROM   Table1 
> WHERE  ID NOT IN (SELECT ID FROM Table2)
>
>

-- 
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/e1e7ba43-70bd-4dc1-8029-21d0959cd023%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Vlad
What would be an equivalent of the following?

SELECT ID, Name 
FROM   Table1 
WHERE  ID NOT IN (SELECT ID FROM Table2)

-- 
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/84c4ac19-b87d-4e6f-8d3a-edea8ee21188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Password File

2019-05-14 Thread Dave S


On Monday, May 13, 2019 at 6:50:40 PM UTC-7, Suhas Jadhav wrote:
>
> Hi Gurus,
> In my web2py application, i am connecting to two different databases.
> Currently, I am saving username and password in the code.
> I want to use a password file or some other mean. Can you please help.
>

If you're using private/appconfig.ini, you can put the passwords in the URI.

private/appconfig.ini should not be checked into source control, nor sent 
unsanitized to customers.

(The one "out of the box" with web2py should be considered a template;, 
which is okay check in or distribute.  The real appconfig.ini should only 
be backed up in a secure place.   The database credentials are a big reason 
for this, but appconfig.ini is entirely instance specific.)

/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/42dcf7e3-2ee9-4c32-acbc-3d242bf6d3a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: block entire app

2019-05-14 Thread Dave S


On Monday, May 13, 2019 at 8:44:54 PM UTC-7, lucas wrote:
>
> hey one and all,
>
> where, in what model or controller, is the best place to place a few lines 
> of code that captures every controller/function call in the entire app and 
> returns a single page with a line of text and link to shuttle the viewers 
> to another website.  and what would be those few lines of code also. 
>  basically, how to gracefully shutdown an entire app?
>
> thank you in advance, lucas
>

I would use routes.py, or even put it directly in your front end if it is a 
static page.

(In my production case, nginx)


/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/ae8bc2c3-d224-40e1-af7a-a621beb55681%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: authapi.py

2019-05-14 Thread Tito Garrido
Thank you,
https://github.com/robertop23/web2py_vuejs_vuetify/blob/master/controllers/api.py

works for me!

On Mon, May 13, 2019 at 4:23 PM Val K  wrote:

> https://github.com/web2py/web2py/blob/4a90c82ee4271b2a17c187d41138a03249c14350/gluon/tools.py#L1002
>
>
>
>
>
> https://github.com/robertop23/web2py_vuejs_vuetify/blob/master/controllers/api.py
>
> On Monday, May 13, 2019 at 10:11:31 PM UTC+3, Tito Garrido wrote:
>>
>> Hi Guys!
>>
>> Is there any example using authapi + jwt in any documentation?
>>
>> Thank you!
>>
>> Tito
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
> --
> 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/97e19835-dce8-499d-aa2b-140641f862fa%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 
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/CAL67CHEBHqboPMPhvqfaCZjvh1gE37s9HZZHJ4eNpDVpeQa1bA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-14 Thread En Ware
So I'm trying to figure out web3py libs and how everything works together. 
Web3py uses bottle for request, routes, and response. Web3py uses DAL or 
PyDAL for database abstraction. 

Is this still valid for Storage class 
? https://web2py.readthedocs.io/en/latest/_modules/gluon/storage.html , I 
was looking up information on how "dict" was formed.

On Tuesday, May 14, 2019 at 9:20:00 AM UTC-5, En Ware wrote:
>
> The editing is very fast and reloads on the fly. This is pretty 
> impressive. 
>
> On Tuesday, May 14, 2019 at 9:05:58 AM UTC-5, En Ware wrote:
>>
>> Ok very good, I created the directories and launched again and i can get 
>> to the _dashboard instance, thanks
>>
>> On Tuesday, May 14, 2019 at 8:58:44 AM UTC-5, 黄祥 wrote:
>>>
>>> pls try:
>>> *need an extra steps to make web3py start in latest commit (101)*
>>> git clone https://github.com/web2py/web3py
>>> cd web3py
>>> pip3 install -r requirements.txt
>>> mkdir applications/_dashboard/translations
>>> mkdir applications/_scaffold/databases
>>> mkdir applications/toys/databases
>>> ./web3py-start applications/
>>>
>>> directory creation to eliminate the error produced on console when 
>>> execute web3py-start
>>>
>>> best regards,
>>> stifan
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/58d252f2-cd1c-446e-846b-8f34cb3d8110%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Block pages on time

2019-05-14 Thread Val K
Yes, but without raise

-- 
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/0da6c03d-0db7-4c37-aa35-966553346b78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-14 Thread 黄祥
pls ignore my previous report about web3py tests folder, pardon, done it in 
wrong way, my bad, here is the correct one
docker pull ubuntu
docker run -it --privileged ubuntu /bin/bash

apt update
apt install -y git python3-pip memcached 
service memcached restart
cd
git clone https://github.com/web2py/web3py
cd web3py
pip3 install -U -r requirements.txt
pip3 install pytest mechanize 
python3 -m pytest -v -s web3py/tests/

*note on latest commit (101):*
- file setup.py install_requires is lack from requirements.txt (tornado, 
python-memcached)
- pip3 install web3py still produce an error, must execute via make install 
or python3 setup.py install (to run test need web3py module)

best regards,
stifan

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


[web2py] Re: Web3py

2019-05-14 Thread En Ware
The editing is very fast and reloads on the fly. This is pretty impressive. 

On Tuesday, May 14, 2019 at 9:05:58 AM UTC-5, En Ware wrote:
>
> Ok very good, I created the directories and launched again and i can get 
> to the _dashboard instance, thanks
>
> On Tuesday, May 14, 2019 at 8:58:44 AM UTC-5, 黄祥 wrote:
>>
>> pls try:
>> *need an extra steps to make web3py start in latest commit (101)*
>> git clone https://github.com/web2py/web3py
>> cd web3py
>> pip3 install -r requirements.txt
>> mkdir applications/_dashboard/translations
>> mkdir applications/_scaffold/databases
>> mkdir applications/toys/databases
>> ./web3py-start applications/
>>
>> directory creation to eliminate the error produced on console when 
>> execute web3py-start
>>
>> best regards,
>> stifan
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/9b321797-0c18-4883-883a-374cdff3dfeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: RESTful service with access control

2019-05-14 Thread Jim S
Yes, I have the view set.   

I have it working now if I use the password stored in my auth_user table.  
But, I'd really prefer to have it go through all available authentication 
methods to authenticate a user.  We have some users that authenticate to 
our mail server and others that use the password in auth_user.  It's not a 
show-stopper, using the auth_user password will work for me.

Thanks for sticking with me on this one.

-Jim

On Tuesday, May 14, 2019 at 12:10:11 AM UTC-5, Val K wrote:
>
> One yet important moment:
> Do you set the view for your api?
> I mean, that book example will not work without 
> response.view='generic.json' if request is not local.

-- 
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/87da0a4b-ee82-4b9e-a77a-a36995beb627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-14 Thread En Ware
Ok very good, I created the directories and launched again and i can get to 
the _dashboard instance, thanks

On Tuesday, May 14, 2019 at 8:58:44 AM UTC-5, 黄祥 wrote:
>
> pls try:
> *need an extra steps to make web3py start in latest commit (101)*
> git clone https://github.com/web2py/web3py
> cd web3py
> pip3 install -r requirements.txt
> mkdir applications/_dashboard/translations
> mkdir applications/_scaffold/databases
> mkdir applications/toys/databases
> ./web3py-start applications/
>
> directory creation to eliminate the error produced on console when execute 
> web3py-start
>
> best regards,
> stifan
>

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


[web2py] Re: Block pages on time

2019-05-14 Thread Константин Комков
Maybe I can use it?
raise redirect(URL('static','403.html'))


-- 
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/1b0d7160-3941-492d-bb42-409ea568f22c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-14 Thread 黄祥
pls try:
*need an extra steps to make web3py start in latest commit (101)*
git clone https://github.com/web2py/web3py
cd web3py
pip3 install -r requirements.txt
mkdir applications/_dashboard/translations
mkdir applications/_scaffold/databases
mkdir applications/toys/databases
./web3py-start applications/

directory creation to eliminate the error produced on console when execute 
web3py-start

best regards,
stifan

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


[web2py] Re: Web3py

2019-05-14 Thread En Ware
still getting same errors 

 pip3 install -r requirements.txt 
Requirement already satisfied: pydal>=19.5.9 in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 1)) (19.5.9)
Requirement already satisfied: pyjwt in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 2)) (1.7.1)
Requirement already satisfied: yatl in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 3)) (1.0.3)
Requirement already satisfied: pluralize in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 4)) (0.1.3)
Requirement already satisfied: bottle in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 5)) (0.12.16)
Requirement already satisfied: tornado in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 6)) (6.0.2)
Requirement already satisfied: gunicorn in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 7)) (19.9.0)
Requirement already satisfied: gevent in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 8)) (1.4.0)
Requirement already satisfied: reloader in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 9)) (0.6)
Requirement already satisfied: python-memcached in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from -r requirements.txt (line 10)) (1.59)
Requirement already satisfied: greenlet>=0.4.14; 
platform_python_implementation == "CPython" in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from gevent->-r requirements.txt (line 8)) (0.4.15)
Requirement already satisfied: six>=1.4.0 in 
/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/lib/python3.6/site-packages 
(from python-memcached->-r requirements.txt (line 10)) (1.12.0)
08:35:49 [aaronm@usmsp-mb03866corpirdetocom web3py]$ ./web3py-start 
applications/

 ___      __  __
|  / / / / __ |/___ \/ __ \ \/ /
| | / / /_  / /_/ /___/ / /_/ /\  /
| | /| / / __/ / __  //__  / / / /
| |/ |/ / /___/ /_/ /___/ / / / /
|___/|_/_/_/_/_/ /_/
It is still experimental...

Dashboard is at: http://127.0.0.1:8000/_dashboard
Traceback (most recent call last):
  File 
"/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/web3py/web3py/core.py", 
line 570, in import_apps
module = importlib.machinery.SourceFileLoader(app_name, 
init).load_module()
  File "", line 399, in 
_check_name_wrapper
  File "", line 823, in load_module
  File "", line 682, in load_module
  File "", line 265, in _load_module_shim
  File "", line 684, in _load
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File 
"/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/web3py/applications/toys/__init__.py",
 
line 5, in 
db = DAL('sqlite://storage.db', 
folder=os.path.join(os.path.dirname(__file__), 'databases'))
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/base.py",
 
line 171, in __call__
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/base.py",
 
line 477, in __init__
"Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/base.py",
 
line 457, in __init__
self._adapter = adapter(**kwargs)
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/adapters/__init__.py",
 
line 39, in __call__
obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/adapters/base.py",
 
line 369, in __init__
super(SQLAdapter, self).__init__(*args, **kwargs)
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/adapters/base.py",
 
line 53, in __init__
self.reconnect()
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/connection.py",
 
line 154, in reconnect
self.connection = self.connector()
  File 
"/Users/aaronm/.pyenv/versions/web3py/lib/python3.6/site-packages/pydal/adapters/sqlite.py",
 
line 42, in connector
return self.driver.Connection(self.dbpath, **self.driver_args)
sqlite3.OperationalError: unable to open database file


Traceback (most recent call last):
  File 
"/Users/aaronm/.pyenv/versions/3.6.4/envs/web3py/web3py/web3py/core.py", 
line 570, in import_apps
module = importlib.machinery.SourceFileLoader(app_name, 
init).load_module()
 

[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-14 Thread Anthony
Looks great. You might want to consider an alternative name to avoid 
confusion with the Python DB-API 
 specification (maybe 
just call the class API -- i.e., pydal.API rather than pydal.DBAPI).

On Tuesday, May 14, 2019 at 2:18:42 AM UTC-4, Massimo Di Pierro wrote:
>
> You may have missed this but there is a new functionality in PyDAL that 
> allows you to create very powerful APIs. It is called DBAPI.
> It is still not 100% stable but it is working and I could use some help 
> testing it.
> web3py's equivalent of appadmin will be called dbadmin (90% done) and it 
> is based on DBAPI.
> Even if primarily designed for web3py it works for web2py too and you can 
> find some preliminary examples below.
> Hope it is self-explanatory.
>
> DBAPI EXAMPLES 
>
> Inspired by GraphQL but not quite the same
>
> Less powerful but simpler to use
>
> Self descriptive (@model=True) and policy based (policy set serverside)
>
> Support complex queries like: 
>
>- name.eq=Clark Kent
>- name.ne=Clark Kent
>- name.gt=Clark Kent
>- name.lt=Clark Kent
>- name.ge=Clark Kent
>- name.le=Clark Kent
>- name.startswith=Clark
>- name.contains=Kent
>- not.real_identity.name.contains=Wayne
>- not.superhero.tag.superpower.description.eq=Flight
>
> Support de-normalization: 
>
>- @lookup=real_identity
>- @lookup=real_identity[name]
>- @lookup=real_identity[name,job]
>- @lookup=identity:real_identity[name,job]
>- @lookup=identity!:real_identity[name,job]
>- @lookup=superhero.tag
>- @lookup=superhero.tag[strength]
>- @lookup=superhero.tag[strength].superpower
>- @lookup=superhero.tag[strength].superpower.description
>
> Fast. Even the most complex query is implemented with at most 2 selects + 
> 1 select for each denormalized link table
> Example Model 
>
> db.define_table(
> 'person',
> Field('name'),
> Field('job'))
>
> db.define_table(
> 'superhero',
> Field('name'),
> Field('real_identity', 'reference person'))
>
> db.define_table(
> 'superpower',
> Field('description'))
>
> db.define_table(
> 'tag',
> Field('superhero', 'reference superhero'),
> Field('superpower', 'reference superpower'),
> Field('strength', 'integer'))
>
> Example Controller 
>
> from pydal.dbapi import DBAPI, Policy
> policy = Policy()
> policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
> post_vars:True, allowed_patterns=['*'])
> policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
> policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
> policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
>
> def api():
> return DBAPI(db, policy)(request.method, request.args(0), request.args(1),
>  request.get_vars, request.post_vars)
>
> Example GET URLs 
> /superheroes/default/api.json/superhero 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": 1,
> "name": "Superman",
> "id": 1
> },
> {
> "real_identity": 2,
> "name": "Spiderman",
> "id": 2
> },
> {
> "real_identity": 3,
> "name": "Batman",
> "id": 3
> }
> ],
> "timestamp": "2019-05-14T06:14:06.764966",
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero&@model=true 
>
> {
> "status": "error",
> "timestamp": "2019-05-14T06:14:06.997662",
> "message": "Invalid table name: superhero_amp_@model=true",
> "code": 400,
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero?@lookup=real_identity 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": {
> "name": "Clark Kent",
> "job": "Journalist",
> "id": 1
> },
> "name": "Superman",
> "id": 1
> },
> {
> "real_identity": {
> "name": "Peter Park",
> "job": "Photographer",
> "id": 2
> },
> "name": "Spiderman",
> "id": 2
> },
> {
> "real_identity": {
> "name": "Bruce Wayne",
> "job": "CEO",
> "id": 3
> },
> "name": "Batman",
> "id": 3
> }
> ],
> "timestamp": "2019-05-14T06:14:06.931746",
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero?@lookup=identity:real_identity 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": 1,
> "name": "Superman",
> "id": 1,
> 

[web2py] Re: gluon.contrib.pymysql.err.Error AssertionError('Protocol error, expecting EOF',)

2019-05-14 Thread Gilad Hoshmand
Solved.
The problem was that I was addressing 'single_value_field' without the 
context of the derived table.
Changed:
 JOIN
   table2 ON (table2.id = single_value_field)
To:
JOIN 
   table2 ON (table2.id = *new_table_alias*.single_value_field)


On Monday, May 13, 2019 at 6:14:08 PM UTC+3, Gilad Hoshmand wrote:
>
> Hi all,
>
> I built a join query which breaks up a field that has '|' char as 
> separator of values to multiple rows with single values (ie. field value = 
> '1|2|3' , rows will be multiplied with single_value_field = 1 , 
> single_value_field = 2 etc..)
> Filters some rows ('Having ... ' )
> Then join with a table that I need to get values from.
>
> I tested it on mysql 5.7 and it works fine.
>
> I'm using db.executesql(...) to execute the query because I find it hard 
> to make with the DAL but I'm getting an error.
> The query is:
>
> SELECT 
>  *
> FROM
> (SELECT * , SUBSTRING_INDEX(SUBSTRING_INDEX(field1, '|', numbers.n), 
> '|', - 1) AS single_value_field
> FROM
> (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 
> 4 UNION ALL SELECT 5) numbers
> INNER JOIN table1 ON CHAR_LENGTH(field1) - CHAR_LENGTH(REPLACE(field1, 
> '|', '')) >= numbers.n - 1
> HAVING (field1 IS NOT NULL
> AND field1 != '||'
> AND single_value_field IS NOT NULL
> AND single_value_field != '')) new_table_alias
> JOIN
> table2 ON (table2.id = single_value_field)
> WHERE (table2.field2 = '' OR table2.field2 is null)
>
>
> My Error arises on db.executesql(...)  only when I include the last Join 
> clause: 
> JOIN
> table2 ON (table2.id = single_value_field)
>
> If it is omitted - no problems.
>
> Full error(private bits renamed as in query):
>
>  ( 'exceptions.AssertionError'>, AssertionError('Protocol error, expecting 
> EOF',))Version
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
>
> Traceback (most recent call last):
>   File "/path/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File " 
> /path/controllers/myController.py"
>  
> ,
>  line 93, in 
>   File "/path/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File "/path/controllers/myController.py" 
> ,
>  line 15, in index
> rows = db.executesql(query);
>   File "/path/gluon/packages/dal/pydal/base.py", line 1019, in executesql
> adapter.execute(query)
>   File "/path/gluon/packages/dal/pydal/adapters/base.py", line 1388, in 
> execute
> return self.log_execute(*a, **b)
>   File "/path/gluon/packages/dal/pydal/adapters/base.py", line 1382, in 
> log_execute
> ret = self.get_cursor().execute(command, *a[1:], **b)
>   File "/path/gluon/contrib/pymysql/cursors.py", line 117, in execute
> self.errorhandler(self, exc, value)
>   File "/path/gluon/contrib/pymysql/connections.py", line 200, in 
> defaulterrorhandler
> raise Error(errorclass, errorvalue)
> Error: (, AssertionError('Protocol error, 
> expecting EOF',))
>
>
> Thank you all!
>

-- 
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/0a849aa9-95fa-4e1a-9d1c-33f13e75a548%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: RESTful service with access control

2019-05-14 Thread Jim Steil
Massimo - thanks for that info.  This won't help in my case as I'm using
the RESTful API to get access to another of my server-side python
packages.  But, I can see the power of the DBAPI.  I'm waiting for you to
stabilize web3py before I jump in.  I'd love to get involved in more
testing but I haven't been able to free up the time.

My current python2 web2py app is too big for me to try to bring to web3py
before the Python 2 drop dead date so I'm also working to test all of that
under python 3. It's a busy (and exciting) year!

Thanks again for all  you do!

-Jim

On Tue, May 14, 2019 at 1:51 AM Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You may want to see my other post about the new policy based DBAPI.
>
> On Monday, 13 May 2019 09:28:11 UTC-7, Jim S wrote:
>>
>> Hi
>>
>> I'm setting up a REST service that requires authentication.  I'm
>> following the example here:
>>
>> http://web2py.com/books/default/chapter/29/10/services#Access-Control
>>
>> Here is the example with basic login:
>>
>> auth.settings.allow_basic_login = True
>>
>> @auth.requires_login()
>> @request.restful()
>> def api():
>> def GET(s):
>> return 'access granted, you said %s' % s
>> return locals()
>>
>> However, I'd like to use email authentication instead of basic_login.
>>
>> When I remove the first line, and pass proper email address and password,
>> I get a 403 return code.
>>
>> Anyone had success with a RESTful service using email authentication?
>>
>> -Jim
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/7DfbZY6xRWU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/e566fd9f-dd15-4225-b3d3-c5852d1c07c9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Block pages on time

2019-05-14 Thread Константин Комков
Thank you! I do like that:
interval = 
db().select(db.t_admission_schedule.BEGINNING,db.t_admission_schedule.END_APP,orderby=~db.t_admission_schedule.END_APP).first()
if ((datetime.datetime.now().date()interval.END_APP)):
raise HTTP(403)
One more question. Now I see "*403 FORBIDDEN*", but if I check code of page 
403.html I see only *403*. How can I redirect user on 403.html?

-- 
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/2a26d0f6-22b0-4da3-8ed5-7f8e1c0ff0a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Block pages on time

2019-05-14 Thread Val K
Just place 
raise HTTP(403,'blah')
at first line of the controller

-- 
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/b3a60fbf-ddf3-4dd0-be09-7d32ab67304b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Block pages on time

2019-05-14 Thread Константин Комков
Hello! I have that page: https://oas.timacad.ru/application.
default.py:











*def index():interval = 
db().select(db.t_admission_schedule.BEGINNING,db.t_admission_schedule.END_APP,orderby=~db.t_admission_schedule.END_APP).first()
if ((datetime.datetime.now().date()>=interval.BEGINNING) & 
(datetime.datetime.now().date()До старта приёмной кампании осталось:')   
 )delta = 
datetime.datetime(interval.BEGINNING.year,interval.BEGINNING.month,interval.BEGINNING.day,0,0)
 - datetime.datetime.now()seconds = delta.total_seconds()return 
dict(text=text,seconds=seconds)*

Can you take advice, how blocked and unblock all pages for controller 
bak.py for users cant see pages like https://oas.timacad.ru/application/
*bak*/swed and see page with 403 error?

-- 
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/d2619a63-6378-4818-91b6-5168786c5684%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Vue2pyj - alternative web IDE

2019-05-14 Thread Val K
OK,  I'll fix it

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


[web2py] Re: Vue2pyj - alternative web IDE

2019-05-14 Thread Massimo Di Pierro
I've think we should adopt the convention that [[ ]] are yatl delimiters and {{ 
}} are Vue delimiters.

-- 
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/a2bb2e27-9a07-4e44-b99c-9adca2a64c4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: RESTful service with access control

2019-05-14 Thread Massimo Di Pierro
You may want to see my other post about the new policy based DBAPI.

On Monday, 13 May 2019 09:28:11 UTC-7, Jim S wrote:
>
> Hi
>
> I'm setting up a REST service that requires authentication.  I'm following 
> the example here:
>
> http://web2py.com/books/default/chapter/29/10/services#Access-Control
>
> Here is the example with basic login:
>
> auth.settings.allow_basic_login = True
>
> @auth.requires_login()
> @request.restful()
> def api(): 
> def GET(s):
> return 'access granted, you said %s' % s 
> return locals()
>
> However, I'd like to use email authentication instead of basic_login.  
>
> When I remove the first line, and pass proper email address and password, 
> I get a 403 return code.
>
> Anyone had success with a RESTful service using email authentication?
>
> -Jim
>

-- 
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/e566fd9f-dd15-4225-b3d3-c5852d1c07c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: new DBAPI in pydal for both web2py and web3py

2019-05-14 Thread Massimo Di Pierro
For more examples look at the tests:
https://github.com/web2py/pydal/blob/master/tests/dbapi.py



On Monday, 13 May 2019 23:18:42 UTC-7, Massimo Di Pierro wrote:
>
> You may have missed this but there is a new functionality in PyDAL that 
> allows you to create very powerful APIs. It is called DBAPI.
> It is still not 100% stable but it is working and I could use some help 
> testing it.
> web3py's equivalent of appadmin will be called dbadmin (90% done) and it 
> is based on DBAPI.
> Even if primarily designed for web3py it works for web2py too and you can 
> find some preliminary examples below.
> Hope it is self-explanatory.
>
> DBAPI EXAMPLES 
>
> Inspired by GraphQL but not quite the same
>
> Less powerful but simpler to use
>
> Self descriptive (@model=True) and policy based (policy set serverside)
>
> Support complex queries like: 
>
>- name.eq=Clark Kent
>- name.ne=Clark Kent
>- name.gt=Clark Kent
>- name.lt=Clark Kent
>- name.ge=Clark Kent
>- name.le=Clark Kent
>- name.startswith=Clark
>- name.contains=Kent
>- not.real_identity.name.contains=Wayne
>- not.superhero.tag.superpower.description.eq=Flight
>
> Support de-normalization: 
>
>- @lookup=real_identity
>- @lookup=real_identity[name]
>- @lookup=real_identity[name,job]
>- @lookup=identity:real_identity[name,job]
>- @lookup=identity!:real_identity[name,job]
>- @lookup=superhero.tag
>- @lookup=superhero.tag[strength]
>- @lookup=superhero.tag[strength].superpower
>- @lookup=superhero.tag[strength].superpower.description
>
> Fast. Even the most complex query is implemented with at most 2 selects + 
> 1 select for each denormalized link table
> Example Model 
>
> db.define_table(
> 'person',
> Field('name'),
> Field('job'))
>
> db.define_table(
> 'superhero',
> Field('name'),
> Field('real_identity', 'reference person'))
>
> db.define_table(
> 'superpower',
> Field('description'))
>
> db.define_table(
> 'tag',
> Field('superhero', 'reference superhero'),
> Field('superpower', 'reference superpower'),
> Field('strength', 'integer'))
>
> Example Controller 
>
> from pydal.dbapi import DBAPI, Policy
> policy = Policy()
> policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
> post_vars:True, allowed_patterns=['*'])
> policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
> policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
> policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
> post_vars:False)
>
> def api():
> return DBAPI(db, policy)(request.method, request.args(0), request.args(1),
>  request.get_vars, request.post_vars)
>
> Example GET URLs 
> /superheroes/default/api.json/superhero 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": 1,
> "name": "Superman",
> "id": 1
> },
> {
> "real_identity": 2,
> "name": "Spiderman",
> "id": 2
> },
> {
> "real_identity": 3,
> "name": "Batman",
> "id": 3
> }
> ],
> "timestamp": "2019-05-14T06:14:06.764966",
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero&@model=true 
>
> {
> "status": "error",
> "timestamp": "2019-05-14T06:14:06.997662",
> "message": "Invalid table name: superhero_amp_@model=true",
> "code": 400,
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero?@lookup=real_identity 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": {
> "name": "Clark Kent",
> "job": "Journalist",
> "id": 1
> },
> "name": "Superman",
> "id": 1
> },
> {
> "real_identity": {
> "name": "Peter Park",
> "job": "Photographer",
> "id": 2
> },
> "name": "Spiderman",
> "id": 2
> },
> {
> "real_identity": {
> "name": "Bruce Wayne",
> "job": "CEO",
> "id": 3
> },
> "name": "Batman",
> "id": 3
> }
> ],
> "timestamp": "2019-05-14T06:14:06.931746",
> "api_version": "0.1"
> }
>
> /superheroes/default/api.json/superhero?@lookup=identity:real_identity 
>
> {
> "count": 3,
> "status": "success",
> "code": 200,
> "items": [
> {
> "real_identity": 1,
> "name": "Superman",
> "id": 1,
> "identity": {
> "name": "Clark Kent",
> "job": "Journalist",
> "id": 1
> }
> },
> {
>  

[web2py] new DBAPI in pydal for both web2py and web3py

2019-05-14 Thread Massimo Di Pierro
You may have missed this but there is a new functionality in PyDAL that 
allows you to create very powerful APIs. It is called DBAPI.
It is still not 100% stable but it is working and I could use some help 
testing it.
web3py's equivalent of appadmin will be called dbadmin (90% done) and it is 
based on DBAPI.
Even if primarily designed for web3py it works for web2py too and you can 
find some preliminary examples below.
Hope it is self-explanatory.

DBAPI EXAMPLES 

Inspired by GraphQL but not quite the same

Less powerful but simpler to use

Self descriptive (@model=True) and policy based (policy set serverside)

Support complex queries like: 

   - name.eq=Clark Kent
   - name.ne=Clark Kent
   - name.gt=Clark Kent
   - name.lt=Clark Kent
   - name.ge=Clark Kent
   - name.le=Clark Kent
   - name.startswith=Clark
   - name.contains=Kent
   - not.real_identity.name.contains=Wayne
   - not.superhero.tag.superpower.description.eq=Flight

Support de-normalization: 

   - @lookup=real_identity
   - @lookup=real_identity[name]
   - @lookup=real_identity[name,job]
   - @lookup=identity:real_identity[name,job]
   - @lookup=identity!:real_identity[name,job]
   - @lookup=superhero.tag
   - @lookup=superhero.tag[strength]
   - @lookup=superhero.tag[strength].superpower
   - @lookup=superhero.tag[strength].superpower.description

Fast. Even the most complex query is implemented with at most 2 selects + 1 
select for each denormalized link table
Example Model 

db.define_table(
'person',
Field('name'),
Field('job'))

db.define_table(
'superhero',
Field('name'),
Field('real_identity', 'reference person'))

db.define_table(
'superpower',
Field('description'))

db.define_table(
'tag',
Field('superhero', 'reference superhero'),
Field('superpower', 'reference superpower'),
Field('strength', 'integer'))

Example Controller 

from pydal.dbapi import DBAPI, Policy
policy = Policy()
policy.set('*', 'GET', authorize=lambda tablename, id, get_vars, 
post_vars:True, allowed_patterns=['*'])
policy.set('*', 'PUT', authorize=lambda tablename, id, get_vars, 
post_vars:False)
policy.set('*', 'POST', authorize=lambda tablename, id, get_vars, 
post_vars:False)
policy.set('*', 'DELETE', authorize=lambda tablename, id, get_vars, 
post_vars:False)

def api():
return DBAPI(db, policy)(request.method, request.args(0), request.args(1),
 request.get_vars, request.post_vars)

Example GET URLs 
/superheroes/default/api.json/superhero 

{
"count": 3,
"status": "success",
"code": 200,
"items": [
{
"real_identity": 1,
"name": "Superman",
"id": 1
},
{
"real_identity": 2,
"name": "Spiderman",
"id": 2
},
{
"real_identity": 3,
"name": "Batman",
"id": 3
}
],
"timestamp": "2019-05-14T06:14:06.764966",
"api_version": "0.1"
}

/superheroes/default/api.json/superhero&@model=true 

{
"status": "error",
"timestamp": "2019-05-14T06:14:06.997662",
"message": "Invalid table name: superhero_amp_@model=true",
"code": 400,
"api_version": "0.1"
}

/superheroes/default/api.json/superhero?@lookup=real_identity 

{
"count": 3,
"status": "success",
"code": 200,
"items": [
{
"real_identity": {
"name": "Clark Kent",
"job": "Journalist",
"id": 1
},
"name": "Superman",
"id": 1
},
{
"real_identity": {
"name": "Peter Park",
"job": "Photographer",
"id": 2
},
"name": "Spiderman",
"id": 2
},
{
"real_identity": {
"name": "Bruce Wayne",
"job": "CEO",
"id": 3
},
"name": "Batman",
"id": 3
}
],
"timestamp": "2019-05-14T06:14:06.931746",
"api_version": "0.1"
}

/superheroes/default/api.json/superhero?@lookup=identity:real_identity 

{
"count": 3,
"status": "success",
"code": 200,
"items": [
{
"real_identity": 1,
"name": "Superman",
"id": 1,
"identity": {
"name": "Clark Kent",
"job": "Journalist",
"id": 1
}
},
{
"real_identity": 2,
"name": "Spiderman",
"id": 2,
"identity": {
"name": "Peter Park",
"job": "Photographer",
"id": 2
}
},
{
"real_identity": 3,
"name": "Batman",
"id": 3,
"identity": {
"name": "Bruce Wayne",
"job": "CEO",
"id": 3
}
}
],
"timestamp":