[web2py] Re: How to create a nested json dictionary by loading data from a flat, parent-referencing list?

2019-03-20 Thread Alex Glaros
"as_trees" works great, but but how to remove the  "Row<" verbiage from the 
result? You mentioned "serialize the result into json". Can you please show 
example?  At the current stage, the data looks like this:

[, , etc


thanks,

Alex Glaros

-- 
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: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread João Matos
What I read about the commit/rollback "wrapping" that web2py does, it 
doesn't seem to solve my problem.

Let me explain.
I have 3 tables (sn_counter, wo_counter and wo).
The procedure I must do is the following:
1. Get the record from wo_counter table a extract the counter value (read 
operation), let's suppose I get the number 10.
2. Increase the counter to 11 and update the wo_counter record.
3. Get the record from sn_counter table a extract the counter value (read 
operation), let's suppose I get the number 20.
4. Increase the counter to 21 and update the sn_counter record.
5. Write a new record in the wo table with the original counters (10 and 
20).

During all these operations, no one can write to any of the 2 records used 
in steps 1 to 4.

I don't think the existing commit/rollback does that. Does it?

quinta-feira, 21 de Março de 2019 às 01:02:24 UTC, Leonel Câmara escreveu:
>
> Web2py always "wraps" your controller functions in a db transaction, so 
> yes, you can do that with any database which has transactions correctly 
> implemented. You don't need to worry about doing it manually.

-- 
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] Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread Leonel Câmara
Web2py always "wraps" your controller functions in a db transaction, so yes, 
you can do that with any database which has transactions correctly implemented. 
You don't need to worry about doing it manually.

-- 
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: When using SQLite does web2py use the older rollback-mode transaction mechanism or the newer WAL?

2019-03-20 Thread João Matos
Thanks.

quarta-feira, 20 de Março de 2019 às 23:16:46 UTC, Leonel Câmara escreveu:
>
> Looking at:
>
> https://github.com/web2py/pydal/blob/master/pydal/adapters/sqlite.py#L73
>
> I don't see any
>
> self.execute('pragma journal_mode=wal;')
>
> So I'm guessing the older.
>

-- 
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: When using SQLite does web2py use the older rollback-mode transaction mechanism or the newer WAL?

2019-03-20 Thread Leonel Câmara
Looking at:

https://github.com/web2py/pydal/blob/master/pydal/adapters/sqlite.py#L73

I don't see any

self.execute('pragma journal_mode=wal;')

So I'm guessing the older.

-- 
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] Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

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

I need to ensure that when I update a record in a table, it must comply 
with these requirements:
1. Begin transaction - don't allow anyone else to write to that record/row.
2. Write and commit the updated record.
3. End transaction, allowing everyone to write to that record/row.
4. There can only be 1 transaction per record/row at the same time.
5. If anyone tries to write while a transaction is in place either receives 
an error or some kind of message that identifies that the record is being 
updated.

Does anyone know if web2py/DAL allow me to do/have this?

I'm  using SQLite and apparently it only does database lock (not record/row 
or even table).
But I willing to accept that if I can follow the requirements above 
replacing record/row lock with database lock.

Another option is to change the db backend to MySQL or PostgreSQL if only 
they would comply with the requirements above.

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] When using SQLite does web2py use the older rollback-mode transaction mechanism or the newer WAL?

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

When using SQLite does web2py use the older rollback-mode transaction 
mechanism or the newer WAL?
https://sqlite.org/lockingv3.html


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: bug in recent versions of web2py related to unicode encoding in mail()

2019-03-20 Thread Shawn Michaels
This is it:
[Py3] ASCII decode error when running app in shell with non-ascii characters
https://github.com/web2py/web2py/issues/2060

Dne čtvrtek 7. března 2019 12:41:08 UTC+1 Shawn Michaels napsal(a):
>
> Hi, I'm facing similar problem in Version 2.17.2 when there is unicode 
> char in subject or message.
> Python 3.6
>
> Traceback (most recent call last):
>   File "/www/projects/web2py/gluon/shell.py", line 276, in run
> execfile(startfile, _env)
>   File "/www/projects/web2py/gluon/shell.py", line 41, in execfile
> code = compile(f.read(), filename, 'exec')
>   File 
> "/usr/lib/python-exec/python3.6/../../../lib64/python3.6/encodings/ascii.py", 
> line 26, in decode
> return codecs.ascii_decode(input, self.errors)[0]
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 321: 
> ordinal not in range(128)
>
> since there is utf-8 encoding as default, it should work fine bud doesn't.
>

-- 
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: New International Telegram Support Group

2019-03-20 Thread Marcelo Huerta
El martes, 19 de marzo de 2019, 15:49:34 (UTC-3), Ari Lion BR Sp escribió:
>
>
> Now I see a new link to this group:
> https://t.me/web2py_world
>
>
>
Joined! 

-- 
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] Checkboxes are shown without space between checkbox and label

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

When creating a SQLFORM with checkboxes, they are shown without a space 
between the checkbox and the label.
The correct behavior would be to have a space, like it happens with the 
Delete checkbox on 
record edit.

This is how it looks


[image: Checkboxes.png] 

This is my code

...
field = Field(
opt_cat.name_en.translate(''.maketrans(*translation_table)).
replace(
'__', '_').replace('__', '_').lower(),
widget=SQLFORM.widgets.checkboxes.widget,
requires=IS_EMPTY_OR(IS_IN_SET(rows_dic)),
)

if T.accepted_language == 'pt':
field.label = opt_cat.name
else:
field.label = opt_cat.name_en

factory_fields.append(field)

form = SQLFORM.factory(*factory_fields,
buttons=[BUTTON(T('Submit'), _type='submit', _class='btn 
btn-primary')],
)






If even tried replacing 

opt_cat.name_en.translate(''.maketrans(*translation_table)).
replace(
'__', '_').replace('__', '_').lower(),


with a simple string, but with the same result.


Windows 7 Pro x64 SP1+all updates
web2py 2.18.4
Firefox 65.0.2 x64
Python 3.71. x86

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] Re: How to catch index error

2019-03-20 Thread Maurice Waka
This works well Boss!!
Thanks a lot and God Bless!
Regards

On Wed, Mar 20, 2019 at 3:45 AM Leonel Câmara 
wrote:

> Notice that, it seems you are using [-1] because want to get the last
> record where the user was awake/light sleep/sleep, however you don't use an
> order by, so depending on the strategy the database decides to use, there's
> no guarantee that it will be the last. This is also inefficient because you
> only want the last record and you're getting all the records and they could
> be hundreds in the future.
>
> Couldn't you just do:
>
> last_sleep = db(db.sleep.id > 0).select(orderby=~db.sleep.id,
> limitby=(0,1)).first()
> gauge.add('Awake', [{'value':last_sleep.awake if last_sleep else 0,
> 'max_value': 24}])
> gauge.add('Light Sleep', [{'value':last_sleep.light_sleep if
> last_sleep else 0, 'max_value': 24}])
> gauge.add('Deep Sleep', [{'value':last_sleep.deep_sleep if last_sleep
> else 0, 'max_value': 24}])
>
> --
> 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/9mI7-ZkpA_0/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.