[web2py] Re: save the original value of one field in another table field
This is generally not good database design. What are you really trying to do? Would it make more sense for mytable2 to reference mytable? Anthony On Tuesday, June 19, 2018 at 9:09:42 PM UTC-4, Ayron Rangel wrote: > > How can i save the value of one field in another table field?? > > db.define_table('mytable', > Field('n1', 'integer', requires=IS_NOT_EMPTY()) > ) > > db.define_table('mytable2', > Field('n1', 'integer', requires=IS_NOT_EMPTY()) -> I want this field > iguals the field (n1) on mytable. > ) > -- 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: save the original value of one field in another table field
perhaps you can use database callbacks or form validation *ref:* http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update http://web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation 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] redis in 2.16.1
it seems session with redis not work in 2.16.1 *e.g. create web2py from scratch name redis* *models/db.py* from gluon.contrib.redis_utils import RConn from gluon.contrib.redis_cache import RedisCache from gluon.contrib.redis_session import RedisSession rconn = RConn('localhost', 6379) cache.redis = RedisCache(redis_conn = rconn, debug = True) sessiondb = RedisSession(redis_conn = rconn, session_expiry = False) session.connect(request, response, db = sessiondb) *result in browser http://localhost:8000/redis/default/index* Traceback (most recent call last): File "/Users/sugizo/web2py/gluon/main.py", line 461, in wsgibase session._try_store_in_db(request, response) File "/Users/sugizo/web2py/gluon/globals.py", line 1224, in _try_store_in_db record_id = table.insert(**dd) File "/Users/sugizo/web2py/gluon/contrib/redis_session.py", line 137, in insert newid = str(self.db.r_server.incr(self.serial)) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py" , line 1011, in incr return self.execute_command('INCRBY', name, amount) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py" , line 667, in execute_command connection.send_command(*args) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 610, in send_command self.send_packed_command(self.pack_command(*args)) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 585, in send_packed_command self.connect() File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 493, in connect self.on_connect() File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 567, in on_connect if nativestr(self.read_response()) != 'OK': File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 629, in read_response raise response ResponseError: invalid DB index also, is it possible to use redis secured with password in web2py? *e.g.* *redis.conf* requirepass password *models/db.py* rconn = RConn('localhost', 6379, 'password') #sessiondb = RedisSession(redis_conn = rconn, session_expiry = False) #session.connect(request, response, db = sessiondb) *result in browser http://localhost:8000/redis/default/index* Traceback (most recent call last): File "/Users/sugizo/web2py/gluon/main.py", line 461, in wsgibase session._try_store_in_db(request, response) File "/Users/sugizo/web2py/gluon/globals.py", line 1224, in _try_store_in_db record_id = table.insert(**dd) File "/Users/sugizo/web2py/gluon/contrib/redis_session.py", line 137, in insert newid = str(self.db.r_server.incr(self.serial)) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py" , line 1011, in incr return self.execute_command('INCRBY', name, amount) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py" , line 667, in execute_command connection.send_command(*args) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 610, in send_command self.send_packed_command(self.pack_command(*args)) File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 585, in send_packed_command self.connect() File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 493, in connect self.on_connect() File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 567, in on_connect if nativestr(self.read_response()) != 'OK': File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py" , line 629, in read_response raise response ResponseError: NOAUTH Authentication required. any hints? thx 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] save the original value of one field in another table field
How can i save the value of one field in another table field?? db.define_table('mytable', Field('n1', 'integer', requires=IS_NOT_EMPTY()) ) db.define_table('mytable2', Field('n1', 'integer', requires=IS_NOT_EMPTY()) -> I want this field iguals the field (n1) on mytable. ) -- 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: managing latin characters
On Tuesday, June 19, 2018 at 3:00:03 PM UTC-4, Andrea Fae' wrote: > > Thank you Leonel, but when I try to insert to db for example this name > "Donà" in the username field (table auth_user) the system tells me that is > not possible...So, what to do? Convert "Donà" in "Dona" without accent? > Which characters can I use in the username field? In the book there is only > db_codec=latin...where can I find documentation about encoding in > python documentation? thank you > The default validators for the username field are: [IS_MATCH('[\w\.\-]+', strict=True, error_message=self.messages.invalid_username), IS_NOT_IN_DB(db, '%s.username' % settings.table_user_name, error_message=self.messages.username_taken)] You could replace the IS_MATCH with a custom validator that accepts unicode characters, or just remove IS_MATCH altogether. 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: field username in auth_user
By default it must match the following regular expression: '[\w\.\-]+' So, no spaces. I suppose you could override the default validator and allow spaces, but I'm not sure if that has any consequences for uses of the username elsewhere in the Auth system. Anthony On Tuesday, June 19, 2018 at 3:20:59 PM UTC-4, Andrea Fae' wrote: > > What kind of characters can we use in this field? > Can I use space character in this field? I think no. > thank you > -- 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: field username in auth_user
On Tuesday, June 19, 2018 at 12:20:59 PM UTC-7, Andrea Fae' wrote: > > What kind of characters can we use in this field? > Can I use space character in this field? I think no. > thank you > You might try a "non-breaking space". In unicode, that U+00A0 http://www.fileformat.info/info/unicode/char/00a0/index.htm> /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: managing latin characters
On Tuesday, June 19, 2018 at 12:00:03 PM UTC-7, Andrea Fae' wrote: > > Thank you Leonel, but when I try to insert to db for example this name > "Donà" in the username field (table auth_user) the system tells me that is > not possible...So, what to do? Convert "Donà" in "Dona" without accent? > Which characters can I use in the username field? In the book there is only > db_codec=latin...where can I find documentation about encoding in > python documentation? thank you > > Il giorno lunedì 18 giugno 2018 23:50:05 UTC+2, Leonel Câmara ha scritto: >> >> Web2py uses utf-8 everywhere by default, you don't need to worry about >> it. If you're smart you will use utf-8 in the database too and everything >> pretty much just works, otherwise you will just have to tell the DAL about >> the encoding the database uses using db_codec. >> > You probably want to look at chapter 7.8 of the Python Standard Library docs: https://docs.python.org/2.7/library/codecs.html> especially section 7.8.2. Also, chapter 7.9 describes the tools for getting unicode properties, and you can find the numeric value for a given character that way. I would expect the DAL connectors to handle most of the common encodings, and Leonel points out they can talk UTF-8 to a database that supports it (find me an example that doesn't). In the book, the DAL signature shows UTF-8 as the default codec. http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=unicode#DAL-signature> If you really need to be ASCII-safe: Since URLs are supposed to be ASCII, unicode gets escaped ... look at chapter 20.5.2 for urllib.quote(): https://docs.python.org/2.7/library/urllib.html#utility-functions> or the web2py helper function xmlescape() http://web2py.com/books/default/chapter/29/05/the-views#xmlescape> to provide a "clean ascii" representation if you need to. I know, TL;DR. But I hope this gives you some pointers to your choices. Dave S /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] field username in auth_user
What kind of characters can we use in this field? Can I use space character in this field? I think no. thank you -- 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: managing latin characters
Thank you Leonel, but when I try to insert to db for example this name "Donà" in the username field (table auth_user) the system tells me that is not possible...So, what to do? Convert "Donà" in "Dona" without accent? Which characters can I use in the username field? In the book there is only db_codec=latin...where can I find documentation about encoding in python documentation? thank you Il giorno lunedì 18 giugno 2018 23:50:05 UTC+2, Leonel Câmara ha scritto: > > Web2py uses utf-8 everywhere by default, you don't need to worry about it. > If you're smart you will use utf-8 in the database too and everything > pretty much just works, otherwise you will just have to tell the DAL about > the encoding the database uses using db_codec. > -- 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: Salesforce access code works standalone but fails from within web2py app
Solved... Ultimately an out-of-date simple_salesforce, but complicated by the fact that my pip v9.0.1 attempt to upgrade simple_salesforce (and even pip itself) also failed with a TLSV1 failure. Stumbled upon this link - which had an answer that worked for me to get out of this apparent infinite loop :-( https://brianchan.us/2018/04/17/pip-install-error-ssl-tlsv1_alert_protocol_version/ Might be for use to others On Tuesday, June 19, 2018 at 9:06:29 AM UTC-7, jim kaubisch wrote: > > HI, > > > One of the apps I’m writing involves interaction with Salesforce. > > > I’ve written a context manager to implement access to our Salesforce > account (using “simple_salesforce” as the access mechanism). > > > When run as a standalone program access and data retrieval work fine, but > imported into my web2py app and called from there, it fails with > > >Failed to open SF connection. > > >Msg= HTTPSConnectionPool(host='login.salesforce.com', port=443): > > Max retries exceeded with url: /services/Soap/u/29.0 (Caused by > SSLError(SSLError(1, > > u'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake > failure (_ssl.c:661)'),)) > > > There’s no particular reason why anyone would know what the problem might > be, but I’m asking just in case :-( > > > 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: Clarification please on autocomplete widget...
It sounds like you want the reference field version of autocomplete. What is your exact model code and the widget code you tried? Anthony On Tuesday, June 19, 2018 at 11:24:07 AM UTC-4, jim kaubisch wrote: > > Thanks, Anthony. > > because there may be MANY values in the field, what I would actually be > perfectly happy with is a list as you describe it, > but one that is the result of a db query, > > e.g. a list of names of all schools whose "Field('district_id' , > 'reference districts', label=T('District')" is 2. > > Tried doing that yesterday without success. > > > On Tuesday, June 19, 2018 at 4:05:08 AM UTC-7, Anthony wrote: >> >> No, as the example in the book shows, by "list", it just means a list >> generated from the contents of a single field in a database table (in >> contrast to the reference field option, which submits integer ID values >> from a reference field but searches and displays the corresponding values >> from an alternative field). >> >> There are other autocomplete widgets you can use, but if you really want >> to use the web2py widget, I suppose you could just put your list in a >> database table. >> >> Anthony >> >> On Monday, June 18, 2018 at 11:59:27 PM UTC-4, jim kaubisch wrote: >>> >>> What am I misunderstanding... ?? >>> >>> Building a form with fields that really need to be autocompleted >>> (potentially 1,000+ possible values). >>> >>> Looked at the book which says "two possible uses for the autocomplete >>> widget: to autocomplete a field that takes a value from a *list* or to >>> autocomplete a *reference field*" >>> I assumed that "list" meant an ordinary Python list object, but when I >>> try: >>> >>> fields = [] >>> ... >>> >>> name_list = ['name1', 'name2'] >>> fields.append(Field('school', 'string' , label=T('School Name?') >>> , >>> widget=SQLFORM.widgets.autocomplete(request , name_list, limitby=(0,10), >>> min_length=0) >>> , requires=IS_NOT_EMPTY())) >>>... >>> >>> enter_data_form=SQLFORM.factory(*fields, table_name='enter_data') >>> >>> I get the following: >>> 'list' object has no >>> attribute 'tablename' >>> >>> which I interpret to mean that 'list' in this case means something >>> different than I expected. >>> >>> What am I doing wrong? >>> >>> 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] Required field label
Hi, what is the best way to add red * (or any indication that the field is required for user) in the label of the required field? 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] Salesforce access code works standalone but fails from within web2py app
HI, One of the apps I’m writing involves interaction with Salesforce. I’ve written a context manager to implement access to our Salesforce account (using “simple_salesforce” as the access mechanism). When run as a standalone program access and data retrieval work fine, but imported into my web2py app and called from there, it fails with Failed to open SF connection. Msg= HTTPSConnectionPool(host='login.salesforce.com', port=443): Max retries exceeded with url: /services/Soap/u/29.0 (Caused by SSLError(SSLError(1, u'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:661)'),)) There’s no particular reason why anyone would know what the problem might be, but I’m asking just in case :-( 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: Clarification please on autocomplete widget...
Thanks, Anthony. because there may be MANY values in the field, what I would actually be perfectly happy with is a list as you describe it, but one that is the result of a db query, e.g. a list of names of all schools whose "Field('district_id' , 'reference districts', label=T('District')" is 2. Tried doing that yesterday without success. On Tuesday, June 19, 2018 at 4:05:08 AM UTC-7, Anthony wrote: > > No, as the example in the book shows, by "list", it just means a list > generated from the contents of a single field in a database table (in > contrast to the reference field option, which submits integer ID values > from a reference field but searches and displays the corresponding values > from an alternative field). > > There are other autocomplete widgets you can use, but if you really want > to use the web2py widget, I suppose you could just put your list in a > database table. > > Anthony > > On Monday, June 18, 2018 at 11:59:27 PM UTC-4, jim kaubisch wrote: >> >> What am I misunderstanding... ?? >> >> Building a form with fields that really need to be autocompleted >> (potentially 1,000+ possible values). >> >> Looked at the book which says "two possible uses for the autocomplete >> widget: to autocomplete a field that takes a value from a *list* or to >> autocomplete a *reference field*" >> I assumed that "list" meant an ordinary Python list object, but when I >> try: >> >> fields = [] >> ... >> >> name_list = ['name1', 'name2'] >> fields.append(Field('school', 'string' , label=T('School Name?') >> , >> widget=SQLFORM.widgets.autocomplete(request , name_list, limitby=(0,10), >> min_length=0) >> , requires=IS_NOT_EMPTY())) >>... >> >> enter_data_form=SQLFORM.factory(*fields, table_name='enter_data') >> >> I get the following: >> 'list' object has no >> attribute 'tablename' >> >> which I interpret to mean that 'list' in this case means something >> different than I expected. >> >> What am I doing wrong? >> >> 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: Clarification please on autocomplete widget...
No, as the example in the book shows, by "list", it just means a list generated from the contents of a single field in a database table (in contrast to the reference field option, which submits integer ID values from a reference field but searches and displays the corresponding values from an alternative field). Anthony On Monday, June 18, 2018 at 11:59:27 PM UTC-4, jim kaubisch wrote: > > What am I misunderstanding... ?? > > Building a form with fields that really need to be autocompleted > (potentially 1,000+ possible values). > > Looked at the book which says "two possible uses for the autocomplete > widget: to autocomplete a field that takes a value from a *list* or to > autocomplete a *reference field*" > I assumed that "list" meant an ordinary Python list object, but when I try: > > fields = [] > ... > > name_list = ['name1', 'name2'] > fields.append(Field('school', 'string' , label=T('School Name?') > , > widget=SQLFORM.widgets.autocomplete(request , name_list, limitby=(0,10), > min_length=0) > , requires=IS_NOT_EMPTY())) >... > > enter_data_form=SQLFORM.factory(*fields, table_name='enter_data') > > I get the following: > 'list' object has no attribute > 'tablename' > > which I interpret to mean that 'list' in this case means something > different than I expected. > > What am I doing wrong? > > 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.