Re: [web2py] Do not show None

2016-07-08 Thread Manuele Pesenti
Il 08/07/16 08:54, Kenneth ha scritto:
> Hello,
>
> I fetch a number on records from the database and show it on the
> screen. Is there a way to not print the text None for fields that are
> in the state None. I could use if field != None but I'd rather not use
> IF if there is an other way.
I would say that it depends on what result you want to accieve:
1. You don't want results with no values for the field in object, in
that case it's better to cat out them with an adequate query (i.e.:
...&(myfield!=None));
2. You want to see "" (empty string) instead of "None" for the records
that has no value for the field in object, in that case you can fix the
represent function of the field with something like field.represent =
lambda v: "" if v is None else v;

I hope it could help.
Cheers

Manuele
>
>
> Kenneth
>
> -- 
> 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.


Re: [web2py] Re: Identifyng Relationship

2016-07-08 Thread Carlos Cesar Caballero Díaz
Thanks Anthony for your time and answers, I will use another tool for 
this project then, the DB already exist with the "Identifying 
Relationship" structure and I can't change it.


Greetings.

El 06/07/16 a las 12:21, Anthony escribió:
On Wednesday, July 6, 2016 at 8:39:57 AM UTC-4, Carlos Cesar Caballero 
wrote:


Hi Anthony, that's exactly what I need, because (among other
things) when the parent key is part of the child primary key I can
do something like child.parent_id, and it works the same with a
relationship of depth n, for example in the relation
author-book-page-sentence-word, I can ask what author wrote a word
just saying word.author_id without need to join word with sentence
with page with book to get the author id.


Yes, but nothing stops you from doing that with the DAL:

|
db.define_table('word',
Field('sentence_id','reference sentence'),
Field('page_id','reference page'),
Field('book_id','reference book'),
Field('author_id','reference author'),
Field('word'))

word =db.word(1)
author_id =word.author_id
|

In the above, db.word.author_id is not part of the primary key of the 
db.word table, but it is still a foreign key to the db.author table.


But keep in mind that this is not that useful, as all you have is the 
record ID of the author -- if you want any details about the author, 
you still need to do a join or an additional query.


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.




--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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: Pythonanywhere Timezone

2016-07-08 Thread Jeff Riley
Just in case anyone is wondering why I would build such a strange little 
web app, it is for my personal use.  I was dianosed with brain cancer 6 
weeks ago and these are the items my doctors want me to track everyday.  So 
I thought Web2py would be perfect.

On Thursday, July 7, 2016 at 2:19:10 PM UTC-5, Jeff Riley wrote:
>
> Hello all.  Me again.  I have run into an interesting issue.  I have 
> installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
> work on my local PC I need to setup my db.py as follows.
>
> import pytz
> user_timezone = session.plugin_timezone_tx or 'UTC'
>
>
> db.define_table('events',
> Field('event_time', 'datetime', default = request.now, update 
> = request.now,
> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
> timezone=pytz.timezone(user_timezone))),
>
>
> But to get it to work on pythonanywhere.com I have to setup my db.py as 
> follows.  Any ideas why?
>
>
> import pytz
>
> db.define_table('events',
> Field('event_time', 'datetime', default = request.now, update 
> = request.now,
> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
> timezone=pytz.timezone("US/Central"))),
>
>
>
>

-- 
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: Pythonanywhere Timezone

2016-07-08 Thread Marlysson Silva
Are you trying to get the timezone just of the your location? 
Case yes, you set your timezone at code, and deploy in pythonanywhere with 
value personal of the timezone.

But you want timezone by any place, then I go prepare a article showing 
what I made to solved this. 

Em sexta-feira, 8 de julho de 2016 09:56:48 UTC-3, Jeff Riley escreveu:
>
> Just in case anyone is wondering why I would build such a strange little 
> web app, it is for my personal use.  I was dianosed with brain cancer 6 
> weeks ago and these are the items my doctors want me to track everyday.  So 
> I thought Web2py would be perfect.
>
> On Thursday, July 7, 2016 at 2:19:10 PM UTC-5, Jeff Riley wrote:
>>
>> Hello all.  Me again.  I have run into an interesting issue.  I have 
>> installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
>> work on my local PC I need to setup my db.py as follows.
>>
>> import pytz
>> user_timezone = session.plugin_timezone_tx or 'UTC'
>>
>>
>> db.define_table('events',
>> Field('event_time', 'datetime', default = request.now, 
>> update = request.now,
>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>> timezone=pytz.timezone(user_timezone))),
>>
>>
>> But to get it to work on pythonanywhere.com I have to setup my db.py as 
>> follows.  Any ideas why?
>>
>>
>> import pytz
>>
>> db.define_table('events',
>> Field('event_time', 'datetime', default = request.now, 
>> update = request.now,
>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>> timezone=pytz.timezone("US/Central"))),
>>
>>
>>
>>

-- 
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: Pythonanywhere Timezone

2016-07-08 Thread Marlysson Silva

Are you trying to get the timezone just of the your location? 
Case yes, you set your timezone at code, and deploy in pythonanywhere with 
value personal of the timezone.

But you want timezone by any place, then I go prepare a article showing 
what I made to solved this. 

Em sexta-feira, 8 de julho de 2016 09:56:48 UTC-3, Jeff Riley escreveu:
>
> Just in case anyone is wondering why I would build such a strange little 
> web app, it is for my personal use.  I was dianosed with brain cancer 6 
> weeks ago and these are the items my doctors want me to track everyday.  So 
> I thought Web2py would be perfect.
>
> On Thursday, July 7, 2016 at 2:19:10 PM UTC-5, Jeff Riley wrote:
>>
>> Hello all.  Me again.  I have run into an interesting issue.  I have 
>> installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
>> work on my local PC I need to setup my db.py as follows.
>>
>> import pytz
>> user_timezone = session.plugin_timezone_tx or 'UTC'
>>
>>
>> db.define_table('events',
>> Field('event_time', 'datetime', default = request.now, 
>> update = request.now,
>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>> timezone=pytz.timezone(user_timezone))),
>>
>>
>> But to get it to work on pythonanywhere.com I have to setup my db.py as 
>> follows.  Any ideas why?
>>
>>
>> import pytz
>>
>> db.define_table('events',
>> Field('event_time', 'datetime', default = request.now, 
>> update = request.now,
>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>> timezone=pytz.timezone("US/Central"))),
>>
>>
>>
>>

-- 
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: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Just to post the right solution.

filter_in didnt work out since im not saving the form when its posted, just 
using the form to generate a query.
So the right solution would be something like:


form = SQLFORM(db.myfilters).process(dbio=False, keepvalues=True, 
onvalidation=enable_bool_tri_state)

#check if a field has a bool_radio widget
def enable_bool_tri_state(form):
   for fld in form.fields:
   field = form.table[fld]
   if field.widget == bool_radio_widget and request.post_vars[fld] == 
None:
   form.vars[fld] = None



-- 
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: Pythonanywhere Timezone

2016-07-08 Thread Jeff Riley
I would like to know how a timezone by any place would be done, so I look 
forward to your article.  For me I am just going to keep it set to 
US/Central.  Also if anyone wants to use the code I have provided to build 
this sort of web app for the general public, please feel free to use what I 
have provided.

On Friday, July 8, 2016 at 8:16:46 AM UTC-5, Marlysson Silva wrote:
>
>
> Are you trying to get the timezone just of the your location? 
> Case yes, you set your timezone at code, and deploy in pythonanywhere with 
> value personal of the timezone.
>
> But you want timezone by any place, then I go prepare a article showing 
> what I made to solved this. 
>
> Em sexta-feira, 8 de julho de 2016 09:56:48 UTC-3, Jeff Riley escreveu:
>>
>> Just in case anyone is wondering why I would build such a strange little 
>> web app, it is for my personal use.  I was dianosed with brain cancer 6 
>> weeks ago and these are the items my doctors want me to track everyday.  So 
>> I thought Web2py would be perfect.
>>
>> On Thursday, July 7, 2016 at 2:19:10 PM UTC-5, Jeff Riley wrote:
>>>
>>> Hello all.  Me again.  I have run into an interesting issue.  I have 
>>> installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
>>> work on my local PC I need to setup my db.py as follows.
>>>
>>> import pytz
>>> user_timezone = session.plugin_timezone_tx or 'UTC'
>>>
>>>
>>> db.define_table('events',
>>> Field('event_time', 'datetime', default = request.now, 
>>> update = request.now,
>>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>>> timezone=pytz.timezone(user_timezone))),
>>>
>>>
>>> But to get it to work on pythonanywhere.com I have to setup my db.py as 
>>> follows.  Any ideas why?
>>>
>>>
>>> import pytz
>>>
>>> db.define_table('events',
>>> Field('event_time', 'datetime', default = request.now, 
>>> update = request.now,
>>> requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>>> timezone=pytz.timezone("US/Central"))),
>>>
>>>
>>>
>>>

-- 
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: Pythonanywhere Timezone

2016-07-08 Thread Marlysson Silva
Great, I will preparing them. Put your code on github to follow the 
development, and to contribuit in something.

Em sexta-feira, 8 de julho de 2016 10:52:26 UTC-3, Jeff Riley escreveu:
>
> I would like to know how a timezone by any place would be done, so I look 
> forward to your article.  For me I am just going to keep it set to 
> US/Central.  Also if anyone wants to use the code I have provided to build 
> this sort of web app for the general public, please feel free to use what I 
> have provided.
>
> On Friday, July 8, 2016 at 8:16:46 AM UTC-5, Marlysson Silva wrote:
>>
>>
>> Are you trying to get the timezone just of the your location? 
>> Case yes, you set your timezone at code, and deploy in pythonanywhere 
>> with value personal of the timezone.
>>
>> But you want timezone by any place, then I go prepare a article showing 
>> what I made to solved this. 
>>
>> Em sexta-feira, 8 de julho de 2016 09:56:48 UTC-3, Jeff Riley escreveu:
>>>
>>> Just in case anyone is wondering why I would build such a strange little 
>>> web app, it is for my personal use.  I was dianosed with brain cancer 6 
>>> weeks ago and these are the items my doctors want me to track everyday.  So 
>>> I thought Web2py would be perfect.
>>>
>>> On Thursday, July 7, 2016 at 2:19:10 PM UTC-5, Jeff Riley wrote:

 Hello all.  Me again.  I have run into an interesting issue.  I have 
 installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
 work on my local PC I need to setup my db.py as follows.

 import pytz
 user_timezone = session.plugin_timezone_tx or 'UTC'


 db.define_table('events',
 Field('event_time', 'datetime', default = request.now, 
 update = request.now,
 requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
 timezone=pytz.timezone(user_timezone))),


 But to get it to work on pythonanywhere.com I have to setup my db.py as 
 follows.  Any ideas why?


 import pytz

 db.define_table('events',
 Field('event_time', 'datetime', default = request.now, 
 update = request.now,
 requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
 timezone=pytz.timezone("US/Central"))),





-- 
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: how to handle boolean's tri states?

2016-07-08 Thread Anthony
On Thursday, July 7, 2016 at 7:36:57 PM UTC-4, Alfonso Serra wrote:
>
> Thanks Richard, Anthony, very good answers.
>>
>
> The use case is simple:
> For example, query articles with a field of uncatalogued, you can either 
> select catalogued, uncatalogued or all (doesnt matter if its uncatalogued). 
> To store such filter i can make use of a boolean tri state, True, False or 
> None to generate the right query.
>
> Im not using web2py to represent anything (is not compatible with an admin 
> template we are using, and it doesnt have to), just using SQLFORM 
> serverside to process post backs and validate.
>

Got it. Keep in mind that it helps if you provide your code and some detail 
regarding what you are doing. You mentioned using SQLFORM and "storing" the 
data, but it wasn't clear you were not storing the data in the database and 
that you simply need the data in form.vars. It's still not quite clear what 
is going on, though. Do you really need the data in form.vars, or could you 
just use request.vars instead? Do you eventually store data in the database 
table?
 

> I can agree with Anthony to a certain point that an undeclared boolean 
> value should always be False. The most common representation of a boolean 
> value is a checkbox, but it could be a radio input with 3 values. [None, 0, 
> 1]
>
> In this case it would be like:
> Field("mybool", "boolean", required = False, notnull = False, default = 
> None
> , filter_in=lambda v: None if v is None else v)
>

But that would just be equivalent to lambda v: v, which doesn't do any 
filtering.

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: how to handle boolean's tri states?

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 9:48:52 AM UTC-4, Alfonso Serra wrote:
>
> Just to post the right solution.
>
> filter_in didnt work out since im not saving the form when its posted, 
> just using the form to generate a query.
> So the right solution would be something like:
>
>
> form = SQLFORM(db.myfilters).process(dbio=False, keepvalues=True, 
> onvalidation=enable_bool_tri_state)
>
> #check if a field has a bool_radio widget
> def enable_bool_tri_state(form):
>for fld in form.fields:
>field = form.table[fld]
>if field.widget == bool_radio_widget and request.post_vars[fld] == 
> None:
>form.vars[fld] = None
>
> It would be ideal if the bool tri state is declared in the field 
> definition somehow so its handled properly later on. Ill try a custom 
> validator or widget and get back with a better solution.
>

Unfortunately, I think SQLFORM will always convert a boolean to True or 
False, regardless of the widget or validator used (the conversion happens 
after validation). If you want three values, you either need something like 
you've got above, or a different field type.

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: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
You are right. The real scenario is:
Im using a table to store filters that are used to retrieve data from 
another table. 

This other table are bookings, and i need a filter to retrieve either all 
of them, or with kids, or without them.

The form of such filters has 3 kind of submits "Execute filter", "Save 
Filter" and "Delete Filter", Save Filter will also execute the filter. 
Depending on which one i submit i save the form or not.

In any case the "with_kids" fields from the filter's table should be a 
boolean tristate, that i should handle properly when the form is processed. 
Not when the form its saved into the db, if its saved.

I think i have a few choices, either use the form's onvalidation callback 
or declare the tristate in the filed definition via validator or widget. 
The latter should be better since i wont have to worry later on, that what 
im looking now.

Thanks.


-- 
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: Identifyng Relationship

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 8:39:01 AM UTC-4, Carlos Cesar Caballero wrote:
>
> Thanks Anthony for your time and answers, I will use another tool for this 
> project then, the DB already exist with the "Identifying Relationship" 
> structure and I can't change it.
>

That's an important detail that you left out. If you are working with a 
legacy database and you cannot change the schema, the DAL supports that, 
though with some limitations. See 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables
 
(it says keyed tables are only supported on a limited set of backends, but 
I'm not sure if that is true, so try it out with your database). The main 
limitation is that keyed tables can only reference other keyed tables, but 
in this case, that sounds like exactly what you want.

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.


Re: [web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Richard Vézina
I would rather use a string field with a drop box as it may arrive that you
add more filter creteria, your three state bool wouldn't be enough once
there...

It makes your system less custom and easier to extend...

Richard

On Fri, Jul 8, 2016 at 10:41 AM, Alfonso Serra  wrote:

> You are right. The real scenario is:
> Im using a table to store filters that are used to retrieve data from
> another table.
>
> This other table are bookings, and i need a filter to retrieve either all
> of them, or with kids, or without them.
>
> The form of such filters has 3 kind of submits "Execute filter", "Save
> Filter" and "Delete Filter", Save Filter will also execute the filter.
> Depending on which one i submit i save the form or not.
>
> In any case the "with_kids" fields from the filter's table should be a
> boolean tristate, that i should handle properly when the form is processed.
> Not when the form its saved into the db, if its saved.
>
> I think i have a few choices, either use the form's onvalidation callback
> or declare the tristate in the filed definition via validator or widget.
> The latter should be better since i wont have to worry later on, that what
> im looking now.
>
> Thanks.
>
>
> --
> 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: how to handle boolean's tri states?

2016-07-08 Thread Anthony


> I think i have a few choices, either use the form's onvalidation callback
>

Actually, that won't work either, because the conversion of booleans 
happens after validation. However, instead, you can use the "onsuccess" 
callback (this is called after validation and database insert, but since 
you are not doing the database insert, it will work for you).
 

> or declare the tristate in the filed definition via validator or widget.
>

No, unfortunately neither of those options will work.

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: how to handle boolean's tri states?

2016-07-08 Thread Anthony
Also, note that you can test for field.type == 'boolean' rather than 
field.widget == bool_radio_widget.

Anthony

On Friday, July 8, 2016 at 9:48:52 AM UTC-4, Alfonso Serra wrote:
>
> Just to post the right solution.
>
> filter_in didnt work out since im not saving the form when its posted, 
> just using the form to generate a query.
> So the right solution would be something like:
>
>
> form = SQLFORM(db.myfilters).process(dbio=False, keepvalues=True, 
> onvalidation=enable_bool_tri_state)
>
> #check if a field has a bool_radio widget
> def enable_bool_tri_state(form):
>for fld in form.fields:
>field = form.table[fld]
>if field.widget == bool_radio_widget and request.post_vars[fld] == 
> None:
>form.vars[fld] = None
>
> It would be ideal if the bool tri state is declared in the field 
> definition somehow so its handled properly later on. Ill try a custom 
> validator or widget and get back with a better solution.
>
>
>

-- 
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: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Absolutetly right, i just realised that.

@Richard
Rather than a string field, i tried your approach using an integer and 
IS_IN_SET() but the problem is that bool conversion happens after that is 
executed. Hmm, actually this might work since as integer the bool 
conversion wont take place, right? Thanks ill try this.

onvalidation or onsuccess will definetly work.
Its not ideal since i have to declare such callbacks and inspect the 
field's widget or something to detect the tristate. Not ideal but better 
that having ifs on the controller after the form process.

Ill read about custom fields, that may be interesting, but since the bool 
conversion is done on form's process i dont think it will do the trick. But 
a custom field might not do the conversion.

Thank you all very much. Ill try these options and get back to you with 
what would be best. 
King Regards.

-- 
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 handle boolean's tri states?

2016-07-08 Thread Richard Vézina
Hello Alfonso,

In my last email, I don't mean what I suggested before. But instead of
using a boolean type field use just a string field (or a reference field
better) so you can add new criteria if it ever happen in the future and you
don't need to kind of customize the behavior of your boolean field to make
it accept NULL flag...

Richard

On Fri, Jul 8, 2016 at 11:21 AM, Alfonso Serra  wrote:

> Absolutetly right, i just realised that.
>
> @Richard
> Rather than a string field, i tried your approach using an integer and
> IS_IN_SET() but the problem is that bool conversion happens after that is
> executed. Hmm, actually this might work since as integer the bool
> conversion wont take place, right? Thanks ill try this.
>
> onvalidation or onsuccess will definetly work.
> Its not ideal since i have to declare such callbacks and inspect the
> field's widget or something to detect the tristate. Not ideal but better
> that having ifs on the controller after the form process.
>
> Ill read about custom fields, that may be interesting, but since the bool
> conversion is done on form's process i dont think it will do the trick. But
> a custom field might not do the conversion.
>
> Thank you all very much. Ill try these options and get back to you with
> what would be best.
> King Regards.
>
> --
> 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.


RE: [web2py] Re: Pythonanywhere Timezone

2016-07-08 Thread Jeff Riley
https://github.com/Sailor972/medicaltracker.git

Sent from Mail for Windows 10

From: Marlysson Silva

-- 
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: how to handle boolean's tri states?

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 11:21:53 AM UTC-4, Alfonso Serra wrote:
>
> Ill read about custom fields, that may be interesting, but since the bool 
> conversion is done on form's process i dont think it will do the trick. But 
> a custom field might not do the conversion.
>

As long as the custom field does not have type='boolean', SQLFORM will not 
convert it. But that's actually a problem, because then your form.vars 
value will be a string instead of a Python boolean. However, you can also 
add a custom validator to the field that will convert to boolean. This 
approach is nice because it (a) is handled entirely in the table definition 
and does not involve any form callbacks and (b) allows the underlying 
storage type for the field to remain boolean.

If you don't want to bother with a custom field type, you can also just use 
an integer field as an alternative.

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: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Jim Spoerl
Well, in the interest of trying out the wiki again, I tried to reinstall 
web2py from the "source" site download.  All went well.  I made sure all 
was well with permissions (www-data on Debian Wheezy) and with the SSL 
stuff including the admin password file.  Also the wsgi handler file was 
copied into the root. 

I went to the site in the browser.  The Welcome page came up fine.  No 
errors.  I clicked on the administration button and it accepted my admin pw 
fine.  I created a new app, modified the default.py to reference the wiki, 
and went to the wiki with no errors.

Next I tried to create a new user (but if I do not and just try to create a 
page by clicking on the button for that, the same thing happens).  When I 
had entered my info and tried to register that user, I got this internal 
error:

 local variable 'gid' referenced 
before assignment

Once this occurred, I could not go back to even the main Welcome page 
without the same error.

So something serious is broken in the auth area.  Can you help me trough 
this please?

By the way, I have tried this as localhost on port 8000 to keep things 
simple and the same is occurring there as when I come in via my FQDN.

Thanks
\Jim

On Thursday, July 7, 2016 at 8:00:32 AM UTC-4, Anthony wrote:
>
> But as a shortcut (I am pretty new with python, admittedly), I have tried 
>> some of the referenced appliances in the repo including, finally, outside 
>> the repo,  Instant Press.  It was promising but it simply throws a lot of 
>> exceptions as you start to use it.  It also has not been maintained and 
>> will not run without a lot of errors on the latest web2py (like KPax2, just 
>> doesn't run any longer).
>>
>> None of the CMS-like apps work currently on web2py  having not been 
>> maintained for years.  Where is that "backwards compatibility" when you 
>> need it?
>>
>
> I don't think there is an actively maintained CMS app/framework for 
> web2py, so you would have to implement the functionality you desire using 
> the base web2py framework.
>
> Regarding backwards compatibility, it is hard to say what is going on 
> without seeing any of the errors. In some cases, it is possible that the 
> original code relied on experimental features or undocumented behavior 
> rather than the public API (only the public API is guaranteed to remain 
> backward compatible). If there are legitimate cases of backward 
> compatibility violations, they will likely be addressed, so feel free to 
> report any you encounter.
>
> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Richard Vézina
gid stand for group id...

I grep the web2py code base you can see where gid is referenced :

tools.py
6451:gid = group.id
6454:auth.add_membership(gid)

contrib/fpdf/ttfonts.py
918:def getHMetric(self, numberOfHMetrics, gid):
920:if (gid < numberOfHMetrics):
921:self.seek(start+(gid*4))
926:self.seek(start+(numberOfHMetrics*2)+(gid*2))

contrib/pg8000/core.py
2057:curs.execute("select gid FROM pg_prepared_xacts")

contrib/login_methods/ldap_auth.py
571:gid = db.auth_group.insert(role=group_to_add,
description='Generated from LDAP')
573:gid = db(db.auth_group.role ==
group_to_add).select(db.auth_group.id).first().id
574:db.auth_membership.insert(user_id=db_user_id,
group_id=gid)


We would need more information contain in the traceback in order to help.

When you reinstall did you recreate you database?

I may possible that it get half created or corrupted because your previous
issue when failling web2py production deployment.

Or you can check that there is not wrongly defined users or
group/membership. For membership remaining despite group or user being
deleted...

Good luck!

Richard


On Fri, Jul 8, 2016 at 12:27 PM, Jim Spoerl  wrote:

> Well, in the interest of trying out the wiki again, I tried to reinstall
> web2py from the "source" site download.  All went well.  I made sure all
> was well with permissions (www-data on Debian Wheezy) and with the SSL
> stuff including the admin password file.  Also the wsgi handler file was
> copied into the root.
>
> I went to the site in the browser.  The Welcome page came up fine.  No
> errors.  I clicked on the administration button and it accepted my admin pw
> fine.  I created a new app, modified the default.py to reference the wiki,
> and went to the wiki with no errors.
>
> Next I tried to create a new user (but if I do not and just try to create
> a page by clicking on the button for that, the same thing happens).  When I
> had entered my info and tried to register that user, I got this internal
> error:
>
>  local variable 'gid' referenced
> before assignment
>
> Once this occurred, I could not go back to even the main Welcome page
> without the same error.
>
> So something serious is broken in the auth area.  Can you help me trough
> this please?
>
> By the way, I have tried this as localhost on port 8000 to keep things
> simple and the same is occurring there as when I come in via my FQDN.
>
> Thanks
> \Jim
>
> On Thursday, July 7, 2016 at 8:00:32 AM UTC-4, Anthony wrote:
>>
>> But as a shortcut (I am pretty new with python, admittedly), I have tried
>>> some of the referenced appliances in the repo including, finally, outside
>>> the repo,  Instant Press.  It was promising but it simply throws a lot of
>>> exceptions as you start to use it.  It also has not been maintained and
>>> will not run without a lot of errors on the latest web2py (like KPax2, just
>>> doesn't run any longer).
>>>
>>> None of the CMS-like apps work currently on web2py  having not been
>>> maintained for years.  Where is that "backwards compatibility" when you
>>> need it?
>>>
>>
>> I don't think there is an actively maintained CMS app/framework for
>> web2py, so you would have to implement the functionality you desire using
>> the base web2py framework.
>>
>> Regarding backwards compatibility, it is hard to say what is going on
>> without seeing any of the errors. In some cases, it is possible that the
>> original code relied on experimental features or undocumented behavior
>> rather than the public API (only the public API is guaranteed to remain
>> backward compatible). If there are legitimate cases of backward
>> compatibility violations, they will likely be addressed, so feel free to
>> report any you encounter.
>>
>> 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.
>

-- 
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] orderby part of a string...

2016-07-08 Thread Richard
Can we do that :

http://stackoverflow.com/questions/8989098/postgres-order-data-by-part-of-string

?

Maybe like this ?

orderby='substring(tablename.fieldname, ...)'

??

Thanks

Richard

-- 
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: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Anthony
Please always show your code and the full traceback and describe the exact 
actions to reproduce the problem.

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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Jim Spoerl
Thanks, Richard.  Nothing was left over from previous work since I 
reinstalled the root directory from scratch.  the DB is sqlite so we were 
starting from an empty DB.  So I think the problem must be in the 
downloaded source.  Is this correct?

Here is the ticket:

24.233.114.172.2016-07-08.12-20-01.5cd46db0-031d-4ca5-abdb-7cadde73bc99
 local variable 'gid' referenced 
before assignmentVersion
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python Python 2.7.3: /usr/local/bin/uwsgi (prefix: /usr)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Traceback (most recent call last):
  File "/var/www/libertymessengerweb2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py" 
, 
line 60, in 
  File "/var/www/libertymessengerweb2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File 
"/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py" 
, 
line 20, in index
return auth.wiki()
  File "/var/www/libertymessengerweb2py/gluon/tools.py", line 4687, in wiki
groups=groups)
  File "/var/www/libertymessengerweb2py/gluon/tools.py", line 6454, in __init__
auth.add_membership(gid)
UnboundLocalError: local variable 'gid' referenced before assignment

Error snapshot [image: help] 


(local variable 'gid' referenced 
before assignment)

inspect attributes
Frames
   
   - 
   
   *File /var/www/libertymessengerweb2py/gluon/restricted.py in restricted 
   at line 227* code arguments variables
   - 
   
   *File 
   /var/www/libertymessengerweb2py/applications/wiki/controllers/default.py in 
at line 60* code arguments variables
   - 
   
   *File /var/www/libertymessengerweb2py/gluon/globals.py in  at 
   line 417* code arguments variables
   - 
   
   *File 
   /var/www/libertymessengerweb2py/applications/wiki/controllers/default.py in 
   index at line 20* code arguments variables
   - 
   
   *File /var/www/libertymessengerweb2py/gluon/tools.py in wiki at line 
   4687* code arguments variables
   - 
   
   *File /var/www/libertymessengerweb2py/gluon/tools.py in __init__ at line 
   6454* code arguments variables
   Function argument list
   
   (self=, auth=, 
   env=None, render='markmin', manage_permissions=False, force_prefix='', 
   restrict_search=False, extra={}, menu_groups=None, templates=None, 
   migrate=True, controller=None, function=None, groups=None)
   Code listing
   
   6449.
   6450.
   6451.
   6452.
   6453.
   6454.
   
   6455.
   6456.
   6457.
   6458.
   
   group = db.auth_group(role='wiki_editor')
   if group:
   gid = group.id
   else:
   db.auth_group.insert(role='wiki_editor')
   auth.add_membership(gid)
   
   
   settings.lock_keys = True
   
   # WIKI ACCESS POLICY
   
   
Thanks again for help!

\Jim


On Friday, July 8, 2016 at 1:01:56 PM UTC-4, Richard wrote:
>
> gid stand for group id...
>
> I grep the web2py code base you can see where gid is referenced :
>
> tools.py
> 6451:gid = group.id
> 6454:auth.add_membership(gid)
>
> contrib/fpdf/ttfonts.py
> 918:def getHMetric(self, numberOfHMetrics, gid): 
> 920:if (gid < numberOfHMetrics):
> 921:self.seek(start+(gid*4))
> 926:self.seek(start+(numberOfHMetrics*2)+(gid*2))
>
> contrib/pg8000/core.py
> 2057:curs.execute("select gid FROM pg_prepared_xacts")
>
> contrib/login_methods/ldap_auth.py
> 571:gid = db.auth_group.insert(role=group_to_add, 
> description='Generated from LDAP')
> 573:gid = db(db.auth_group.role == 
> group_to_add).select(db.auth_group.id).first().id
> 574:db.auth_membership.insert(user_id=db_user_id, 
> group_id=gid)
>
>
> We would need more information contain in the traceback in order to help.
>
> When you reinstall did you recreate you database?
>
> I may possible that it get half created or corrupted because your previous 
> issue when failling web2py production deployment.
>
> Or you can check that there is not wrongly defined users or 
> group/membership. For membership remaining despite group or user being 
> deleted...
>
> Good luck!
>
> Richard
>
>
> On Fri, Jul 8, 2016 at 12:27 PM, Jim Spoerl  > wrote:
>
>> Well, in the interest of trying out the wiki again, I tried to reinstall 
>> web2py from the "source" site download.  All went well.  I made sure all 
>> was well with permissions (www-data on Debian Wheezy) and with the SSL 
>> stuff including the admin password file.  Also the wsgi handler file was 
>> copied into th

Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Richard Vézina
Can you show you mods to the welcome please...

You may try to remove the auth.wiki() at line 60 of controllers/default.py
though we need to understand how to reproduce this error. There maybe a bug
in auth.wiki(). Difficult to say without knowing what you did...

Richard



On Fri, Jul 8, 2016 at 1:53 PM, Jim Spoerl  wrote:

> Thanks, Richard.  Nothing was left over from previous work since I
> reinstalled the root directory from scratch.  the DB is sqlite so we were
> starting from an empty DB.  So I think the problem must be in the
> downloaded source.  Is this correct?
>
> Here is the ticket:
>
> 24.233.114.172.2016-07-08.12-20-01.5cd46db0-031d-4ca5-abdb-7cadde73bc99
>  local variable 'gid' referenced
> before assignmentVersion
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
> Python Python 2.7.3: /usr/local/bin/uwsgi (prefix: /usr)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "/var/www/libertymessengerweb2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py" 
> ,
>  line 60, in 
>   File "/var/www/libertymessengerweb2py/gluon/globals.py", line 417, in 
> 
> self._caller = lambda f: f()
>   File 
> "/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py" 
> ,
>  line 20, in index
> return auth.wiki()
>   File "/var/www/libertymessengerweb2py/gluon/tools.py", line 4687, in wiki
> groups=groups)
>   File "/var/www/libertymessengerweb2py/gluon/tools.py", line 6454, in 
> __init__
> auth.add_membership(gid)
> UnboundLocalError: local variable 'gid' referenced before assignment
>
> Error snapshot [image: help]
> 
>
> (local variable 'gid' referenced
> before assignment)
>
> inspect attributes
> Frames
>
>-
>
>*File /var/www/libertymessengerweb2py/gluon/restricted.py in
>restricted at line 227* code arguments variables
>-
>
>*File
>/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py in
> at line 60* code arguments variables
>-
>
>*File /var/www/libertymessengerweb2py/gluon/globals.py in  at
>line 417* code arguments variables
>-
>
>*File
>/var/www/libertymessengerweb2py/applications/wiki/controllers/default.py in
>index at line 20* code arguments variables
>-
>
>*File /var/www/libertymessengerweb2py/gluon/tools.py in wiki at line
>4687* code arguments variables
>-
>
>*File /var/www/libertymessengerweb2py/gluon/tools.py in __init__ at
>line 6454* code arguments variables
>Function argument list
>
>(self=, auth=,
>env=None, render='markmin', manage_permissions=False, force_prefix='',
>restrict_search=False, extra={}, menu_groups=None, templates=None,
>migrate=True, controller=None, function=None, groups=None)
>Code listing
>
>6449.
>6450.
>6451.
>6452.
>6453.
>6454.
>
>6455.
>6456.
>6457.
>6458.
>
>group = db.auth_group(role='wiki_editor')
>if group:
>gid = group.id
>else:
>db.auth_group.insert(role='wiki_editor')
>auth.add_membership(gid)
>
>
>settings.lock_keys = True
>
># WIKI ACCESS POLICY
>
>
> Thanks again for help!
>
> \Jim
>
>
> On Friday, July 8, 2016 at 1:01:56 PM UTC-4, Richard wrote:
>>
>> gid stand for group id...
>>
>> I grep the web2py code base you can see where gid is referenced :
>>
>> tools.py
>> 6451:gid = group.id
>> 6454:auth.add_membership(gid)
>>
>> contrib/fpdf/ttfonts.py
>> 918:def getHMetric(self, numberOfHMetrics, gid):
>> 920:if (gid < numberOfHMetrics):
>> 921:self.seek(start+(gid*4))
>> 926:self.seek(start+(numberOfHMetrics*2)+(gid*2))
>>
>> contrib/pg8000/core.py
>> 2057:curs.execute("select gid FROM pg_prepared_xacts")
>>
>> contrib/login_methods/ldap_auth.py
>> 571:gid = db.auth_group.insert(role=group_to_add,
>> description='Generated from LDAP')
>> 573:gid = db(db.auth_group.role ==
>> group_to_add).select(db.auth_group.id).first().id
>> 574:db.auth_membership.insert(user_id=db_user_id,
>> group_id=gid)
>>
>>
>> We would need more information contain in the traceback in order to help.
>>
>> When you reinstall did you recreate you database?
>>
>> I may possible that it get half created or corrupted because your
>> previous issue when failling web2py production deployment.
>>
>> Or you can check that there is not wrongly defi

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
This should do it:

Field("with_kids", "integer", length = 1, notnull = False, default=None, 
required 
= False, requires=IS_NULL_OR(IS_INT_IN_RANGE(0,2)) )

Ive tested it and it converts correctly, and accepts the tri state.

Thanks again.

-- 
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: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 11:12:53 AM UTC-7, Richard wrote:
>
> Can you show you mods to the welcome please...
>
> You may try to remove the auth.wiki() at line 60 of controllers/default.py 
> though we need to understand how to reproduce this error. There maybe a bug 
> in auth.wiki(). Difficult to say without knowing what you did...
>
> Richard
>
>
>
>From the code snippet in the ticket, it looks like at line 6453, gid should 
be set with the result of the insert, but I haven't yet looked at the whole 
code.

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


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Dave S

On Friday, July 8, 2016 at 11:38:36 AM UTC-7, Dave S wrote:
>
>
> On Friday, July 8, 2016 at 11:12:53 AM UTC-7, Richard wrote:
>>
>> Can you show you mods to the welcome please...
>>
>> You may try to remove the auth.wiki() at line 60 of 
>> controllers/default.py though we need to understand how to reproduce this 
>> error. There maybe a bug in auth.wiki(). Difficult to say without knowing 
>> what you did...
>>
>> Richard
>>
>>
>>
> From the code snippet in the ticket, it looks like at line 6453, gid 
> should be set with the result of the insert, but I haven't yet looked at 
> the whole code.
>

As a test/workaround, a fresh install and manually creating the wiki_editor 
group (using the admin interface or the sqlite3 shell) should avoid the 
ticket.

I'm not sure why there are tickets still occurring after the initial one; 
the insert should have happened, but maybe that was lost when the db.commit 
didn't happen because of the exception.  This could be checked from the 
sqlite3 shell.

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


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Anthony

>
> From the code snippet in the ticket, it looks like at line 6453, gid 
>> should be set with the result of the insert, but I haven't yet looked at 
>> the whole code.
>>
>
> As a test/workaround, a fresh install and manually creating the 
> wiki_editor group (using the admin interface or the sqlite3 shell) should 
> avoid the ticket.
>
> I'm not sure why there are tickets still occurring after the initial one; 
> the insert should have happened, but maybe that was lost when the db.commit 
> didn't happen because of the exception.  This could be checked from the 
> sqlite3 shell.
>

No, the insert will be rolled back due to the exception.

Anyway, turns out this is a bug introduced recently (on April 17). I have 
filed an issue: https://github.com/web2py/web2py/issues/1389.

For now the workaround is to create the "wiki_editor" role manually rather 
than relying on auth.wiki() to create it automatically. It's just a 
one-time action, so not a big deal for now.

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.


Re: [web2py] orderby part of a string...

2016-07-08 Thread Richard Vézina
Answer is yes it work just fine...

db(db.ref_colorimeter_color.filter_parameter.belongs(['delta_a',
'delta_a_b'])).select(db.ref_colorimeter_color.color,
orderby="substring(color, '\(([^\)]+)\)')")

But with this :

db.ref_colorimeter_color.color.regexp('\(([^\)]+)\)')

It doesn't seems to work as DAL translate it into :

SELECT  ref_colorimeter_color.color
   FROM ref_colorimeter_color
WHERE (ref_colorimeter_color.filter_parameter IN ('delta_a_b','delta_a'))
ORDER BY (ref_colorimeter_color.color ~ '\(([^\)]+)\)');

Which don't seems to help in sorting record... I try to understand why
regexp get translated that way :


https://github.com/web2py/pydal/blob/e1136b6e29e4dbeb878cf9718c053aa790d909b5/pydal/dialects/postgre.py#L78

I am not sure the rational of :

order by field_name ~ regexp

I can find anything in postgres documentation as far as my search goes...

Richard






On Fri, Jul 8, 2016 at 1:04 PM, Richard  wrote:

> Can we do that :
>
>
> http://stackoverflow.com/questions/8989098/postgres-order-data-by-part-of-string
>
> ?
>
> Maybe like this ?
>
> orderby='substring(tablename.fieldname, ...)'
>
> ??
>
> Thanks
>
> Richard
>
> --
> 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: Do not show None

2016-07-08 Thread Alfonso Serra
Declare your field as:

 Field("price", "double", represent = lambda f, r: r.price if r.price != 
None else " ")

Here represent is a function that will format the field's value and takes 
the field itself and the row as arguments.

To display the table.

def index():
table = SQLTABLE(db(db.mytable).select())
return locals()


-- 
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: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Jim Spoerl
Creating the "wiki_editor" role manually is straightforward for you but 
since I am a beginner, I would appreciate it if you could show how this is 
done.
Thanks very much!   /Jim

On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:
>
> From the code snippet in the ticket, it looks like at line 6453, gid 
>>> should be set with the result of the insert, but I haven't yet looked at 
>>> the whole code.
>>>
>>
>> As a test/workaround, a fresh install and manually creating the 
>> wiki_editor group (using the admin interface or the sqlite3 shell) should 
>> avoid the ticket.
>>
>> I'm not sure why there are tickets still occurring after the initial one; 
>> the insert should have happened, but maybe that was lost when the db.commit 
>> didn't happen because of the exception.  This could be checked from the 
>> sqlite3 shell.
>>
>
> No, the insert will be rolled back due to the exception.
>
> Anyway, turns out this is a bug introduced recently (on April 17). I have 
> filed an issue: https://github.com/web2py/web2py/issues/1389.
>
> For now the workaround is to create the "wiki_editor" role manually rather 
> than relying on auth.wiki() to create it automatically. It's just a 
> one-time action, so not a big deal for now.
>
> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 12:55:09 PM UTC-7, Jim Spoerl wrote:
>
> Creating the "wiki_editor" role manually is straightforward for you but 
> since I am a beginner, I would appreciate it if you could show how this is 
> done.
> Thanks very much!   /Jim
>
>
cd web2py/applications/myapp
sqlite3 databases/storage.sqlite
INSERT INTO "auth_group" VALUES(99,'wiki_editor','Authorized editors group') 
;
.quit

(change the 99 to the next available value; do "SELECT * from auth_group" 
to find out what's been used)\

(If the admin interface was working, it would handle

 

> On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:
>>
>> From the code snippet in the ticket, it looks like at line 6453, gid 
 should be set with the result of the insert, but I haven't yet looked at 
 the whole code.

>>>
>>> As a test/workaround, a fresh install and manually creating the 
>>> wiki_editor group (using the admin interface or the sqlite3 shell) should 
>>> avoid the ticket.
>>>
>>> I'm not sure why there are tickets still occurring after the initial 
>>> one; the insert should have happened, but maybe that was lost when the 
>>> db.commit didn't happen because of the exception.  This could be checked 
>>> from the sqlite3 shell.
>>>
>>
>> No, the insert will be rolled back due to the exception.
>>
>> Anyway, turns out this is a bug introduced recently (on April 17). I have 
>> filed an issue: https://github.com/web2py/web2py/issues/1389.
>>
>> For now the workaround is to create the "wiki_editor" role manually 
>> rather than relying on auth.wiki() to create it automatically. It's just a 
>> one-time action, so not a big deal for now.
>>
>> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Anthony
You can use appadmin to make an insert in the db.auth_group table or follow 
the documentation (see auth.add_group): 
http://web2py.com/books/default/chapter/29/09/access-control#Authorization.

Anthony

On Friday, July 8, 2016 at 3:55:09 PM UTC-4, Jim Spoerl wrote:
>
> Creating the "wiki_editor" role manually is straightforward for you but 
> since I am a beginner, I would appreciate it if you could show how this is 
> done.
> Thanks very much!   /Jim
>
> On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:
>>
>> From the code snippet in the ticket, it looks like at line 6453, gid 
 should be set with the result of the insert, but I haven't yet looked at 
 the whole code.

>>>
>>> As a test/workaround, a fresh install and manually creating the 
>>> wiki_editor group (using the admin interface or the sqlite3 shell) should 
>>> avoid the ticket.
>>>
>>> I'm not sure why there are tickets still occurring after the initial 
>>> one; the insert should have happened, but maybe that was lost when the 
>>> db.commit didn't happen because of the exception.  This could be checked 
>>> from the sqlite3 shell.
>>>
>>
>> No, the insert will be rolled back due to the exception.
>>
>> Anyway, turns out this is a bug introduced recently (on April 17). I have 
>> filed an issue: https://github.com/web2py/web2py/issues/1389.
>>
>> For now the workaround is to create the "wiki_editor" role manually 
>> rather than relying on auth.wiki() to create it automatically. It's just a 
>> one-time action, so not a big deal for now.
>>
>> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Jim Spoerl
OK.  I will try that when I can find a few moments of "prime" time. By the 
way, it seems strange to me that no one else reported this in the two and a 
half months since the error was introduced.  Is there really so little use 
of web2py these days.  That would be so strange since it seems to me to be 
a framework with a very easy learning curve compared with others.

Again, thanks to you and others here in this group who have helped me. 
 This is really great.
\Jim

On Friday, July 8, 2016 at 4:31:33 PM UTC-4, Anthony wrote:
>
> You can use appadmin to make an insert in the db.auth_group table or 
> follow the documentation (see auth.add_group): 
> http://web2py.com/books/default/chapter/29/09/access-control#Authorization
> .
>
> Anthony
>
> On Friday, July 8, 2016 at 3:55:09 PM UTC-4, Jim Spoerl wrote:
>>
>> Creating the "wiki_editor" role manually is straightforward for you but 
>> since I am a beginner, I would appreciate it if you could show how this is 
>> done.
>> Thanks very much!   /Jim
>>
>> On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:
>>>
>>> From the code snippet in the ticket, it looks like at line 6453, gid 
> should be set with the result of the insert, but I haven't yet looked at 
> the whole code.
>

 As a test/workaround, a fresh install and manually creating the 
 wiki_editor group (using the admin interface or the sqlite3 shell) should 
 avoid the ticket.

 I'm not sure why there are tickets still occurring after the initial 
 one; the insert should have happened, but maybe that was lost when the 
 db.commit didn't happen because of the exception.  This could be checked 
 from the sqlite3 shell.

>>>
>>> No, the insert will be rolled back due to the exception.
>>>
>>> Anyway, turns out this is a bug introduced recently (on April 17). I 
>>> have filed an issue: https://github.com/web2py/web2py/issues/1389.
>>>
>>> For now the workaround is to create the "wiki_editor" role manually 
>>> rather than relying on auth.wiki() to create it automatically. It's just a 
>>> one-time action, so not a big deal for now.
>>>
>>> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 1:31:33 PM UTC-7, Anthony wrote:
>
> You can use appadmin to make an insert in the db.auth_group table or 
> follow the documentation (see auth.add_group): 
> http://web2py.com/books/default/chapter/29/09/access-control#Authorization
> .
>
> Anthony
>

I was assuming appadmin would not work, but that controller wouldn't be 
looking for the missing gid, would it?

/dps

 

>
> On Friday, July 8, 2016 at 3:55:09 PM UTC-4, Jim Spoerl wrote:
>>
>> Creating the "wiki_editor" role manually is straightforward for you but 
>> since I am a beginner, I would appreciate it if you could show how this is 
>> done.
>> Thanks very much!   /Jim
>>
>> On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:
>>>
>>> From the code snippet in the ticket, it looks like at line 6453, gid 
> should be set with the result of the insert, but I haven't yet looked at 
> the whole code.
>

 As a test/workaround, a fresh install and manually creating the 
 wiki_editor group (using the admin interface or the sqlite3 shell) should 
 avoid the ticket.

 I'm not sure why there are tickets still occurring after the initial 
 one; the insert should have happened, but maybe that was lost when the 
 db.commit didn't happen because of the exception.  This could be checked 
 from the sqlite3 shell.

>>>
>>> No, the insert will be rolled back due to the exception.
>>>
>>> Anyway, turns out this is a bug introduced recently (on April 17). I 
>>> have filed an issue: https://github.com/web2py/web2py/issues/1389.
>>>
>>> For now the workaround is to create the "wiki_editor" role manually 
>>> rather than relying on auth.wiki() to create it automatically. It's just a 
>>> one-time action, so not a big deal for now.
>>>
>>> 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 1:46:24 PM UTC-7, Jim Spoerl wrote:
>
> OK.  I will try that when I can find a few moments of "prime" time. By the 
> way, it seems strange to me that no one else reported this in the two and a 
> half months since the error was introduced.  Is there really so little use 
> of web2py these days.  That would be so strange since it seems to me to be 
> a framework with a very easy learning curve compared with others.
>
> Again, thanks to you and others here in this group who have helped me. 
>  This is really great.
> \Jim
>
>
Lots of use of web2py, but the wiki feature may not be heavily used.  My 
projects don't need it, although it could be the basis of a very simple CMS
(use Mercurial to track changes to pages, because "management"  implies 
tracking)

/dps
 

> On Friday, July 8, 2016 at 4:31:33 PM UTC-4, Anthony wrote:
>>
>> You can use appadmin to make an insert in the db.auth_group table or 
>> follow the documentation (see auth.add_group): 
>> http://web2py.com/books/default/chapter/29/09/access-control#Authorization
>> .
>>
>> Anthony
>>
>> On Friday, July 8, 2016 at 3:55:09 PM UTC-4, Jim Spoerl wrote:
>>>
>>> Creating the "wiki_editor" role manually is straightforward for you but 
>>> since I am a beginner, I would appreciate it if you could show how this is 
>>> done.
>>> Thanks very much!   /Jim
>>>
>>> On Friday, July 8, 2016 at 2:55:19 PM UTC-4, Anthony wrote:

 From the code snippet in the ticket, it looks like at line 6453, gid 
>> should be set with the result of the insert, but I haven't yet looked at 
>> the whole code.
>>
>
> As a test/workaround, a fresh install and manually creating the 
> wiki_editor group (using the admin interface or the sqlite3 shell) should 
> avoid the ticket.
>
> I'm not sure why there are tickets still occurring after the initial 
> one; the insert should have happened, but maybe that was lost when the 
> db.commit didn't happen because of the exception.  This could be checked 
> from the sqlite3 shell.
>

 No, the insert will be rolled back due to the exception.

 Anyway, turns out this is a bug introduced recently (on April 17). I 
 have filed an issue: https://github.com/web2py/web2py/issues/1389.

 For now the workaround is to create the "wiki_editor" role manually 
 rather than relying on auth.wiki() to create it automatically. It's just a 
 one-time action, so not a big deal for now.

 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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 4:39:58 PM UTC-4, Dave S wrote:
>
>
>
> On Friday, July 8, 2016 at 1:31:33 PM UTC-7, Anthony wrote:
>>
>> You can use appadmin to make an insert in the db.auth_group table or 
>> follow the documentation (see auth.add_group): 
>> http://web2py.com/books/default/chapter/29/09/access-control#Authorization
>> .
>>
>> Anthony
>>
>
> I was assuming appadmin would not work, but that controller wouldn't be 
> looking for the missing gid, would it?
>

This has nothing to do with appadmin -- the bug is with the wiki only. If 
you are (a) logged into the app, (b) also logged into admin, and (c) the 
"wiki_editor" group does not yet exist, then the wiki creates the 
"wiki_editor" role and assigns you to it. The problem is that a bug in the 
wiki code prevents this from working.

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.


Re: [web2py] Re: Can't get a working web2py that will support many of the example apps. Most seem to be broken!

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 4:46:24 PM UTC-4, Jim Spoerl wrote:
>
> OK.  I will try that when I can find a few moments of "prime" time. By the 
> way, it seems strange to me that no one else reported this in the two and a 
> half months since the error was introduced.  Is there really so little use 
> of web2py these days.  That would be so strange since it seems to me to be 
> a framework with a very easy learning curve compared with others.
>

Probably just not many new users who (a) use the wiki, (b) rely on the 
automatic creation of the "wiki_editor" group, and (c) are willing to take 
the time to report the problem. I don't see a lot of questions about the 
wiki, so I get the sense it is not the most popular feature.

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.


Re: [web2py] orderby part of a string...

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 12:13:41 PM UTC-7, Richard wrote:
>
> Answer is yes it work just fine...
>
> db(db.ref_colorimeter_color.filter_parameter.belongs(['delta_a', 
> 'delta_a_b'])).select(db.ref_colorimeter_color.color, 
> orderby="substring(color, '\(([^\)]+)\)')")
>
> But with this :
>
> db.ref_colorimeter_color.color.regexp('\(([^\)]+)\)')
>
> It doesn't seems to work as DAL translate it into :
>
> SELECT  ref_colorimeter_color.color 
>FROM ref_colorimeter_color 
> WHERE (ref_colorimeter_color.filter_parameter IN ('delta_a_b','delta_a')) 
> ORDER BY (ref_colorimeter_color.color ~ '\(([^\)]+)\)');
>
> Which don't seems to help in sorting record... I try to understand why 
> regexp get translated that way :
>
>
>
> https://github.com/web2py/pydal/blob/e1136b6e29e4dbeb878cf9718c053aa790d909b5/pydal/dialects/postgre.py#L78
>
> I am not sure the rational of :
>
> order by field_name ~ regexp
>
> I can find anything in postgres documentation as far as my search goes...
>
> Richard
>
>
OT:  that's one of those regexps that makes me dizzy.  Trying to find 
strings that begin with a part in parentheses?

/dps

 

>
>
>
> On Fri, Jul 8, 2016 at 1:04 PM, Richard  > wrote:
>
>> Can we do that :
>>
>>
>> http://stackoverflow.com/questions/8989098/postgres-order-data-by-part-of-string
>>
>> ?
>>
>> Maybe like this ?
>>
>> orderby='substring(tablename.fieldname, ...)'
>>
>> ??
>>
>> Thanks
>>
>> Richard
>>
>> -- 
>> 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+un...@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: Uploading multiple images in web2py

2016-07-08 Thread Fabio Ceccarani
Thanks Ron.
Thanks Massimo, I have 6 upload fields (img01, img02,...img06); there is 
way to use multiple upload with only one  in a 
SQLFORM? 

Thanks
Fabio

Il giorno mercoledì 6 luglio 2016 09:45:53 UTC+2, Massimo Di Pierro ha 
scritto:
>
> Mind that with modern browsers (tested on chrome), dropzone is not 
> necessary as it is the default behavior. All you need to do is use CSS to 
> style the  to make it clear to users they can drop 
> files there.
>
> On Tuesday, 5 July 2016 16:28:11 UTC-5, Fabio Ceccarani wrote:
>>
>> I'm trying with dropzone.js but I have some difficult to integrate it in 
>> sqlform. Someone has used it with sqlform?
>> Thanks
>> Fabio
>
>

-- 
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] web2py traceback is not clear to tell the error

2016-07-08 Thread 黄祥
let say i have a code:
*models/db_wizard_1_bank.py*
db.define_table('bank', 
Field('name'), 
Field('website'), 
format = '%(name)s')

*controllers/install.py*
def index():
if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
# create index : auth_user
db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
last_name, email, username);')

# insert : bank
db.bank.bulk_insert([
{'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
{'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )

session.flash = T('Installation Done')
redirect(URL('default', 'index') )

as you can see, i made a mistake during insert to table bank field name1 
(incorrect), should be field name in table bank, but the traceback error 
said is different.

what i got in traceback error :

Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
, 
line 412, in 
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
, 
line 9, in index
db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
last_name, email, username);')
  File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/base.py", line 
1019, in executesql
adapter.execute(query)
  File 
"/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1388, in execute
return self.log_execute(*a, **b)
  File 
"/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
1382, in log_execute
ret = self.get_cursor().execute(command, *a[1:], **b)
OperationalError: index idx_auth_user already exists

Error snapshot [image: help] 


(index idx_auth_user already exists)

again, same code with different structure order (insert first then create 
index) in install.py
*controllers/install.py*
def index():
if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
# insert : bank
db.bank.bulk_insert([
{'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
{'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )

# create index : auth_user
db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
last_name, email, username);')

session.flash = T('Installation Done')
redirect(URL('default', 'index') )

as you can see, i made a mistake during insert to table bank field name1 
(incorrect), should be field name in table bank, but the traceback error 
said is straight to the point to show where is my mistake.

what i got in traceback error :

Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
, 
line 412, in 
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
self._caller = lambda f: f()
  File "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
, 
line 55, in index
{'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
  File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
line 828, in bulk_insert
listify_items = [self._listify(item) for item in items]
  File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
line 641, in _listify
'Field %s does not belong to the table' % name)
SyntaxError: Field name1 does not belong to the table

Error snapshot [image: help] 


(Field name1 does not belong to the table)

the solution is either i comment the create index part or change the order 
to get the clear traceback error, my question is it normal?

thanks and 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: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Sorry, to finish up some considerations...

Ive been investigating how web2py assigns default validators to field 
types. 

If im not wrong this is done by SQLFORM which imports a function from 
gluon.dal called _default_validators.

In this function the relationship between web2py field types and validators 
is hardcoded.

Its a shame that these relationships cannot be extended since it looks like 
creating a new field type, is as easy as something like:
db._adapter.types['booleantri']='TINYINT(1)'

I have tried it and  
Field("with_kids", "booleantri", requires=IS_NULL_OR(IS_INT_IN_RANGE(0,2)))
works as expected so far. 

Of course it might not be this obvious to create a field type (or maybe it 
is) but the point is that it would be great if we could declare a default 
validator for this sort of custom field types.

I guess that with some python surgery it can be done by overloading this 
_default_validators function but yes, it would be great if there were a way 
without hacking.

Thanks




-- 
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: web2py traceback is not clear to tell the error

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 5:47:42 PM UTC-7, 黄祥 wrote:
>
> let say i have a code:
> *models/db_wizard_1_bank.py*
> db.define_table('bank', 
> Field('name'), 
> Field('website'), 
> format = '%(name)s')
>
> *controllers/install.py*
> def index():
> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
> # create index : auth_user
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>
> # insert : bank
> db.bank.bulk_insert([
> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>
> session.flash = T('Installation Done')
> redirect(URL('default', 'index') )
>
> as you can see, i made a mistake during insert to table bank field name1 
> (incorrect), should be field name in table bank, but the traceback error 
> said is different.
>
> what i got in traceback error :
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 412, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 9, in index
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>
>
This line is saying the first ticket occurs before your insert line.  I 
think it means you previously created an index, and now you're trying to do 
it again.

I have next-to-no experiences with indexes or indices because my DBs 
contain only thousands of entries (barely, and often much less).  But it 
looks like the order of statements is not relevant compared to previous 
activity.

/dps



 

>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/base.py", line 
> 1019, in executesql
> adapter.execute(query)
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1388, in execute
> return self.log_execute(*a, **b)
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1382, in log_execute
> ret = self.get_cursor().execute(command, *a[1:], **b)
> OperationalError: index idx_auth_user already exists
>
> Error snapshot [image: help] 
> 
>
> (index idx_auth_user already exists)
>
> again, same code with different structure order (insert first then create 
> index) in install.py
> *controllers/install.py*
> def index():
> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
> # insert : bank
> db.bank.bulk_insert([
> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>
> # create index : auth_user
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>
> session.flash = T('Installation Done')
> redirect(URL('default', 'index') )
>
> as you can see, i made a mistake during insert to table bank field name1 
> (incorrect), should be field name in table bank, but the traceback error 
> said is straight to the point to show where is my mistake.
>
> what i got in traceback error :
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 412, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 55, in index
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
> line 828, in bulk_insert
> listify_items = [self._listify(item) for item in items]
>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
> line 641, in _listify
> 'Field %s does not belong to the table' % name)
> SyntaxError: Field name1 does not belong to the table
>
> Error snapshot [image: help] 
> 
>
> (Field name1 does not belong to the table)
>
> the solution is either i comment the create index part or

[web2py] Re: web2py traceback is not clear to tell the error

2016-07-08 Thread Marlysson Silva
The keys of dictionary of bulk_insert are fields of table that you want you 
insert.
Try so:

db.bank.bulk_insert([ {'name' : 'bank0', 'website' : 'http://www.bank0.com'
},  {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )

Em sexta-feira, 8 de julho de 2016 21:47:42 UTC-3, 黄祥 escreveu:
>
> let say i have a code:
> *models/db_wizard_1_bank.py*
> db.define_table('bank', 
> Field('name'), 
> Field('website'), 
> format = '%(name)s')
>
> *controllers/install.py*
> def index():
> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
> # create index : auth_user
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>
> # insert : bank
> db.bank.bulk_insert([
> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>
> session.flash = T('Installation Done')
> redirect(URL('default', 'index') )
>
> as you can see, i made a mistake during insert to table bank field name1 
> (incorrect), should be field name in table bank, but the traceback error 
> said is different.
>
> what i got in traceback error :
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 412, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 9, in index
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/base.py", line 
> 1019, in executesql
> adapter.execute(query)
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1388, in execute
> return self.log_execute(*a, **b)
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1382, in log_execute
> ret = self.get_cursor().execute(command, *a[1:], **b)
> OperationalError: index idx_auth_user already exists
>
> Error snapshot [image: help] 
> 
>
> (index idx_auth_user already exists)
>
> again, same code with different structure order (insert first then create 
> index) in install.py
> *controllers/install.py*
> def index():
> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
> # insert : bank
> db.bank.bulk_insert([
> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>
> # create index : auth_user
> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
> last_name, email, username);')
>
> session.flash = T('Installation Done')
> redirect(URL('default', 'index') )
>
> as you can see, i made a mistake during insert to table bank field name1 
> (incorrect), should be field name in table bank, but the traceback error 
> said is straight to the point to show where is my mistake.
>
> what i got in traceback error :
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 412, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
> ,
>  line 55, in index
> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
> line 828, in bulk_insert
> listify_items = [self._listify(item) for item in items]
>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
> line 641, in _listify
> 'Field %s does not belong to the table' % name)
> SyntaxError: Field name1 does not belong to the table
>
> Error snapshot [image: help] 
> 
>
> (Field name1 does not belong to the table)
>
> the solution is either i comment the create index part or change the order 
> to get the clear traceback error, my question is it normal?
>
> thanks and best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- htt

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Anthony
On Friday, July 8, 2016 at 8:51:21 PM UTC-4, Alfonso Serra wrote:
>
> Sorry, to finish up some considerations...
>
> Ive been investigating how web2py assigns default validators (or widgets) 
> to field types. 
>
> If im not wrong this is done by SQLFORM which imports a function from 
> gluon.dal called _default_validators.
>

Actually, pydal (independent of web2py) includes two ways of specifying 
default validators based on field type -- the DAL has class attributes 
"validator_method" and "validators". The first is a function that takes a 
DAL instance and a Field and returns a validator, and the second is a 
dictionary mapping field types to validators. The gluon.dal module is part 
of web2py, and it sets the DAL.validator_method function to 
_default_validators, but you are free to override that, or use the 
DAL.validators dictionary as an alternative (you would first have to delete 
DAL.validator_method, as it takes precedence over DAL.validators).
 

> Its a shame that these relationships cannot be extended since it looks 
> like creating a new field type, is as easy as something like:
> db._adapter.types['booleantri']='TINYINT(1)'
>
> Actually, the API for creating a custom field type is 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Custom-Field-types--experimental-.
 
Note, it isn't documented, but SQLCustomType also takes "validator", 
"represent", "widget", and "_class" arguments, so you can specify defaults 
for all of those attributes as well (i.e., no need to bother with 
DAL.validator_method or _default_validators).

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: how to handle boolean's tri states?

2016-07-08 Thread Dave S

On Friday, July 8, 2016 at 7:41:19 AM UTC-7, Alfonso Serra wrote:
>
> [...]
> In any case the "with_kids" fields from the filter's table should be a 
> boolean tristate, that i should handle properly when the form is processed. 
> Not when the form its saved into the db, if its saved. 
>


I'm inclined to say that this is a misapplication of "Boolean".   Tri-state 
logic is not Boolean.  Boolean is True or False.

I think I would consider this to be an appropriate place for an enumeration 
(C terminology) of {DONTCARE, YES, NO}.  And C enumertions are essentially 
a special way of writing range(0 .. n).  Why not just use an int and the 
IN_RANGE() validator?

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


[web2py] Re: web2py traceback is not clear to tell the error

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 6:31:29 PM UTC-7, Marlysson Silva wrote:
>
> The keys of dictionary of bulk_insert are fields of table that you want 
> you insert.
> Try so:
>
> db.bank.bulk_insert([ {'name' : 'bank0', 'website' : 'http://www.bank0.com
> '},  {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>
>
That's what he did, except for the typo.  But what caused the first ticket 
seems to be already having an index.

/dps

 

> Em sexta-feira, 8 de julho de 2016 21:47:42 UTC-3, 黄祥 escreveu:
>>
>> let say i have a code:
>> *models/db_wizard_1_bank.py*
>> db.define_table('bank', 
>> Field('name'), 
>> Field('website'), 
>> format = '%(name)s')
>>
>> *controllers/install.py*
>> def index():
>> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
>> # create index : auth_user
>> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
>> last_name, email, username);')
>>
>> # insert : bank
>> db.bank.bulk_insert([
>> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
>> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>>
>> session.flash = T('Installation Done')
>> redirect(URL('default', 'index') )
>>
>> as you can see, i made a mistake during insert to table bank field name1 
>> (incorrect), should be field name in table bank, but the traceback error 
>> said is different.
>>
>> what i got in traceback error :
>>
>> Traceback (most recent call last):
>>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
>> ,
>>  line 412, in 
>>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
>> ,
>>  line 9, in index
>> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
>> last_name, email, username);')
>>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/base.py", 
>> line 1019, in executesql
>> adapter.execute(query)
>>   File 
>> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 1388, in execute
>> return self.log_execute(*a, **b)
>>   File 
>> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 1382, in log_execute
>> ret = self.get_cursor().execute(command, *a[1:], **b)
>> OperationalError: index idx_auth_user already exists
>>
>> Error snapshot [image: help] 
>> 
>>
>> (index idx_auth_user already exists)
>>
>> again, same code with different structure order (insert first then create 
>> index) in install.py
>> *controllers/install.py*
>> def index():
>> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
>> # insert : bank
>> db.bank.bulk_insert([
>> {'name1' : 'bank0', 'website' : 'http://www.bank0.com'}, 
>> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>>
>> # create index : auth_user
>> db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name, 
>> last_name, email, username);')
>>
>> session.flash = T('Installation Done')
>> redirect(URL('default', 'index') )
>>
>> as you can see, i made a mistake during insert to table bank field name1 
>> (incorrect), should be field name in table bank, but the traceback error 
>> said is straight to the point to show where is my mistake.
>>
>> what i got in traceback error :
>>
>> Traceback (most recent call last):
>>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
>> ,
>>  line 412, in 
>>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/test/controllers/install.py" 
>> ,
>>  line 55, in index
>> {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
>>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
>> line 828, in bulk_insert
>> listify_items = [self._listify(item) for item in items]
>>   File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
>> line 641, in _listify
>> 'Field %s does not belong to the table' % name)
>> SyntaxError: Field name1 does not belong to the table
>>
>> Error snapshot [image: help] 
>> 

[web2py] Re: web2py traceback is not clear to tell the error

2016-07-08 Thread 黄祥
the apps is build from scratch, no created index before either from apps 
and from database side. the only place i create index is in the 
controllers/install.py, and it's only execute one time only.

my logic during first code install script is :
execute create index first then execute insert table, if auth_permission 
and auth_membership is empty 

my logic during second code install script is :
execute insert table first then execute create index, if auth_permission 
and auth_membership is empty 

why the traceback didn't straight to the point show my mistake on the first 
code and it's show my mistake straight to the point on second code?

thanks and 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: web2py traceback is not clear to tell the error

2016-07-08 Thread Dave S


On Friday, July 8, 2016 at 8:12:39 PM UTC-7, 黄祥 wrote:
>
> the apps is build from scratch, no created index before either from apps 
> and from database side. the only place i create index is in the 
> controllers/install.py, and it's only execute one time only.
>
> my logic during first code install script is :
> execute create index first then execute insert table, if auth_permission 
> and auth_membership is empty 
>
> my logic during second code install script is :
> execute insert table first then execute create index, if auth_permission 
> and auth_membership is empty 
>
> why the traceback didn't straight to the point show my mistake on the 
> first code and it's show my mistake straight to the point on second code?
>
> thanks and best regards,
> stifan
>


All I can tell you is that in the first ticket, it never got to the line 
with the typo, because it had already blown up thinking there was an 
existing index.

 I putter around in sqlite all the time, but I don't know how it does 
indexing, so someone else will have to jump in.

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


[web2py] running web2py module from terminal return AttributeError: 'thread._local' object has no attribute '

2016-07-08 Thread 黄祥
i have web2py modules that insert new data for new web2py app:
*modules/test_install.py*
#!/usr/bin/env python
# coding: utf8

import sys; 
sys.path.append('site/web2py/')

from gluon import current
#from gluon import *
from gluon.contrib.webclient import WebClient

install = WebClient('http://127.0.0.1:8000/test/install/',
postbacks = True)

install.get('index')

*if current.T('Installation Done') in install.text:*
print "Installation Done"
else:
print "Installation Failed"

Web2py had already running with :
python ~/site/web2py/web2py.py

But when i tried to execute web2py module in another terminal on the same 
machine it return an error

Test:~ Test$ python ~/site/web2py/applications/test/modules/test_install.py
Traceback (most recent call last):
  File 
"/Users/MacBookPro/site/web2py/applications/test/modules/test_install.py", 
line 18, in 
if current.T('Installation Done') in install.text:
AttributeError: 'thread._local' object has no attribute 'T'

is there any way to fix it?

thanks and 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.