[web2py] Re: web3py again....

2019-03-28 Thread Massimo Di Pierro
People asked about the Goal. My goal is:

- preserve as much as possible of web2py syntax that we love
- much faster
- simpler code base (so far less than 300 lines of code in a single file)
- move more logic to apps and js libs
- web2py's goal was to make it simple to build complex web apps. web3py 
goal is the same but show that we learned from our mistakes (some, not all).

Some benchmarks on my laptop below. Real apps are likely to be slower 
because the actions may do more computation but this shows that the 
overhead of processing a simple template, a sessions, and performing a DB 
transaction, are about 1ms or less. Details depend on the architecture.

$ python3 web3py.py applications --workers 4

## bencharking a memoized API

$ ab -n 4000 -c 4 http://127.0.0.1:8000/todo/uuid
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Completed 4000 requests
Finished 4000 requests


Server Software:gunicorn/19.9.0
Server Hostname:127.0.0.1
Server Port:8000

Document Path:  /todo/uuid
Document Length:36 bytes

Concurrency Level:  4
Time taken for tests:   2.149 seconds
Complete requests:  4000
Failed requests:0
Total transferred:  784000 bytes
HTML transferred:   144000 bytes
Requests per second:1861.48 [#/sec] (mean)
Time per request:   2.149 [ms] (mean)
Time per request:   0.537 [ms] (mean, across all concurrent requests)
Transfer rate:  356.30 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   4.8  0 303
Processing: 12   8.3  2 305
Waiting:11   6.8  1 304
Total:  12   9.6  2 305

Percentage of the requests served within a certain time (ms)
  50%  2
  66%  2
  75%  2
  80%  2
  90%  3
  95%  3
  98%  4
  99%  4
 100%305 (longest request)

## bencharking a page with a simple template and session counter

$ ab -n 4000 -c 4 http://127.0.0.1:8000/todo/index
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Completed 4000 requests
Finished 4000 requests


Server Software:gunicorn/19.9.0
Server Hostname:127.0.0.1
Server Port:8000

Document Path:  /todo/index
Document Length:828 bytes

Concurrency Level:  4
Time taken for tests:   4.448 seconds
Complete requests:  4000
Failed requests:0
Total transferred:  4864636 bytes
HTML transferred:   3312000 bytes
Requests per second:899.23 [#/sec] (mean)
Time per request:   4.448 [ms] (mean)
Time per request:   1.112 [ms] (mean, across all concurrent requests)
Transfer rate:  1067.98 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   2
Processing: 24   2.3  3  47
Waiting:24   2.1  3  46
Total:  24   2.3  4  47

Percentage of the requests served within a certain time (ms)
  50%  4
  66%  4
  75%  5
  80%  5
  90%  7
  95%  8
  98% 12
  99% 14
 100% 47 (longest request)

## bencharking a GET api that accesses pydal + sqlite

$ ab -n 4000 -c 4 http://127.0.0.1:8000/todo/api
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Completed 4000 requests
Finished 4000 requests


Server Software:gunicorn/19.9.0
Server Hostname:127.0.0.1
Server Port:8000

Document Path:  /todo/api
Document Length:324 bytes

Concurrency Level:  4
Time taken for tests:   3.349 seconds
Complete requests:  4000
Failed requests:0
Total transferred:  194 bytes
HTML transferred:   1296000 bytes
Requests per second:1194.23 [#/sec] (mean)
Time per request:   3.349 

[web2py] Re: web3py again....

2019-03-28 Thread Massimo Di Pierro
My thought exactly.

On Thursday, 28 March 2019 18:46:47 UTC-7, Joe Barnhart wrote:
>
> I agree that back porting web2py code should be straightforward (after 
> all, it's not rocket science :-D).  But maybe we should revisit those 
> modules and pare them down to minimalist proportions.  I really need Auth, 
> complete with user roles and groups, but there's probably a better way to 
> minimize/abstract and provide a growth path.
>
> Plus, with py3 and web2py in hand, its not like there's a fire that needs 
> putting out.
>
> -- Joe
>
>
> On Thursday, March 28, 2019 at 2:16:15 AM UTC-7, Massimo Di Pierro wrote:
>>
>> I know this comes up once in a while but ...
>>
>> https://github.com/web2py/web3py
>>
>> what do you think? 
>>
>> It is very preliminary but I will have an admin soon.
>> Backporting SQLFORM, grid and Auth, should not be that complicated, 
>> although I think we can do better.
>>
>> Massimo
>>
>>

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


Re: [web2py] Re: web3py again....

2019-03-28 Thread Kevin Keller
I like the general direction of it.
Auth and sqlform backported would of course be great.

With bottle in the middle we can tap into the bottle community extensions
but also gain extra flexibility..

Combined with web2py sqlform and Auth etc could be a real winner

On Fri, 29 Mar 2019, 02:46 Joe Barnhart,  wrote:

> I agree that back porting web2py code should be straightforward (after
> all, it's not rocket science :-D).  But maybe we should revisit those
> modules and pare them down to minimalist proportions.  I really need Auth,
> complete with user roles and groups, but there's probably a better way to
> minimize/abstract and provide a growth path.
>
> Plus, with py3 and web2py in hand, its not like there's a fire that needs
> putting out.
>
> -- Joe
>
>
> On Thursday, March 28, 2019 at 2:16:15 AM UTC-7, Massimo Di Pierro wrote:
>>
>> I know this comes up once in a while but ...
>>
>> https://github.com/web2py/web3py
>>
>> what do you think?
>>
>> It is very preliminary but I will have an admin soon.
>> Backporting SQLFORM, grid and Auth, should not be that complicated,
>> although I think we can do better.
>>
>> Massimo
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: web3py again....

2019-03-28 Thread Joe Barnhart
I agree that back porting web2py code should be straightforward (after all, 
it's not rocket science :-D).  But maybe we should revisit those modules 
and pare them down to minimalist proportions.  I really need Auth, complete 
with user roles and groups, but there's probably a better way to 
minimize/abstract and provide a growth path.

Plus, with py3 and web2py in hand, its not like there's a fire that needs 
putting out.

-- Joe


On Thursday, March 28, 2019 at 2:16:15 AM UTC-7, Massimo Di Pierro wrote:
>
> I know this comes up once in a while but ...
>
> https://github.com/web2py/web3py
>
> what do you think? 
>
> It is very preliminary but I will have an admin soon.
> Backporting SQLFORM, grid and Auth, should not be that complicated, 
> although I think we can do better.
>
> Massimo
>
>

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


[web2py] Re: Not my type

2019-03-28 Thread Joe Barnhart
Hi Al --

First off, welcome to the web2py group.  Next, it's not clear from your 
message just what the question is.  If you can elaborate on (a) what you 
did, (b) what you expected, and (c) what you got, I'm sure someone here can 
help

Warm regards,

Joe B.

On Thursday, March 28, 2019 at 2:10:50 AM UTC-7, Al Hart wrote:
>
> Hi folks, if you'll pardon the corny title, I am brand new to web2py (so 
> excited to discover it) and I'm just working may way through the book. In 
> Chapter two, the section on types, I tried to run the examples, but I got 
> error messages. Googling around it seemed to work better if I went one of 
> two ways:
>
>
>1. a = 3
>type(a)
>2. a = 4 
>print(type(a))
>
>
> I'm on Ubuntu 18.04. Not sure if the example is based on python 3? If not, 
> is this the best way to suggest updates to the book or should we just try a 
> pull request? 
>

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


Re: [web2py] web3py again....

2019-03-28 Thread 黄祥
interested in github readme :

   - it is not as good as web2py yet, but it is 10-20x faster

perhaps could you share which benchmark method or tools to get this 
conclusion (compare with similar web2py todo apps) ? 

best regards,
stifan

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


Re: [web2py] web3py again....

2019-03-28 Thread junderhill
For authentication, Okta, Azure AD B2C, etc. are options that offload a lot 
of trouble, but I like having a fully-functional Auth built-in and we do 
use it in some projects.  It needs full OIDC support.  YMMV.  We build 
scalable back ends with Web2py using Postgres and Nginx.

John

On Thursday, March 28, 2019 at 12:16:58 PM UTC-7, Marcelo Huerta wrote:
>
> El jueves, 28 de marzo de 2019, 6:57:08 (UTC-3), José L. escribió:
>>
>>
>>- sqlform and grid are one of the key points for web2py. It's one of 
>>the main reasons to use it instead of other frameworks as development is 
>>really quick. However I think nowadays a backport from web2py is not a 
>> good 
>>idea. We should provide something optional based only on vue.js. As you 
>>say, we can do it better.
>>
>>
> SQLFORM and grid were the main selling points to me. Something similar 
> should be provided, surely.
>  
>
>>
>>- auth is not as important in my experience. It has never been the 
>>reason to pick web2py and there are other ways to do it.
>>
>> I love auth, actually. Maybe I haven't investigated enough, but what 
> other ways to do it are preferable in your opinion?
>

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


[web2py] Re: Using the results of a variable returned by one function in another function

2019-03-28 Thread mostwanted
I put up this line 
rslts=db((db.business.place==results.id) & (db.business.services==request.
vars.services_id)).select()
The good thing is i am not getting any errors anymore but now the page is 
displaying nothing at all! I am not getting any results in my view

*CONTROLLER*

def Results():
results=db.locations(request.args(0))
rslts=db((db.business.place==results.id) & (db.business.services==
request.vars.services_id)).select()
services=len(rslts)
return locals()

*VIEW*
{{extend 'layout.html'}}

{{for company in rslts:}}
The company is: {{=company.rslts}}
{{pass}}


On Thursday, March 28, 2019 at 1:23:20 PM UTC+2, Leonel Câmara wrote:
>
> Just send the services id in the URL either as an arg or a var and then do 
> something like this:
>
> rslts=db((db.business.place==results.id) & 
> (db.business.services==request.vars.services_id)).select()
>
> Notice that I also removed a query you had in the select call, which was 
> wrong.
>

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


[web2py] Re: Using the results of a variable returned by one function in another function

2019-03-28 Thread mostwanted
I put up this line 
rslts=db((db.business.place==results.id) & (db.business.services==request.
vars.services_id)).select()
The good thing is i am not getting any errors anymore but now the page is 
displaying nothing at all! I am not getting any results in my view

*CONTROLLER*

def Results():
results=db.locations(request.args(0))
rslts=db((db.business.place==results.id) & (db.business.services==
request.vars.services_id)).select()
services=len(rslts)
return locals()

*VIEW*
{{extend 'layout.html'}}

{{for company in rslts:}}
The company is: {{=company.rslts}}
{{pass}}






On Thursday, March 28, 2019 at 1:23:20 PM UTC+2, Leonel Câmara wrote:
>
> Just send the services id in the URL either as an arg or a var and then do 
> something like this:
>
> rslts=db((db.business.place==results.id) & 
> (db.business.services==request.vars.services_id)).select()
>
> Notice that I also removed a query you had in the select call, which was 
> wrong.
>

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


[web2py] Grid sorting questions (referenced fields and case sensitive)

2019-03-28 Thread João Matos
Hello,

I have these 2 tables opt and opt_cat, where opt depends on opt_cat for the 
category name and other settings.

db.define_table('opt',
Field('name', 'string', label=T('Name'), length=NAME_LEN, 
notnull=True,
  required=True, unique=True),
Field('opt_cat_id', 'reference opt_cat', label=T('Category'
),
  notnull=True, required=True),
auth.signature,
format='%(name)s',
)

db.define_table('opt_cat',
Field('name', 'string', label=T('Name in Portuguese'), 
length=NAME_LEN,
  notnull=True, required=True, unique=True),
Field('name_en', 'string', label=T('Name in English'),
  length=NAME_LEN, notnull=True, required=True, unique=
True),
Field('mandatory', 'boolean', default=False,
  label=T('Mandatory'), notnull=True, required=True),
Field('one_opt_only', 'boolean', default=False,
  label=T('One option only'), notnull=True, required=
True),
auth.signature,
format='%(name)s',
)

I was testing grid sort and found that a grid like this

table = db.opt

grid = SQLFORM.grid(
table,
csv=False,
details=False,
maxtextlength=GRID_COL_LEN_FOR_TEXT,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # Form only.
orderby=db.opt.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
)

will sort by opt_cat_id and not by the opt_cat.name that is shown.
The only solution I've found is to make a join between the 2 columns and 
show the client.name directly.

query = db.opt.opt_cat_id == db.opt_cat.id

grid = SQLFORM.grid(
query,
csv=False,
details=False,
field_id=db.opt.id,
fields=[
db.opt.name,
db.opt_cat.name,
db.opt_cat.name_en,
],
headers={'opt_cat.name': T('Category'), 'opt_cat.name_en': T(
'Category')},
maxtextlength=GRID_COL_LEN_FOR_TEXT,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # Form only.
orderby=db.opt.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
)


Is there a better solution?

Another question is that I see that the sorting is ASCII based (small case 
after upper case).

Is there any way to make it sort without being case sensitive?


Thanks,

JM

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


Re: [web2py] web3py again....

2019-03-28 Thread Marcelo Huerta
El jueves, 28 de marzo de 2019, 6:57:08 (UTC-3), José L. escribió:
>
>
>- sqlform and grid are one of the key points for web2py. It's one of 
>the main reasons to use it instead of other frameworks as development is 
>really quick. However I think nowadays a backport from web2py is not a 
> good 
>idea. We should provide something optional based only on vue.js. As you 
>say, we can do it better.
>
>
SQLFORM and grid were the main selling points to me. Something similar 
should be provided, surely.
 

>
>- auth is not as important in my experience. It has never been the 
>reason to pick web2py and there are other ways to do it.
>
> I love auth, actually. Maybe I haven't investigated enough, but what other 
ways to do it are preferable in your opinion?

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


[web2py] Re: Is there a way to differentiate between a form refresh (F5) and a submit that calls back the form?

2019-03-28 Thread João Matos
Had to revert this

elif request.post_vars.modified_on != str(form.record.modified_on):
 session.flash = T('Record was changed while you were editing. '
   'This is the updated record.')
 redirect(URL(args=request.args, vars=request.get_vars, user_signature=
True))

to this

elif request.post_vars.modified_on != str(db.client(request.vars.id).
modified_on):
 session.flash = T('Record was changed while you were editing. '
   'This is the updated record.')
 redirect(URL(args=request.args, vars=request.get_vars, user_signature=
True))

because if the record was changed by another user while the this user was 
editing and the this user made a mistake in a field that was auto-checked 
by web2py (using the requires from the model file), the upper version would 
not catch that the record had been changed and would save the record 
instead of showing the message.

Per your suggestion, I have this in the index function (where the grid is 
created):
if 'edit' in request.args:
form = grid.update_form
form['hidden'].update(modified_on=form.record.modified_on)



quinta-feira, 28 de Março de 2019 às 13:01:46 UTC, Anthony escreveu:
>
> which I changed now to this
>>
>>   elif request.post_vars.modified_on != str(db.client(request.vars.id).
>> modified_on):
>>  session.flash = T('Record was changed while you were editing. '
>>'This is the updated record.')
>>  redirect(URL(args=request.args, vars=request.get_vars, 
>> user_signature=True))
>>
>
> Why not put the above inside the "edit" condition, as it is not relevant 
> otherwise (and won't work on record creation)? Also, given that this is in 
> the onvalidation function, why not use form.record rather than 
> unnecessarily re-selecting the record via db.client(request.vars.id)?
>
> Anthony
>

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


[web2py] Grid sorting bug when default orderby column type is date

2019-03-28 Thread João Matos
Hello,

I have this action

@auth.requires(auth.has_membership(CHECKER_ROLE) or auth.has_membership(
SUPERVISOR_ROLE))
def list_tags_to_issue():
"""List tags to issue.

:return: Dict with grid.
"""

   query = ((db.wo.is_active == True)
& (db.wo.tags_issued == False)
& (db.wo.pies_verified == False)
& (db.wo.equipment_id == db.equipment.id))

grid = SQLFORM.grid(
query,
create=False,
csv=False,
deletable=False,
details=False,
editable=False,
fields=[db.wo.est_finish,
db.equipment.name,
db.wo.sn,
db.wo.opts,
db.wo.finished,  # Necessary dummy entry.
db.wo.canceled_on,  # Necessary dummy entry.
db.wo.canceled_by,  # Necessary dummy entry.
db.wo.cancel_approved_by,  # Necessary dummy entry.
],
orderby=db.wo.est_finish,
)

return dict(grid=grid)

With this view

{{extend 'layout.html'}}

{{=T('List tags to issue')}}

{{=grid}}

{{if DEV:
=response.toolbar()
pass}}

If I try to change the sorting in the default orderby column (est_finish) 
it doesn't occur.
The URL is changed from  ...orderby=do.wo.est_finish to 
...orderby=~db.wo.est_finish, but the grid doesn't change.
When I see the db stats, the SQL command also didn't change.
The SQL command is always

SELECT "wo"."est_finish", "equipment"."name", "wo"."sn", "wo"."opts", 
"wo"."finished", "wo"."canceled_on", "wo"."canceled_by", 
"wo"."cancel_approved_by", "wo"."id" 
FROM "wo", "equipment" 
WHERE "wo"."is_active" = 'T') AND ("wo"."tags_issued" = 'F')) AND 
("wo"."pies_verified" = 'F')) AND ("wo"."equipment_id" = "equipment"."id")) 
ORDER BY "wo"."est_finish", "wo"."id" LIMIT 20 OFFSET 0;

no matter the URL changing from ...orderby=do.wo.est_finish to 
...orderby=~db.wo.est_finish.

This is one of 3 different views (all have in common a orderby with a date 
column) that show this problem. All others work correctly.

If I remove the orderby parameter from the grid or change it to a non-date one, 
everything works, including the sorting of the date column.

Any ideas?

Thanks,

JM


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


[web2py] Re: session.connect()

2019-03-28 Thread 'Annet' via web2py-users
Hi Anthony,

Thanks for your reply.  

I added 

response.cookies['session_id_cms']['domain'] = '.yourdomain.com 

'

to a model file in the cms app. And in the init app I have

session.connect(request, response, masterapp="controlpanel")

The apps do share the session cookie both locally and in production:

response.session_id_name


returns session_id_cms

However, locally auth.is_logged_in() returns True but in production it
returns False and auth.user returns None.

I have no idea what causes the difference in behaviour. I hope you do.


Kind regards,

Annet

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


[web2py] Re: web3py again....

2019-03-28 Thread 黄祥
great, tested it

*environment*
$ uname
Darwin
$ python -V
Python 3.7.2

*steps*
git clone https://github.com/web2py/web3py
cd web3py
pip install -r requirements.txt
python web3py.py applications/
open http://localhost:8000/todo/index

*result in browser*
can add (save) and delete data in browser

*result in terminal*
Traceback (most recent call last):
  File "/Users/sugizo/Downloads/learn/web3py/web3py.py", line 149, in load
self.data = jwt.decode(enc_data, self.secret, algorithms=[self.algorithm
])
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/jwt/api_jwt.py"
, line 84, in decode
payload, _, _, _ = self._load(jwt)
  File 
"/Users/sugizo/miniconda3/envs/python3_test/lib/python3.7/site-packages/jwt/api_jws.py"
, line 177, in _load
binary_type))
jwt.exceptions.DecodeError: Invalid token type. Token must be a 

best regards,
stifan

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


[web2py] Re: Is there a way to differentiate between a form refresh (F5) and a submit that calls back the form?

2019-03-28 Thread João Matos
Made the changes you suggested. Thanks Anthony.

This is an example of my new onvalidation, just in case you have other tips 
:)

def on_validation(form: SQLFORM) -> None:
"""Used in the edit form, including when creating and deleting.

:param form: Form.
"""
# Fix for SQLite instead of for_update=True. When for_update is
# fixed for SQLite, only the first SELECT in the function should
# have for_update=True.
while True:
try:
# SQLite only does database lock.
db.executesql('BEGIN IMMEDIATE TRANSACTION')
break
except sqlite3.OperationalError:
sleep(0.5)

if request.args and request.args[0] == 'new':
if db.wo_counter(year_=request.now.year):
form.errors.last_assigned = T('Counter already exists')
else:  # Edit/delete.
if (not form.record.is_active and not form.vars.delete_this_record
and auth.has_membership(SUPERVISOR_ROLE)):
db.wo_counter(request.vars.id).update_record(
cancel_approved_by=None,
canceled_by=None,
canceled_on=None,
is_active=True,
)

db.commit()

session.flash = T('Record was activated.')
redirect(URL('index', user_signature=True))
elif not form.record.is_active:
session.flash = T('Record was deleted while you were editing.')
redirect(URL('index', user_signature=True))
elif (request.post_vars.modified_on != str(form.record.modified_on
)):
session.flash = T('Record was changed while you were editing. '
  'This is the updated record.')
redirect(URL(args=request.args, vars=request.get_vars, 
user_signature=True))
elif db.wo_counter(request.args[-1]).last_assigned > form.vars.
last_assigned:
form.errors.last_assigned = T('New value must >= than old.')
elif form.vars.delete_this_record:
db.wo_counter(request.vars.id).update_record(
cancel_approved_by=auth.user_id,
canceled_by=auth.user_id,
canceled_on=request.now,
is_active=False,
)

db.commit()

session.flash = T('Done.')
redirect(URL(user_signature=True))







quinta-feira, 28 de Março de 2019 às 13:01:46 UTC, Anthony escreveu:
>
> which I changed now to this
>>
>>   elif request.post_vars.modified_on != str(db.client(request.vars.id).
>> modified_on):
>>  session.flash = T('Record was changed while you were editing. '
>>'This is the updated record.')
>>  redirect(URL(args=request.args, vars=request.get_vars, 
>> user_signature=True))
>>
>
> Why not put the above inside the "edit" condition, as it is not relevant 
> otherwise (and won't work on record creation)? Also, given that this is in 
> the onvalidation function, why not use form.record rather than 
> unnecessarily re-selecting the record via db.client(request.vars.id)?
>
> Anthony
>

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


[web2py] Re: Is there a way to differentiate between a form refresh (F5) and a submit that calls back the form?

2019-03-28 Thread Anthony

>
> which I changed now to this
>
>   elif request.post_vars.modified_on != str(db.client(request.vars.id).
> modified_on):
>  session.flash = T('Record was changed while you were editing. '
>'This is the updated record.')
>  redirect(URL(args=request.args, vars=request.get_vars, user_signature
> =True))
>

Why not put the above inside the "edit" condition, as it is not relevant 
otherwise (and won't work on record creation)? Also, given that this is in 
the onvalidation function, why not use form.record rather than 
unnecessarily re-selecting the record via db.client(request.vars.id)?

Anthony

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


[web2py] Re: Strange error on grid edit

2019-03-28 Thread João Matos
I was able to "solve" it with a kludge.
I changed this

_href=URL('get_approval', args=[row.opt.id], user_signature=True),

to this

_href=URL('get_approval', args=[str(row).split("'id': ")[1].split(',')[0]], 
user_signature=True),

and now everything works.

But I still don't understand why the strange error.

Any ideas?

Thanks,

JM


quinta-feira, 28 de Março de 2019 às 12:41:23 UTC, João Matos escreveu:
>
> Hello,
>
> I have this grid
>
> # Hidden fields in grid and edit/view form.
> db.opt.canceled_on.readable = False
> db.opt.canceled_by.readable = False
> db.opt.cancel_approved_by.readable = False
>
> query = ((db.opt.is_active == True) & (db.opt.opt_cat_id == db.
> opt_cat.id))
>
> grid = SQLFORM.grid(
> query,
> csv=False,
> deletable=False,
> details=False,
> fields=[
> db.opt.id,
> db.opt.name,
> db.opt_cat.name,
> db.opt_cat.name_en,
> ],
> headers={'opt_cat.name': T('Category'), 'opt_cat.name_en': T(
> 'Category')},
> links=[
> lambda row: A(
> SPAN(T('Delete'), _class='buttontext button', _title=
> 'Delete'),
> _href=URL('get_approval', args=[row.opt.id], 
> user_signature=True),
> _class='button btn btn-default btn-secondary',
> ),
> ],
> maxtextlength=GRID_COL_LEN_FOR_TEXT,
> ondelete=on_delete,  # Grid only.
> onvalidation=on_validation,  # Form only.
> orderby=db.opt.name,
> paginate=session.auth.user.pagination,
> # represent_none='',  # Grid and view form only.
> )
>
> If I select the Delete button (link) everything works as expected.
>
> If I select the auto-created Edit button, web2py returns this strange error
>
> ERROR:web2py:Traceback (most recent call last):
>   File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 107, in 
> __getattr__
>
> return self.__getitem__(k)
>   File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 94, in 
> __getitem__
> raise KeyError(key)
> KeyError: 'opt'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "c:\web2py\applications\ajc\controllers/opt.py", line 537, in 
> 
>   File "C:\web2py\gluon\globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "C:\web2py\gluon\tools.py", line 3868, in f
> return action(*a, **b)
>   File "c:\web2py\applications\ajc\controllers/opt.py", line 245, in index
> paginate=session.auth.user.pagination,
>   File "C:\web2py\gluon\sqlhtml.py", line 2583, in grid
> res = DIV(buttons(view=details, record=record),
>   File "C:\web2py\gluon\sqlhtml.py", line 2505, in buttons
> elif link(record):
>   File "c:\web2py\applications\ajc\controllers/opt.py", line 237, in 
> 
> _href=URL('get_approval', args=[row.opt.id], user_signature=True),
>   File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 109, in 
> __getattr__
>
> raise AttributeError
> AttributeError
>
>
> If I comment the links parameter, the edit works.
>
> Thanks,
>
> JM
>
>
>
>

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


[web2py] Strange error on grid edit

2019-03-28 Thread João Matos
Hello,

I have this grid

# Hidden fields in grid and edit/view form.
db.opt.canceled_on.readable = False
db.opt.canceled_by.readable = False
db.opt.cancel_approved_by.readable = False

query = ((db.opt.is_active == True) & (db.opt.opt_cat_id == db.
opt_cat.id))

grid = SQLFORM.grid(
query,
csv=False,
deletable=False,
details=False,
fields=[
db.opt.id,
db.opt.name,
db.opt_cat.name,
db.opt_cat.name_en,
],
headers={'opt_cat.name': T('Category'), 'opt_cat.name_en': T(
'Category')},
links=[
lambda row: A(
SPAN(T('Delete'), _class='buttontext button', _title=
'Delete'),
_href=URL('get_approval', args=[row.opt.id], 
user_signature=True),
_class='button btn btn-default btn-secondary',
),
],
maxtextlength=GRID_COL_LEN_FOR_TEXT,
ondelete=on_delete,  # Grid only.
onvalidation=on_validation,  # Form only.
orderby=db.opt.name,
paginate=session.auth.user.pagination,
# represent_none='',  # Grid and view form only.
)

If I select the Delete button (link) everything works as expected.

If I select the auto-created Edit button, web2py returns this strange error

ERROR:web2py:Traceback (most recent call last):
  File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 107, in 
__getattr__

return self.__getitem__(k)
  File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 94, in 
__getitem__
raise KeyError(key)
KeyError: 'opt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "c:\web2py\applications\ajc\controllers/opt.py", line 537, in 

  File "C:\web2py\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 3868, in f
return action(*a, **b)
  File "c:\web2py\applications\ajc\controllers/opt.py", line 245, in index
paginate=session.auth.user.pagination,
  File "C:\web2py\gluon\sqlhtml.py", line 2583, in grid
res = DIV(buttons(view=details, record=record),
  File "C:\web2py\gluon\sqlhtml.py", line 2505, in buttons
elif link(record):
  File "c:\web2py\applications\ajc\controllers/opt.py", line 236, in 

SPAN(str(row.opt.id) + T('Delete'), _class='buttontext button', _title=
'Dele
te'),
  File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 109, in 
__getattr__

raise AttributeError
AttributeError

If I comment the links parameter, the edit works.

Thanks,

JM



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


[web2py] Re: Using the results of a variable returned by one function in another function

2019-03-28 Thread Leonel Câmara
Just send the services id in the URL either as an arg or a var and then do 
something like this:

rslts=db((db.business.place==results.id) & 
(db.business.services==request.vars.services_id)).select()

Notice that I also removed a query you had in the select call, which was 
wrong.

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


[web2py] Re: Is there a way to differentiate between a form refresh (F5) and a submit that calls back the form?

2019-03-28 Thread João Matos

Thanks for the tip.

I was using this (it's included in the above code)

  elif request.post_vars.modified_on != str(db.client(request.vars.id).
modified_on):
form.errors.code = T('Record was changed while you were editing. '
 'Press F5 to refresh and press Resend in the '
 'browser question.')

which I changed now to this

  elif request.post_vars.modified_on != str(db.client(request.vars.id).
modified_on):

session.flash = T('Record was changed while you were editing. '
  'This is the updated record.')
redirect(URL(args=request.args, vars=request.get_vars, 
user_signature=True))


quinta-feira, 28 de Março de 2019 às 01:57:29 UTC, Anthony escreveu:
>
> I don't see any code that checks for record change, but you could do 
> something like:
>
> elif request.args and request.args[0] == 'edit':
> if request.vars.modified_on != str(form.record.modified_on):
> session.flash = 'Record change detected. Please try again.'
> redirect(URL(args=request.args, vars=request.get_vars))
>
> That will redirect to the same URL, which will load the same record (with 
> the updated data), and show the message after redirect.
>
> Anthony
>
> On Wednesday, March 27, 2019 at 3:06:16 PM UTC-4, João Matos wrote:
>>
>> This is my code for the another table (it has the same situation, but 
>> without using a SQLFORM.factory).
>> I posted this instead of the SQLFORM.factory, because it is simpler code.
>>
>> My index function contains the grid
>>
>> grid = SQLFORM.grid(
>> query,
>> csv=False, deletable=False, details=False,
>> links=[
>> lambda row: A(
>> SPAN(T('Delete'), _class='buttontext button', _title=
>> 'Delete'),
>> _href=URL('get_approval', args=[row.id], 
>> user_signature=True),
>> _class='button btn btn-default btn-secondary',
>> ),
>> ],
>> onvalidation=on_validation,  # Form only.
>> orderby=db.client.name,
>> paginate=session.auth.user.pagination,
>> # represent_none='',  # Grid and view form only.
>> )
>>
>>
>> if 'edit' in request.args:
>> form = grid.update_form
>> form['hidden'].update(modified_on=form.record.modified_on)
>>
>> My onvalidation function
>>
>> if request.args and request.args[0] == 'new':
>> # Fix for SQLite instead of for_update=True. When for_update is
>> # fixed for SQLite, only the first SELECT in the function should
>> # have for_update=True.
>> while True:
>> try:
>> # SQLite only does database lock.
>> db.executesql('BEGIN IMMEDIATE TRANSACTION')
>> break
>> except sqlite3.OperationalError:
>> sleep(0.5)
>> elif not db.client(request.vars.id).is_active:
>> session.flash = T('Record was deleted while you were editing.')
>> redirect(URL(user_signature=True))
>> elif request.post_vars.modified_on != str(db.client(request.vars.id).
>> modified_on):
>> form.errors.code = T('Record was changed while you were editing. 
>> '
>>  'Press F5 to refresh and press Resend in 
>> the '
>>  'browser question.')
>> elif form.vars.delete_this_record:
>> # Fix for SQLite instead of for_update=True. When for_update is
>> # fixed for SQLite, only the first SELECT in the function should
>> # have for_update=True.
>> while True:
>> try:
>> # SQLite only does database lock.
>> db.executesql('BEGIN IMMEDIATE TRANSACTION')
>> break
>> except sqlite3.OperationalError:
>> sleep(0.5)
>>
>> db.client(request.vars.id).update_record(
>> cancel_approved_by=auth.user_id,
>> canceled_by=auth.user_id,
>> canceled_on=request.now,
>> is_active=False,
>> )
>>
>> db.commit()
>>
>> session.flash = T('Done.')
>> redirect(URL(user_signature=True))
>> elif request.args and request.args[0] == 'edit':
>> # Fix for SQLite instead of for_update=True. When for_update is
>> # fixed for SQLite, only the first SELECT in the function should
>> # have for_update=True.
>> while True:
>> try:
>> # SQLite only does database lock.
>> db.executesql('BEGIN IMMEDIATE TRANSACTION')
>> break
>> except sqlite3.OperationalError:
>> sleep(0.5)
>>
>>
>>
>> quarta-feira, 27 de Março de 2019 às 18:47:33 UTC, Anthony escreveu:
>>>
>>> Need to see your code.
>>>
>>> On Wednesday, March 27, 2019 at 2:47:01 PM UTC-4, João Matos wrote:

 You mean to update the 

[web2py] Re: Compartilhar aplicações feita em Web2py em Rede Local.

2019-03-28 Thread Leonel Câmara
Hey Alessandro, this is an international group so please use English 
instead of Portuguese.

Basically you just need to be sure your computer has a static local network 
ip which you can probably configure in your wireless router if he's the one 
running DHCP. Then run web2py on that ip instead of 127.0.0.1. If you want 
to make it easier you can also put a name for that IP in your local network 
computers hosts file.

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


[web2py] Re: web3py again....

2019-03-28 Thread Leonel Câmara
I haven't tried it, but looking at the code...

Can you explain a little bit more what you're trying to achieve here?  
  
This seems like it's bottle with pydal and yatl. Why not just use bottle 
then? It will force me to learn bottle anyway.

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


Re: [web2py] web3py again....

2019-03-28 Thread José Luis Redrejo
Just tested, some considerations:

1. Tested with Python 3.6, followig strictly the provided instructions,
several things don't work:
a) static folder is not working properly. I get a 404 error for all the
requests
127.0.0.1 - - [28/Mar/2019 10:45:10] "GET /todo/index HTTP/1.1" 200 828
127.0.0.1 - - [28/Mar/2019 10:45:10] "GET /todo/static/js/sugar.min.js
HTTP/1.1" 404 774
127.0.0.1 - - [28/Mar/2019 10:45:10] "GET /todo/static/js/axios.min.js
HTTP/1.1" 404 774
127.0.0.1 - - [28/Mar/2019 10:45:10] "GET /todo/static/js/vue.min.js
HTTP/1.1" 404 770
127.0.0.1 - - [28/Mar/2019 10:45:10] "GET /todo/static/js/todo.js HTTP/1.1"
404 764

b) favicon requests also produce a python error:
27.0.0.1 - - [28/Mar/2019 10:44:47] "GET /favicon.ico HTTP/1.1" 404 742
Traceback (most recent call last):
  File "/opt/src/web3py/web3py.py", line 149, in load
self.data = jwt.decode(enc_data, self.secret,
algorithms=[self.algorithm])
  File "/opt/src/web3py/venv/lib/python3.6/site-packages/jwt/api_jwt.py",
line 84, in decode
payload, _, _, _ = self._load(jwt)
  File "/opt/src/web3py/venv/lib/python3.6/site-packages/jwt/api_jws.py",
line 177, in _load
binary_type))
jwt.exceptions.DecodeError: Invalid token type. Token must be a 


2. About your questions:

   - sqlform and grid are one of the key points for web2py. It's one of the
   main reasons to use it instead of other frameworks as development is really
   quick. However I think nowadays a backport from web2py is not a good idea.
   We should provide something optional based only on vue.js. As you say, we
   can do it better.
   - auth is not as important in my experience. It has never been the
   reason to pick web2py and there are other ways to do it.


3. about the new ideas:

   - I love the use of jwt and vue.js
   - I love it does not use custom import or eval. That will make testing
   much, much easier and logical.
   - I would like to have a kind of automatic integration between the
   backend and webpack, for modern development. It should be optional
   obviously, but something like django-webpack-loader should be added (or
   have web3py-webpack-loader as an external library that can be installed if
   required)


If you have a roadmap where others could lend a hand, please, tell it.
Maybe creating some github issues that could be assigned to volunteers. I'd
be glad to help.
José L.



El jue., 28 mar. 2019 a las 10:16, Massimo Di Pierro (<
massimo.dipie...@gmail.com>) escribió:

> I know this comes up once in a while but ...
>
> https://github.com/web2py/web3py
>
> what do you think?
>
> It is very preliminary but I will have an admin soon.
> Backporting SQLFORM, grid and Auth, should not be that complicated,
> although I think we can do better.
>
> Massimo
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] web3py again....

2019-03-28 Thread Massimo Di Pierro
I know this comes up once in a while but ...

https://github.com/web2py/web3py

what do you think? 

It is very preliminary but I will have an admin soon.
Backporting SQLFORM, grid and Auth, should not be that complicated, 
although I think we can do better.

Massimo

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


[web2py] Not my type

2019-03-28 Thread Al Hart
Hi folks, if you'll pardon the corny title, I am brand new to web2py (so 
excited to discover it) and I'm just working may way through the book. In 
Chapter two, the section on types, I tried to run the examples, but I got 
error messages. Googling around it seemed to work better if I went one of 
two ways:


   1. a = 3
   type(a)
   2. a = 4 
   print(type(a))


I'm on Ubuntu 18.04. Not sure if the example is based on python 3? If not, 
is this the best way to suggest updates to the book or should we just try a 
pull request? 

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


[web2py] Compartilhar aplicações feita em Web2py em Rede Local.

2019-03-28 Thread Alessandro dos Santos
Boa tarde! Fiz uma pequena aplicação utilizando web2py, e gostaria de 
compartilhar ela em rede local, lembrando que a rede no meu serviço é 
compartilhado por wifi sem IP.

grato.

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


[web2py] Re: Using the results of a variable returned by one function in another function

2019-03-28 Thread mostwanted
Ok this is what i am trying to achieve and have been struggling with for 
weeks now, in the controller below I am searching for businesses that offer 
desired services, after displaying all those businesses, from that very 
list am trying to further filter through that list by searching for 
businesses that offer that desired service but in a certain desired 
location.
I hope I give sense

*FULL CONTROLLER1 CODE*
def companies():
*resultsARE=db.services(request.args(0))*
rslts=db(db.business.services==resultsARE.id).select(db.business.ALL, 
orderby=db.business.company_name)
services=len(rslts)
form=SQLFORM.factory(Field('query', requires=IS_NOT_EMPTY(), label=SPAN(
'', _style="font-weight: bold;"), widget = lambda field, value: SQLFORM.
widgets.string.widget(field, value, _class='my-string', _id='searching', 
_placeholder='LOCATION')))
searchBtn=form.element('input',_type='submit')
searchBtn['_style'] = 'display:none;'
if form.accepts(request):
tokens=form.vars.query.split()
query=reduce(lambda a,b:a, [db.locations.name.contains(k) for k in 
tokens])
location=db(query).select(orderby=db.locations.name)
else:
location=[]
return locals()


*CONTROLLER2 CODE*
def Results():
results=db.locations(request.args(0))
comps=companies()
for services in comps:
serv=services
rslts=db(db.business.place==results.id).select
*(db.business.services==resultsARE.id)*
services=len(rslts)
return locals()


Mostwanted

On Wednesday, March 27, 2019 at 8:42:30 PM UTC+2, Anthony wrote:
>
> It's not quite clear what you mean. Are these two functions two separate 
> controller actions? If so, it's not clear how you can share that variable, 
> as it is defined based on request.args(0) in the first function, but 
> presumably request.args(0) has a different meaning in the context of the 
> second function. What are you really trying to do?
>
> On Wednesday, March 27, 2019 at 8:11:15 AM UTC-4, mostwanted wrote:
>>
>> I have 2 functions and i want to use the value of the variable returned 
>> by one function in another function, how can i achieve this?
>> I want to use the value of *resultsARE *in *function1 *in the same way 
>> in *function2 *as attempted in the highlighted lines below.
>>
>> *FUNCTION1*
>> def companies():
>> *resultsARE=db.services(request.args(0))*
>> rslts=db(db.business.services==resultsARE.id).select(db.business.ALL, 
>> orderby=db.business.company_name)
>> services=len(rslts)
>> return locals()
>>
>> *FUNCTION2*
>> def Results():
>> results=db.locations(request.args(0))
>> comps=companies()
>> for services in comps:
>> serv=services
>> rslts=db(db.business.place==results.id).select
>> *(db.business.services==resultsARE.id)*
>> services=len(rslts)
>> return locals()
>> Mostwanted
>>
>>

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