[web2py] Boolean types with Postgres adapter

2019-05-10 Thread John Underhill
The documentation states the SQLite lacks a boolean data type, so PyDAL 
maps boolean values to CHAR(1).  But why do you do this with Postgres?  
Looking in my migration logs, I see boolean fields being created as 
CHAR(1).  Postgres does have a boolean type.

John

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


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

2019-04-02 Thread John Underhill
I think all this bears some brainstorming in light of what’s going on with 
Webassembly.

I’m not saying Javascript for building web UIs isn’t the future, but...

Ok, quick show of hands: How many people absolutely adore Javascript?  Oh wait, 
it doesn’t matter, because we have no choice.  Or do we?

What if we could develop the whole app in Python, front end and back end?  What 
if we could develop front end apps for the browser in Python, with Web2py (or 
its successor)?  And they ran really fast, and integrated transparently with 
back-end services, also written in Python?

Not sure exactly what this would look like, but I’ve been pushing it around for 
a while.  At the very least this has the potential to make my life much easier. 
 We probably need some pieces that aren’t there yet (but probably they will be 
shortly).

What do you all think?

John


From: web2py@googlegroups.com on behalf of Carlos Costa 

Sent: Tuesday, April 2, 2019 2:09 PM
To: web2py-users
Subject: [web2py] Re: web3py again

Will it have default url routes?

beyond that,  my thought about ui widgets:
I think it would be nice:
1 - to have an easy integration via a model rest api
2- be agnostice to client side frameworks
3 - come with a default client side framework (preferably vue)
4 - have a ui lib by default
5 - have a template for building custom ui widgets using vue (like single page 
components or something.) that integrates easily,
maybe with some client api, with the server

Em quinta-feira, 28 de março de 2019 06:16:15 UTC-3, Massimo Di Pierro escreveu:
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 a topic in the Google 
Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/vLw9sj6nw7M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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


RE: [web2py] Simple didactic integration of web2py with Vue.js

2019-03-24 Thread John Underhill
Luciano,

I think this is a great idea!  I really like Vue.js, and we use Web2py 
extensively.  I have been looking for a way to use a good JavaScript framework 
front end with Web2py.  We also like to incorporate Bootstrap if we can, and 
there are nice Bootstrap components for Vue.js.

I think Massimo is also working on something cool (Web3py), but I’m not sure 
where he is with that at the moment.

I think Web2py is a great teaching tool.  But I think JavaScript is a very bad 
language, and JavaScript frameworks layer a lot of stuff on top of it, and are 
very hard to learn and understand.  This architecture is a very good idea, and 
will teach marketable skills (Python and JavaScript/Vue.js), but I wish young 
students had more choices for front-end languages.  Hopefully Webassembly is 
starting to change that.

John Underhill
QIS Project, Inc.
Santa Barbara, California

From: web2py@googlegroups.com  On Behalf Of 
luciano.on...@gmail.com
Sent: Sunday, March 24, 2019 2:27 PM
To: web2py-users 
Subject: [web2py] Simple didactic integration of web2py with Vue.js

Dear all,
I am considering to create a didactic tool to teach poor children the basics of 
web development.
I strongly believe in web2py potential as didactic tool and I believe that 
Vue.js also would be nice in the front end.
I created a simple example to get people feedback:

https://github.com/luciano-ondir/simple-Web2py-VueJs

This project has the following objectives:
a. Keeping simplicity, avoiding installing other software (like npn, webpack, 
etc)
b. Ease to use, keeping soft learning curve for new comers
c. Seamless Integration with web2py, keeping web2py cybersecurity and access 
control
d. Minimizing web data exchange, keeping loading times low
e. Scalability, avoiding pitfalls for large applications

If anyone has suggestions on how to improve any of the stated objectives, I 
would be very grateful.
Luciano Ondir Freire


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

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


RE: [web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-24 Thread John Underhill
@João, you are programming yourself into a corner.  No matter what you do, 
you’ll keep running into more problems.  The reason for this is because you’re 
trying to do atomic operations at the application level.  You simply can’t do 
that.

If you check whether or not something is locked at the application level, and 
then take some action, you risk making a mistake.  What happens if the lock 
state changes between when you checked, and the next operation in your program? 
 You will take the wrong action.  By definition, *anything* can happen between 
*any* two operations in your program.  Another process could change the state:

1: if databaseislocked() then:
2:  doseomthing()
3: else:
4:  dosomethingelse()

What if the database state changes between 1 and 2 or 4?  Perhaps you think if 
it ends up being locked, and you try to lock it again, then your subsequent 
attempt will fail.  But then what?  Do you go into to a loop trying to lock it? 
 Now you can get blocked waiting for a lock, or worse, get into a deadlock 
situation, with two processes blocked, each waiting for the other one to free 
up something.

So you say you created a flag?  Now you’ve just pushed the problem back onto 
another application-level ‘lock’ that can’t possibly be relied upon (unless 
you’re using a low-level locking mechanism, and even then this can be tricky).

My understanding of what I read between you and Anthony is this:

a) SQLite defers starting the actual transaction until the first write, so your 
initial code wasn’t actually wrapped in a transaction at all.
b) As a result, your tests failed.  But this doesn’t mean transactions don’t 
work in SQLite, or in general.
c) Anthony tried to force the transaction open with the FOR UPDATE clause, but 
that doesn’t work in SQLite.
d) So the solution for SQLite is to explicitly start the transaction before 
reading and/or writing anything.

So all you have to do is

db.executesql('BEGIN IMMEDIATE TRANSACTION')

before you start reading and updating your counters, and the work order, and 
then

db.commit()

as soon as you’re done.  You *do not* need to check if the database is already 
locked.  SQLite will handle this during the commit process.  It will guarantee 
that any two operations running concurrently are isolated from each other—each 
process will see a consistent view of the database, and the final result will 
be the same as if they had executed one after the other (serially).  If they 
collide, SQLite will abort one of them, and restart it.  For this to work, it’s 
important that:


  1.  You start the transaction before you *read* anything, not just before you 
write.  SQLite needs to know what you’re looking at, as well as what you intend 
to change.
  2.  You do the whole process in batch.  You can’t stop to wait for the user 
to do something.  Get all the input you need from the user first, then do the 
update without stopping.

This process will be more scalable, and not require locking the whole database, 
on a multi-user MVCC database like Postgres.  This would also avoid the 
silliness with the SQLite adapter bugs.  We use Postgres with Nginx and Web2py 
in production systems with lots of contention and it works beautifully.  But 
this really only matters if you have lots of users.  SQLite is very solid for 
smaller, single-server deployments.

John

From: web2py@googlegroups.com  On Behalf Of João Matos
Sent: Sunday, March 24, 2019 2:47 PM
To: web2py-users 
Subject: [web2py] Re: Does web2py/DAL allow for creating atomic operations 
(begin transaction/end transaction)?

@John
I think you didn't understand the problem.
I have to assign a wo_counter and a sn_counter to each new record of the wo 
table.
To do that, I must disable any attempt to change them during the process of 
saving the wo record to the database.
That process consists of:
1. If the user didn't select an existing wo_counter, then I must read the last 
assigned wo_counter, increase it, save it in memory to assign it to the wo 
record, and save the new value in the wo_counter table.
2. Read the last assigned sn_counter (which is different by equipment_id 
selected by the user), increase it, save it in memory to assign it to the wo 
record, and save the new value in the sn_counter table.
3. Save the wo record with the wo_counter and sn_counter that were stored in 
memory.

The existing transaction auto-created by web2py within each action does not 
allow the protection I need. I tested it. If you want you can follow this test 
procedure I used.
Put a sleep command between step 1 and 2.
Open session 1 where the wo record procedure I listed above is running until it 
pauses in the sleep command.
On session 2 access the table for the wo_counter or sn_counter. Change the 
value of the counter and save it.
Wait until the pause ends on session 1 and the wo record function will save 
it's value over the value stored by the session 2.
This means that information was lost.

What is needed