Re: [web2py] Re: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread Anthony
On Friday, March 29, 2019 at 5:42:10 PM UTC-4, João Matos wrote:
>
> Found a solution (more like a kludge) :)
>
> form.element('#no_table_sn')['_readonly'] = 'readonly' 
>
I even tried adding 
>
> _readonly='readonly'
>
> to the Field, but didn't work.
>
> Only works after the form exists.
>

Field('sn', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, 
_readonly=True))


> Is there a better way?
>

As noted earlier, you can use the "fields" argument.

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 add a read-only field to a SQLFORM.factory

2019-03-29 Thread Anthony
On Friday, March 29, 2019 at 5:04:41 PM UTC-4, João Matos wrote:
>
> @Anthony
> This is a SQLFORM.factory not a SQLFORM.
> There is no database.
> Are you sure fields parameter is applicable to SQLFORM.factory w/o a db?
>

Yes, it does work with SQLFORM.factory.

>

-- 
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: In praise of the lowly "nested_select"

2019-03-29 Thread Joe Barnhart
Sorry for the delay in replying.

The first step is to create a Select object, rather than an Expression. 
 Look again at the code:
subq = db(dbts.id>0).nested_select(dbts.ALL,...etc)

This creates a Select object.  The Select object implements "on".  (Table 
also implements "on", but not Expression)

I should come up with a simpler example.  This one was just grabbed 
directly out of my site so I knew it worked but i's too complex to just 
show the concept.

-- Joe



On Wednesday, February 13, 2019 at 11:22:46 AM UTC-8, Skiros wrote:
>
> Hello !
> Very interesting !!!
>
> I'm trying to reproduce this behaviour but I'm getting this error 
> "Expression object has no attribute on". What version of w2p are you using ?
>

-- 
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: In praise of the lowly "nested_select"

2019-03-29 Thread Joe Barnhart
Sorry I didn't see this question earlier.

The "on" attribute is on the Table object.  If you look at the code, I use 
variables like

dbt = db.times

This allows me to use "dbt.xxx" to access the Table object directly.  I 
find it a convenient syntactic shorthand because I'm always using it to get 
to Fields and other table-related items.

So, to reiterate, the "on" function is in the Table, not Expression.

-- Joe


On Wednesday, February 13, 2019 at 11:22:46 AM UTC-8, Skiros wrote:
>
> Hello !
> Very interesting !!!
>
> I'm trying to reproduce this behaviour but I'm getting this error 
> "Expression object has no attribute on". What version of w2p are you using ?
>

-- 
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: Redis and Python3?

2019-03-29 Thread Joe Barnhart
Hi Leonel --

My brain refuses to put together the words "session locked field".  I 
understand the part of pickle smashing the values and encoding them as one 
string.  The bool has something to do with session locking?  

I've only looked at the web2py redis code in the most scant way as I wasn't 
planning to become a redis expert.  Sessions in redis could be important to 
me, tho, so I may need to set aside some time to dig into it.  (Storing 
sessions in cookies has been problematic due to the limited space for 
cookies in browsers.)

-- Joe


On Wednesday, March 27, 2019 at 4:49:25 PM UTC-7, Leonel Câmara wrote:
>
> It's not your values Joe, pickle serializes them as a string so they would 
> be fine. It's web2py session locked field which is True or False. It's 
> probably easy to fix this in redis_session.py
>

-- 
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: Not my type

2019-03-29 Thread Joe Barnhart
I suspect you were actually running Python 3.x in which case "print xxx" 
doesn't work because print has been mad into a function (requiring 
parentheses).  When I start each on my Mac, this is the display I get:

Python 2.7:

ssmain:~ jbarnhart$ python

Python 2.7.10 (default, Feb 22 2019, 21:17:52)

[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> 


Python 3.7:

ssmain:~ jbarnhart$ 

ssmain:~ jbarnhart$ python3

Python 3.7.2 (default, Feb 12 2019, 08:15:36) 

[Clang 10.0.0 (clang-1000.11.45.5)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> 

You should be able to tell the version by the startup message.  If you are 
actually running Python 2 and the code fails, copy and paste the actual 
error message you get and we'll puzzle it out.

Warm regards,
Joe




On Friday, March 29, 2019 at 7:32:52 AM UTC-7, Al Hart wrote:
>
> Hi Joe,
>
> Thanks so much for responding. Let me be more specific. I was referring to a 
> section in the book, chapter two, on types 
> .
> In there it suggests
>
> >>> a = 3>>> print type(a)
>>
>> But that didn't work for me, I got error messages (don't recall what they 
> were at this moment).
> However, when I tried it using two other methods...
> 1.
>
>> >>> a = 3 
>
> >>> type(a)
>
> or
> 2.
>
>> >>> a = 3 
>
> >>> print(type(a))
>
>
> Both of those worked for me. Kind of weird because when I checked which 
> version of python I had running  it said 2.7 but perhaps I installed w2p 
> with python3.
>
> Anyway, at the end I was suggesting that maybe we could update the book 
> some making reference to how things might look with python3. I wasn't sure 
> if that sort of thing is just done here, by mentioning it in the forum and 
> someone will get to it, or if it might be done by pull request.
>
> Best,
>
> Al
>
> On Thu, Mar 28, 2019 at 9:30 PM Joe Barnhart  > wrote:
>
>> Hi Al --
>>
>> First off, welcome to the web2py group.  Next, it's not clear from your 
>> message just what the question is.  If you can elaborate on (a) what you 
>> did, (b) what you expected, and (c) what you got, I'm sure someone here can 
>> help
>>
>> Warm regards,
>>
>> Joe B.
>>
>> On Thursday, March 28, 2019 at 2:10:50 AM UTC-7, Al Hart wrote:
>>>
>>> Hi folks, if you'll pardon the corny title, I am brand new to web2py (so 
>>> excited to discover it) and I'm just working may way through the book. In 
>>> Chapter two, the section on types, I tried to run the examples, but I got 
>>> error messages. Googling around it seemed to work better if I went one of 
>>> two ways:
>>>
>>>
>>>1. a = 3
>>>type(a)
>>>2. a = 4 
>>>print(type(a))
>>>
>>>
>>> I'm on Ubuntu 18.04. Not sure if the example is based on python 3? If 
>>> not, is this the best way to suggest updates to the book or should we just 
>>> try a pull request? 
>>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/VityJ20AV2M/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@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: Grid sorting questions (referenced fields and case sensitive)

2019-03-29 Thread João Matos
Found a kludge to sort the grid's search fields list.

# Sort grid's search fields list.
grid.element('#w2p_query_fields').components = 
sort_grid_search_fields_list(grid)


def sort_grid_search_fields_list(grid: gluon.DIV) -> List[gluon.OPTION]:
"""Sort grid's search fields list.

:param grid: Grid.
:return: Sorted search fields list (HTML options).
"""
keys: List[str] = []
elements: Dict[str, str] = {}
for element in grid.element('#w2p_query_fields').components:  # type: 
gluon.OPTION
keys.append(element.flatten())
elements[element.flatten()] = element['_value']
keys.sort(key=str.lower)
return [gluon.OPTION(key, _value=elements[key]) for key in keys]


quinta-feira, 28 de Março de 2019 às 21:13:04 UTC, João Matos escreveu:
>
> Hello,
>
> I have these 2 tables opt and opt_cat, where opt depends on opt_cat for 
> the category name and other settings.
>
> db.define_table('opt',
> Field('name', 'string', label=T('Name'), length=NAME_LEN, 
> notnull=True,
>   required=True, unique=True),
> Field('opt_cat_id', 'reference opt_cat', label=T(
> 'Category'),
>   notnull=True, required=True),
> auth.signature,
> format='%(name)s',
> )
>
> db.define_table('opt_cat',
> Field('name', 'string', label=T('Name in Portuguese'), 
> length=NAME_LEN,
>   notnull=True, required=True, unique=True),
> Field('name_en', 'string', label=T('Name in English'),
>   length=NAME_LEN, notnull=True, required=True, unique
> =True),
> Field('mandatory', 'boolean', default=False,
>   label=T('Mandatory'), notnull=True, required=True),
> Field('one_opt_only', 'boolean', default=False,
>   label=T('One option only'), notnull=True, required=
> True),
> auth.signature,
> format='%(name)s',
> )
>
> I was testing grid sort and found that a grid like this
>
> table = db.opt
>
> grid = SQLFORM.grid(
> table,
> csv=False,
> details=False,
> maxtextlength=GRID_COL_LEN_FOR_TEXT,
> ondelete=on_delete,  # Grid only.
> onvalidation=on_validation,  # Form only.
> orderby=db.opt.name,
> paginate=session.auth.user.pagination,
> # represent_none='',  # Grid and view form only.
> )
>
> will sort by opt_cat_id and not by the opt_cat.name that is shown.
> The only solution I've found is to make a join between the 2 columns and 
> show the client.name directly.
>
> query = db.opt.opt_cat_id == db.opt_cat.id
>
> grid = SQLFORM.grid(
> query,
> csv=False,
> details=False,
> field_id=db.opt.id,
> fields=[
> db.opt.name,
> db.opt_cat.name,
> db.opt_cat.name_en,
> ],
> headers={'opt_cat.name': T('Category'), 'opt_cat.name_en': T(
> 'Category')},
> maxtextlength=GRID_COL_LEN_FOR_TEXT,
> ondelete=on_delete,  # Grid only.
> onvalidation=on_validation,  # Form only.
> orderby=db.opt.name,
> paginate=session.auth.user.pagination,
> # represent_none='',  # Grid and view form only.
> )
>
>
> Is there a better solution?
>
> Another question is that I see that the sorting is ASCII based (small case 
> after upper case).
>
> Is there any way to make it sort without being case sensitive?
>
> One last question. Is there any way to sort the fields names in the search 
> fields list of a grid?
>
>
> Thanks,
>
> JM
>

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


[web2py] Re: Is it possible to disable grid sorting for some columns only?

2019-03-29 Thread João Matos
Found a kludge.

# Remove sorting from specific columns.
grid.elements('a', replace=remove_sorting)

which uses this function

def remove_sorting(html: gluon.HTML) -> Union[str, gluon.HTML]:
"""Remove HTML tag if it contains specific words.

:param html: HTML.
:return: Original HTML or text inside HTML tags w/specific words.
"""
text = str(html)
if ('power_supply' in text or 'automation' in text or 'doors' in text
or 'sg_model_power' in text):
return text.split('>')[1].split('<')[0]
return html


Is there a better way?


sexta-feira, 29 de Março de 2019 às 11:31:08 UTC, João Matos escreveu:
>
> Is it possible to disable grid sorting for some columns only?
>

-- 
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 add a read-only field to a SQLFORM.factory

2019-03-29 Thread João Matos
Found a solution (more like a kludge) :)

form.element('#no_table_sn').attributes['_readonly'] = 'readonly'

I even tried adding 

_readonly='readonly'

to the Field, but didn't work.

Only works after the form exists.

Is there a better way?


sexta-feira, 29 de Março de 2019 às 21:25:48 UTC, João Matos escreveu:
>
> The field I want to make read-only is sn.
>
> form = SQLFORM.factory(
> Field('equipment_id',
>   label=T('Equipment'),
>   requires=IS_IN_DB(db, 'equipment.id', '%(name)s', zero=None
> ),
> ),
> Field('sn', 'integer', label=T('SN'), writable=False),
> Field('code', label=T('WO'), requires=IS_EMPTY_OR(
> IS_IN_DB(db(query), 'wo.code', distinct=True))),
> Field('client_id',
>   label=T('Client'),
>   requires=IS_IN_DB(db, 'client.id', '%(name)s', zero=T('Choose 
> one...')),
> ),
> Field('manual_lang_id',
>   label=T('Manual language'),
>   requires=IS_IN_DB(db,
> 'manual_lang.id',
> '%(name)s',
> zero=T('Choose one...'),
>   ),
> ),
> Field('co_code', 'string', default='', label=T('Customer order')),
> Field('so_code', 'string', default='', label=T('Supplier order')),
> Field('export', 'boolean', default=False, label=T('Export')),
> Field('notes', 'string', default='', label=T('Notes')),
> Field('observations', 'string', default='', label=T('Observations'
> )),
> Field('est_finish', 'date', label=T('Estimated finish'), notnull=
> True,
>   required=True,
>   requires=IS_DATE_IN_RANGE(  # format=T('%Y-%m-%d'),
> minimum=request.now.date() + 
> timedelta(days=1),
> # maximum=request.now.date() + ,
> error_message=T('Must be a future 
> date.')
>   )
> ),
> *factory_fields,
> hidden={'mon': wo.modified_on},
> )
>
>
>
> sexta-feira, 29 de Março de 2019 às 21:20:27 UTC, Jim S escreveu:
>>
>> Can you show some code?  Mine is working fine without a db and specifying 
>> writable=False.
>>
>> -Jim
>>
>> On Fri, Mar 29, 2019 at 4:02 PM João Matos  wrote:
>>
>>> It is readable and editable.
>>>
>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> --- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/U7zQi02p2MY/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> web...@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: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread João Matos
The field I want to make read-only is sn.

form = SQLFORM.factory(
Field('equipment_id',
  label=T('Equipment'),
  requires=IS_IN_DB(db, 'equipment.id', '%(name)s', zero=None),
),
Field('sn', 'integer', label=T('SN'), writable=False),
Field('code', label=T('WO'), requires=IS_EMPTY_OR(
IS_IN_DB(db(query), 'wo.code', distinct=True))),
Field('client_id',
  label=T('Client'),
  requires=IS_IN_DB(db, 'client.id', '%(name)s', zero=T('Choose 
one...')),
),
Field('manual_lang_id',
  label=T('Manual language'),
  requires=IS_IN_DB(db,
'manual_lang.id',
'%(name)s',
zero=T('Choose one...'),
  ),
),
Field('co_code', 'string', default='', label=T('Customer order')),
Field('so_code', 'string', default='', label=T('Supplier order')),
Field('export', 'boolean', default=False, label=T('Export')),
Field('notes', 'string', default='', label=T('Notes')),
Field('observations', 'string', default='', label=T('Observations'
)),
Field('est_finish', 'date', label=T('Estimated finish'), notnull=
True,
  required=True,
  requires=IS_DATE_IN_RANGE(  # format=T('%Y-%m-%d'),
minimum=request.now.date() + 
timedelta(days=1),
# maximum=request.now.date() + ,
error_message=T('Must be a future 
date.')
  )
),
*factory_fields,
hidden={'mon': wo.modified_on},
)



sexta-feira, 29 de Março de 2019 às 21:20:27 UTC, Jim S escreveu:
>
> Can you show some code?  Mine is working fine without a db and specifying 
> writable=False.
>
> -Jim
>
> On Fri, Mar 29, 2019 at 4:02 PM João Matos  > wrote:
>
>> It is readable and editable.
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/U7zQi02p2MY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@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: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread Jim Steil
Can you show some code?  Mine is working fine without a db and specifying
writable=False.

-Jim

On Fri, Mar 29, 2019 at 4:02 PM João Matos  wrote:

> It is readable and editable.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/U7zQi02p2MY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread João Matos
This is a SQLFORM.factory not a SQLFORM.
There is no database.
Are you sure fields parameter is applicable to SQLFORM.factory w/o a db?


sexta-feira, 29 de Março de 2019 às 20:51:10 UTC, Anthony escreveu:
>
> By default, non-writable fields are excluded from create forms (though 
> shown in edit forms if readable=True). However, you can override that 
> behavior by specifying the "fields" argument with a list of field names to 
> include in the form.
>
> Anthony
>
> On Friday, March 29, 2019 at 4:32:27 PM UTC-4, João Matos wrote:
>>
>> Tried that, doesn't work.
>> With writable=False the field isn't shown.
>>
>>
>> sexta-feira, 29 de Março de 2019 às 20:12:45 UTC, Jim S escreveu:
>>>
>>> Set writable=False
>>>
>>> Field('end', 'date', requires=IS_DATE('%m/%d/%Y'), default=default_end, 
>>> writable=False)
>>>
>>> -Jim
>>>
>>> On Friday, March 29, 2019 at 2:39:58 PM UTC-5, João Matos wrote:

 Hello,

 How can I add a read-only field to a SQLFORM.factory?

 Thanks,

 JM



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


Re: [web2py] Re: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread João Matos
It is readable and editable.

-- 
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: placeholder for update record field names

2019-03-29 Thread Anthony
You can create a dictionary of field names and values and then do:

workrecord.update_record(**dict_of_new_values)

Anthony

On Friday, March 29, 2019 at 4:49:28 PM UTC-4, Steve wrote:
>
> Hi All,
>
> When updating a record i would like to make some column names variable.
> I have the next statement : workrecord.update_record(starttime=iid.start, 
> t1=worktime, c1=amount)
>
> I would like to make the field t1 variable so that ik can replace the 1 
> with another number.!
> Any a suggestion if this is possible and if so how.
>
> The %s or %d does not work on fieldnames
>
> Steve
>

-- 
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 add a read-only field to a SQLFORM.factory

2019-03-29 Thread Anthony
By default, non-writable fields are excluded from create forms (though 
shown in edit forms if readable=True). However, you can override that 
behavior by specifying the "fields" argument with a list of field names to 
include in the form.

Anthony

On Friday, March 29, 2019 at 4:32:27 PM UTC-4, João Matos wrote:
>
> Tried that, doesn't work.
> With writable=False the field isn't shown.
>
>
> sexta-feira, 29 de Março de 2019 às 20:12:45 UTC, Jim S escreveu:
>>
>> Set writable=False
>>
>> Field('end', 'date', requires=IS_DATE('%m/%d/%Y'), default=default_end, 
>> writable=False)
>>
>> -Jim
>>
>> On Friday, March 29, 2019 at 2:39:58 PM UTC-5, João Matos wrote:
>>>
>>> Hello,
>>>
>>> How can I add a read-only field to a SQLFORM.factory?
>>>
>>> Thanks,
>>>
>>> JM
>>>
>>>

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


[web2py] placeholder for update record field names

2019-03-29 Thread Steve
Hi All,

When updating a record i would like to make some column names variable.
I have the next statement : workrecord.update_record(starttime=iid.start, 
t1=worktime, c1=amount)

I would like to make the field t1 variable so that ik can replace the 1 
with another number.!
Any a suggestion if this is possible and if so how.

The %s or %d does not work on fieldnames

Steve

-- 
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 add a read-only field to a SQLFORM.factory

2019-03-29 Thread Jim Steil
Is readable set to True?

-Jim

On Fri, Mar 29, 2019 at 3:32 PM João Matos  wrote:

> Tried that, doesn't work.
> With writable=False the field isn't shown.
>
>
> sexta-feira, 29 de Março de 2019 às 20:12:45 UTC, Jim S escreveu:
>>
>> Set writable=False
>>
>> Field('end', 'date', requires=IS_DATE('%m/%d/%Y'), default=default_end,
>> writable=False)
>>
>> -Jim
>>
>> On Friday, March 29, 2019 at 2:39:58 PM UTC-5, João Matos wrote:
>>>
>>> Hello,
>>>
>>> How can I add a read-only field to a SQLFORM.factory?
>>>
>>> Thanks,
>>>
>>> JM
>>>
>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/U7zQi02p2MY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread João Matos
Tried that, doesn't work.
With writable=False the field isn't shown.


sexta-feira, 29 de Março de 2019 às 20:12:45 UTC, Jim S escreveu:
>
> Set writable=False
>
> Field('end', 'date', requires=IS_DATE('%m/%d/%Y'), default=default_end, 
> writable=False)
>
> -Jim
>
> On Friday, March 29, 2019 at 2:39:58 PM UTC-5, João Matos wrote:
>>
>> Hello,
>>
>> How can I add a read-only field to a SQLFORM.factory?
>>
>> Thanks,
>>
>> JM
>>
>>

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


[web2py] Re: How to add a read-only field to a SQLFORM.factory

2019-03-29 Thread Jim S
Set writable=False

Field('end', 'date', requires=IS_DATE('%m/%d/%Y'), default=default_end, 
writable=False)

-Jim

On Friday, March 29, 2019 at 2:39:58 PM UTC-5, João Matos wrote:
>
> Hello,
>
> How can I add a read-only field to a SQLFORM.factory?
>
> Thanks,
>
> JM
>
>

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


[web2py] How to add a read-only field to a SQLFORM.factory

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

How can I add a read-only field to a SQLFORM.factory?

Thanks,

JM

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


Re: [web2py] Re: Not my type

2019-03-29 Thread notyour mitch
Hi Joe,

Thanks so much for responding. Let me be more specific. I was referring to a
section in the book, chapter two, on types
.
In there it suggests

>>> a = 3>>> print type(a)
>
> But that didn't work for me, I got error messages (don't recall what they
were at this moment).
However, when I tried it using two other methods...
1.

> >>> a = 3

>>> type(a)

or
2.

> >>> a = 3

>>> print(type(a))


Both of those worked for me. Kind of weird because when I checked which
version of python I had running  it said 2.7 but perhaps I installed w2p
with python3.

Anyway, at the end I was suggesting that maybe we could update the book
some making reference to how things might look with python3. I wasn't sure
if that sort of thing is just done here, by mentioning it in the forum and
someone will get to it, or if it might be done by pull request.

Best,

Al

On Thu, Mar 28, 2019 at 9:30 PM Joe Barnhart  wrote:

> Hi Al --
>
> First off, welcome to the web2py group.  Next, it's not clear from your
> message just what the question is.  If you can elaborate on (a) what you
> did, (b) what you expected, and (c) what you got, I'm sure someone here can
> help
>
> Warm regards,
>
> Joe B.
>
> On Thursday, March 28, 2019 at 2:10:50 AM UTC-7, Al Hart wrote:
>>
>> Hi folks, if you'll pardon the corny title, I am brand new to web2py (so
>> excited to discover it) and I'm just working may way through the book. In
>> Chapter two, the section on types, I tried to run the examples, but I got
>> error messages. Googling around it seemed to work better if I went one of
>> two ways:
>>
>>
>>1. a = 3
>>type(a)
>>2. a = 4
>>print(type(a))
>>
>>
>> I'm on Ubuntu 18.04. Not sure if the example is based on python 3? If
>> not, is this the best way to suggest updates to the book or should we just
>> try a pull request?
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/VityJ20AV2M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] change favicon for one page

2019-03-29 Thread Dave S
I want to use a different favicon for one page of an application.  How do I 
override this?  What I've tried (without success) is

- put  in the view (default/index.html) before the 
"extend 'layout.html'"
(the line shows in the page source, but is before the link lines from 
layout.html, and is over-ridden)

- put head> in the view (default/index.html) after the 
"extend 'layout.html'"
(line does not show up)

- in the controller, use response.headers["link"]="... "
(line does not show up)

It's easy enough to change the whole app, but I want to have the one page 
not be the same as the rest of the app's pages.

Thanks.

/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] Is it possible to disable grid sorting for some columns only?

2019-03-29 Thread João Matos
Is it possible to disable grid sorting for some columns only?

-- 
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: Clear a form after submit

2019-03-29 Thread Dave S


On Wednesday, February 6, 2019 at 1:31:49 PM UTC-8, Dave S wrote:
>
>
>
> On Wednesday, February 6, 2019 at 4:49:43 AM UTC-8, Ben Duncan wrote:
>>
>> Ok, I found the answer. It's by putting in the entry ' autocomplete="off" 
>> ' in the > does not allow previous values to be accessed. This is the behavior I was 
>> looking for.
>>
>>
> Ah, interesting.  I have a field where the browser's suggestions are more 
> distracting than helpful.   Some exploration will follow.
>

I finally got around to trying this out, and it looks like with SQLFORM(), 
what I want is

Field('Mint', 'string', requires=IS_MATCH('^[dpx]*$', error_message="not a 
valid mint string"),
 widget = lambda f, v: SQLFORM.widgets.string.widget(f, 
v, _autocomplete="off")),

 Previous advice had told me about the widget stuff for autofocus,(=True) 
and it looks like it works for autocomplete.

Thanks!

(Off topic annoyance:   appadmin's "DB new record"  form doesn't use 
autofocus, and I feel it *should* take you to the first field.)

/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: web3py again....

2019-03-29 Thread José Luis Redrejo
El vie., 29 mar. 2019 a las 5:12, Massimo Di Pierro (<
massimo.dipie...@gmail.com>) escribió:

> My thought exactly.
>
>
I also fully agree.
Very excited with the new features.

Also, I see the problems I reported yesterday have been solved in the git
repository. Now we can begin to really play with it.
José L.




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

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