[web2py] Re: How to debug appadmin CSV uploading

2020-05-01 Thread Andrew Rogers
Can't help you Jon sorry. I tried to upload a while back but got a 
different issue (see 
https://groups.google.com/forum/#!topic/web2py/03-7xKAioD8)  So maybe that 
feature has fallen into disuse?


On Friday, 1 May 2020 16:57:38 UTC+10, Jonsubs wrote:
>
> Hi everyone,
> I'm trying to upload a CSV file to my MySQL database using appadmin.
>
> I do get a "data uploaded" flash message as if I succeeded, but data is 
> not there.
>
> Could anyone suggest me how to debug this operation?
> Thanks, Jon.
>
>
> 
>  Libre 
> de virus. www.avast.com 
> 
>  
> <#CAK8tz31FLL14iggF+geUS_piGUFSmjKQV7ie34f=7OeQBFRh3Q@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f7f07401-d033-4a7e-9273-79e3698050b2%40googlegroups.com.


[web2py] Re: SQLFORM with extra_fields

2020-05-01 Thread Jim S
S, I'm wondering if this is a bug in web2py.  In the traceback above 
you can see the error is on line 1505 in sqlhtml.py.  In looking at the 
code, it appears as though it is just setting the default value for each 
field based on the record that was retrieved.

Here is that block of code:
if record:
default = record[fieldname]
else:
default = field.default
if isinstance(default, CALLABLETYPES):
default = default()

With extra_fields we don't want to set the default from the database 
because these fields don't exist in the database.  We want to set it based 
upon the field definition.  So, to me, the right fix is:

if record and fieldname not in [x.name for x in extra_fields]:
default = record[fieldname]
else:
default = field.default
if isinstance(default, CALLABLETYPES):
default = default()

With this change to the if statement it only sets the default from the 
retrieved record if the field is not in extra_fields.

I've tested with my app and it works well.

I'll try submitting a PR to get it added to the codebase.

-Jim




On Friday, May 1, 2020 at 1:38:55 PM UTC-5, Jim S wrote:
>
> Clemens
>
> Thanks for this.
>
> Have you ever used extra_fields in SQLFORM?
>
> I'm wondering what it is for if it doesn't work the way I'm using it.
>
> -Jim
>
>
> On Friday, May 1, 2020 at 1:16:36 PM UTC-5, Clemens wrote:
>>
>> Hi Jim,
>>
>> I've solved it as follows (for an additional field to select the 
>> corresponding business unit, here stored in a dictionary):
>>
>> biz_unit = TR(TD(LABEL(T('Responsible'), XML(''))), \
>> TD(SELECT(_name='biz_unit', value='', *[OPTION(biz_unit_title, 
>> _value=biz_unit_dict[biz_unit_title]) \
>> for biz_unit_title in sorted(biz_unit_dict)])))
>> form[0].insert(-1, biz_unit)
>>
>> Hope it helps!
>>
>> Best regards
>> Clemens
>>
>>
>> On Friday, May 1, 2020 at 5:53:36 PM UTC+2, Jim S wrote:
>>>
>>> Anyone have experience with using 'extra_fields' in a SQLFORM?
>>>
>>> Here is my code:
>>>
>>>
>>> def edit_demo():
>>> response.view = 'producer/edit/edit_demo.load'
>>>
>>> producer_id = request.get_vars.producer_id
>>>
>>> producer = db(db.producer.id == producer_id).select().first()
>>>
>>> form = None
>>> if producer:
>>> fields = ['name', 'address', 'city',
>>>   'state', 'zip_code', 'primary_contact',
>>>   'primary_phone', 'primary_email', 'secondary_contact',
>>>   'secondary_phone', 'secondary_email', 'grade',
>>>   'district']
>>>
>>> extra_fields = []
>>> for pt in db(db.producer_type.id > 0).select(orderby=db.
>>> producer_type.name):
>>> if db((db.producer_producer_type.producer_type == pt.id) &
>>>   (db.producer_producer_type.producer == producer.id)).
>>> select().first():
>>> has_producer_type = True
>>> else:
>>> has_producer_type = False
>>> extra_fields.append(Field(fieldname='pt%s' % pt.id,
>>>   type='boolean',
>>>   default=has_producer_type,
>>>   label=pt.name))
>>>
>>> form = SQLFORM(db.producer, record=producer_id, fields=fields,
>>>showid=False, extra_fields=extra_fields,
>>>table_name='edit_demographics', formname=
>>> 'edit_demographics_form')
>>>
>>> if form.process().accepted:
>>>
>>> response.flash = None
>>>
>>> url = URL('index', args=['edit', 'producer', producer_id], 
>>> user_signature=True, extension=False)
>>> url += '=demographics_jump'
>>> redirect(url, client_side=True)
>>>
>>> return dict(form=form, is_owner=is_owner, is_admin=is_admin)
>>>
>>> And it is giving me this error:
>>>
>>> Traceback (most recent call last):
>>>  File "/home/jim/dev/web2py/gluon/restricted.py", line 219, in restricted
>>>  exec(ccode, environment)
>>>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
>>> , 
>>> line 1621, in 
>>>  File "/home/jim/dev/web2py/gluon/globals.py", line 422, in 
>>>  self._caller = lambda f: f()
>>>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
>>> , 
>>> line 1609, in edit_demo
>>>  table_name='edit_demographics', formname='edit_demographics_form')
>>>  File "/home/jim/dev/web2py/gluon/sqlhtml.py", line 1505, in __init__
>>>  default = record[fieldname]
>>>  File "/home/jim/dev/web2py/gluon/packages/dal/pydal/objects.py", line 145, 
>>> in __getitem__
>>>  raise KeyError(key)
>>> KeyError: 'pt3'
>>>
>>> I'm not understanding how to define extra_fields in this context.  In the 
>>> end, the form is supposed to look like the attached.  I'm trying to add the 
>>> checkboxes at the bottom 

[web2py] Re: SQLFORM with extra_fields

2020-05-01 Thread Jim S
Clemens

Thanks for this.

Have you ever used extra_fields in SQLFORM?

I'm wondering what it is for if it doesn't work the way I'm using it.

-Jim


On Friday, May 1, 2020 at 1:16:36 PM UTC-5, Clemens wrote:
>
> Hi Jim,
>
> I've solved it as follows (for an additional field to select the 
> corresponding business unit, here stored in a dictionary):
>
> biz_unit = TR(TD(LABEL(T('Responsible'), XML(''))), \
> TD(SELECT(_name='biz_unit', value='', *[OPTION(biz_unit_title, 
> _value=biz_unit_dict[biz_unit_title]) \
> for biz_unit_title in sorted(biz_unit_dict)])))
> form[0].insert(-1, biz_unit)
>
> Hope it helps!
>
> Best regards
> Clemens
>
>
> On Friday, May 1, 2020 at 5:53:36 PM UTC+2, Jim S wrote:
>>
>> Anyone have experience with using 'extra_fields' in a SQLFORM?
>>
>> Here is my code:
>>
>>
>> def edit_demo():
>> response.view = 'producer/edit/edit_demo.load'
>>
>> producer_id = request.get_vars.producer_id
>>
>> producer = db(db.producer.id == producer_id).select().first()
>>
>> form = None
>> if producer:
>> fields = ['name', 'address', 'city',
>>   'state', 'zip_code', 'primary_contact',
>>   'primary_phone', 'primary_email', 'secondary_contact',
>>   'secondary_phone', 'secondary_email', 'grade',
>>   'district']
>>
>> extra_fields = []
>> for pt in db(db.producer_type.id > 0).select(orderby=db.
>> producer_type.name):
>> if db((db.producer_producer_type.producer_type == pt.id) &
>>   (db.producer_producer_type.producer == producer.id)).
>> select().first():
>> has_producer_type = True
>> else:
>> has_producer_type = False
>> extra_fields.append(Field(fieldname='pt%s' % pt.id,
>>   type='boolean',
>>   default=has_producer_type,
>>   label=pt.name))
>>
>> form = SQLFORM(db.producer, record=producer_id, fields=fields,
>>showid=False, extra_fields=extra_fields,
>>table_name='edit_demographics', formname=
>> 'edit_demographics_form')
>>
>> if form.process().accepted:
>>
>> response.flash = None
>>
>> url = URL('index', args=['edit', 'producer', producer_id], 
>> user_signature=True, extension=False)
>> url += '=demographics_jump'
>> redirect(url, client_side=True)
>>
>> return dict(form=form, is_owner=is_owner, is_admin=is_admin)
>>
>> And it is giving me this error:
>>
>> Traceback (most recent call last):
>>  File "/home/jim/dev/web2py/gluon/restricted.py", line 219, in restricted
>>  exec(ccode, environment)
>>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
>> , 
>> line 1621, in 
>>  File "/home/jim/dev/web2py/gluon/globals.py", line 422, in 
>>  self._caller = lambda f: f()
>>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
>> , 
>> line 1609, in edit_demo
>>  table_name='edit_demographics', formname='edit_demographics_form')
>>  File "/home/jim/dev/web2py/gluon/sqlhtml.py", line 1505, in __init__
>>  default = record[fieldname]
>>  File "/home/jim/dev/web2py/gluon/packages/dal/pydal/objects.py", line 145, 
>> in __getitem__
>>  raise KeyError(key)
>> KeyError: 'pt3'
>>
>> I'm not understanding how to define extra_fields in this context.  In the 
>> end, the form is supposed to look like the attached.  I'm trying to add the 
>> checkboxes at the bottom of the form.  
>>
>> I have it all working with SQLFORM.factory but would prefer that I do it 
>> with the base SQLFORM.  Thoughts?
>>
>> -Jim
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/61093f3d-ba54-456c-8157-a8794b13b78e%40googlegroups.com.


Re: [web2py] Re: web2py and ubuntu 20lts

2020-05-01 Thread Maurice Waka
Noted guys
Works well.
regards

On Friday, May 1, 2020 at 4:57:11 PM UTC+3, Lovedie JC wrote:
>
> On system restart, the previous pyc files for python 2+ were deleted and 
> it works OK.
> Let me observe for now. 
> Regards 
>
> On Fri, May 1, 2020, 11:26 Lovedie JC > 
> wrote:
>
>> Let me try
>>
>> On Fri, May 1, 2020, 11:00 Clemens > > wrote:
>>
>>> Hi Maurice,
>>>
>>> obviously you're trying to execute  your pythone-2-compiled code with 
>>> python 3 (Ubuntu 20 default). Have a try recompiling it with python 3.x.
>>>
>>> Does this solve the problem?
>>>
>>> Regards
>>> Clemens
>>>
>>> On Friday, May 1, 2020 at 7:24:34 AM UTC+2, Maurice Waka wrote:

 I recently moved to ubuntu 20LTS and on login to web2py I get this 
 error:

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
  Traceback (most recent call last):
  File "/home/maurice/web2py/gluon/main.py", line 440, in wsgibase
  serve_controller(request, response, session)
  File "/home/maurice/web2py/gluon/main.py", line 174, in 
 serve_controller
  run_models_in(environment)
  File "/home/maurice/web2py/gluon/compileapp.py", line 562, in 
 run_models_in
  ccode = getcfs(model, model, f)
  File "/home/maurice/web2py/gluon/cfs.py", line 50, in getcfs
  data = filter()
  File "/home/maurice/web2py/gluon/compileapp.py", line 559, in 
  f = lambda: read_pyc(model)
  File "/home/maurice/web2py/gluon/compileapp.py", line 427, in read_pyc
  raise SystemError('compiled code is incompatible')
 SystemError: compiled code is incompatible


 -- 
>>> 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 web...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/web2py/5e0165da-cac3-4398-93b2-ebc7c3a4c120%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e0f04e10-15d5-41c6-98bd-98c4731a1501%40googlegroups.com.


Re: [web2py] Re: "TypeError: sequence of byte string values expected, value of type str found" when accessing admin

2020-05-01 Thread João Matos

Hello,

Nope. What I did was use another port with HTTPS (not 443, eg. 8000) for 
the client's application.



Best regards,

João Matos

On 01/05/2020 19:15, Ian W. Scott wrote:

Did you ever solve this problem? I'm running into the same thing.

On Monday, April 8, 2019 at 12:56:49 PM UTC-4, João Matos wrote:

When using Apache 2.4 (HTTPS using port 443) with web2py the
application works fine, but the admin interface always returns and
error "Internal Server Error".

This only happens if using port 443 (if I change the HTTPS port to
eg. 8000, it all works).

I checked that I don't have any other program/process using port 443.


The Apache error.log shows this

|[Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid
924] [client 192.168.1.119:61409 ]
mod_wsgi (pid=4448): Exception occurred processing WSGI script
'C:/web2py/wsgihandler.py'. [Mon Apr 08 00:36:13.551971 2019]
[wsgi:error] [pid 4448:tid 924] [client 192.168.1.119:61409
] TypeError: sequence of byte
string values expected, value of type str found\r |

I searched for this and found this article

https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found



Apparently this has to do with Python3.
Maybe web2py is sending str instead of bytes to Apache when
accessing the admin interface?


My env

Windows 7 Pro x64 SP1+all upd
Firefox 66.0.2 x64
Python 3.7.1 x86
web2py 2.18.4
Apache 2.4 (httpd-2.4.39-win32-VC14)
mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win32.whl


--
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/OXyGJcA_TU4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1bc6d551-020a-43b9-89fd-cfc936f5aa97%40googlegroups.com 
.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/bd9dc462-d790-e18f-4003-2a039b0e7e38%40gmail.com.


[web2py] Re: SQLFORM with extra_fields

2020-05-01 Thread Clemens
Hi Jim,

I've solved it as follows (for an additional field to select the 
corresponding business unit, here stored in a dictionary):

biz_unit = TR(TD(LABEL(T('Responsible'), XML(''))), \
TD(SELECT(_name='biz_unit', value='', *[OPTION(biz_unit_title, 
_value=biz_unit_dict[biz_unit_title]) \
for biz_unit_title in sorted(biz_unit_dict)])))
form[0].insert(-1, biz_unit)

Hope it helps!

Best regards
Clemens


On Friday, May 1, 2020 at 5:53:36 PM UTC+2, Jim S wrote:
>
> Anyone have experience with using 'extra_fields' in a SQLFORM?
>
> Here is my code:
>
>
> def edit_demo():
> response.view = 'producer/edit/edit_demo.load'
>
> producer_id = request.get_vars.producer_id
>
> producer = db(db.producer.id == producer_id).select().first()
>
> form = None
> if producer:
> fields = ['name', 'address', 'city',
>   'state', 'zip_code', 'primary_contact',
>   'primary_phone', 'primary_email', 'secondary_contact',
>   'secondary_phone', 'secondary_email', 'grade',
>   'district']
>
> extra_fields = []
> for pt in db(db.producer_type.id > 0).select(orderby=db.
> producer_type.name):
> if db((db.producer_producer_type.producer_type == pt.id) &
>   (db.producer_producer_type.producer == producer.id)).
> select().first():
> has_producer_type = True
> else:
> has_producer_type = False
> extra_fields.append(Field(fieldname='pt%s' % pt.id,
>   type='boolean',
>   default=has_producer_type,
>   label=pt.name))
>
> form = SQLFORM(db.producer, record=producer_id, fields=fields,
>showid=False, extra_fields=extra_fields,
>table_name='edit_demographics', formname=
> 'edit_demographics_form')
>
> if form.process().accepted:
>
> response.flash = None
>
> url = URL('index', args=['edit', 'producer', producer_id], 
> user_signature=True, extension=False)
> url += '=demographics_jump'
> redirect(url, client_side=True)
>
> return dict(form=form, is_owner=is_owner, is_admin=is_admin)
>
> And it is giving me this error:
>
> Traceback (most recent call last):
>  File "/home/jim/dev/web2py/gluon/restricted.py", line 219, in restricted
>  exec(ccode, environment)
>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
> , 
> line 1621, in 
>  File "/home/jim/dev/web2py/gluon/globals.py", line 422, in 
>  self._caller = lambda f: f()
>  File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
> , 
> line 1609, in edit_demo
>  table_name='edit_demographics', formname='edit_demographics_form')
>  File "/home/jim/dev/web2py/gluon/sqlhtml.py", line 1505, in __init__
>  default = record[fieldname]
>  File "/home/jim/dev/web2py/gluon/packages/dal/pydal/objects.py", line 145, 
> in __getitem__
>  raise KeyError(key)
> KeyError: 'pt3'
>
> I'm not understanding how to define extra_fields in this context.  In the 
> end, the form is supposed to look like the attached.  I'm trying to add the 
> checkboxes at the bottom of the form.  
>
> I have it all working with SQLFORM.factory but would prefer that I do it with 
> the base SQLFORM.  Thoughts?
>
> -Jim
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b1f00702-f5fc-428e-9aae-4ae797a304cb%40googlegroups.com.


[web2py] Re: "TypeError: sequence of byte string values expected, value of type str found" when accessing admin

2020-05-01 Thread Ian W. Scott
Did you ever solve this problem? I'm running into the same thing.

On Monday, April 8, 2019 at 12:56:49 PM UTC-4, João Matos wrote:
>
> When using Apache 2.4 (HTTPS using port 443) with web2py the application 
> works fine, but the admin interface always returns and error "Internal 
> Server Error".
>
> This only happens if using port 443 (if I change the HTTPS port to eg. 
> 8000, it all works).
>
> I checked that I don't have any other program/process using port 443.
>
>
> The Apache error.log shows this
>
>> [Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid 924] [client 
>> 192.168.1.119:61409] mod_wsgi (pid=4448): Exception occurred processing WSGI 
>> script 'C:/web2py/wsgihandler.py'.
>> [Mon Apr 08 00:36:13.551971 2019] [wsgi:error] [pid 4448:tid 924] [client 
>> 192.168.1.119:61409] TypeError: sequence of byte string values expected, 
>> value of type str found\r
>>
>> I searched for this and found this article
>
> https://stackoverflow.com/questions/34838443/typeerror-sequence-of-byte-string-values-expected-value-of-type-str-found
>
> Apparently this has to do with Python3.
> Maybe web2py is sending str instead of bytes to Apache when accessing the 
> admin interface?
>
>
> My env
>
> Windows 7 Pro x64 SP1+all upd
> Firefox 66.0.2 x64
> Python 3.7.1 x86
> web2py 2.18.4
> Apache 2.4 (httpd-2.4.39-win32-VC14)
> mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win32.whl
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1bc6d551-020a-43b9-89fd-cfc936f5aa97%40googlegroups.com.


[web2py] Likely causes of admin server error?

2020-05-01 Thread Ian W. Scott
What are the "likely culprits" I should be looking at when I get an 
"Internal server error" accessing admin or appadmin on a fresh web2py 
installation? Here's what I've been trying so far. 

- Apache2 config file correctly configured?
- I'm 
- accessing over https?
- admin password set?
- parameters_443.py file present in web2py folder and accessible?

I've confirmed that all of these are working properly. (The apache2 config 
is identical to one working fine on an identical server.) 

So what else could be blocking admin? What else should I be looking at?

Thanks ahead of time 


- newest web2py source, py3.7, apache 2.4 with mod_wsgi

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2a991935-9e29-4c35-ac02-bfd2af5f34b3%40googlegroups.com.


[web2py] SQLFORM with extra_fields

2020-05-01 Thread Jim S
Anyone have experience with using 'extra_fields' in a SQLFORM?

Here is my code:


def edit_demo():
response.view = 'producer/edit/edit_demo.load'

producer_id = request.get_vars.producer_id

producer = db(db.producer.id == producer_id).select().first()

form = None
if producer:
fields = ['name', 'address', 'city',
  'state', 'zip_code', 'primary_contact',
  'primary_phone', 'primary_email', 'secondary_contact',
  'secondary_phone', 'secondary_email', 'grade',
  'district']

extra_fields = []
for pt in db(db.producer_type.id > 0).select(orderby=db.
producer_type.name):
if db((db.producer_producer_type.producer_type == pt.id) &
  (db.producer_producer_type.producer == producer.id)).
select().first():
has_producer_type = True
else:
has_producer_type = False
extra_fields.append(Field(fieldname='pt%s' % pt.id,
  type='boolean',
  default=has_producer_type,
  label=pt.name))

form = SQLFORM(db.producer, record=producer_id, fields=fields,
   showid=False, extra_fields=extra_fields,
   table_name='edit_demographics', formname=
'edit_demographics_form')

if form.process().accepted:

response.flash = None

url = URL('index', args=['edit', 'producer', producer_id], 
user_signature=True, extension=False)
url += '=demographics_jump'
redirect(url, client_side=True)

return dict(form=form, is_owner=is_owner, is_admin=is_admin)

And it is giving me this error:

Traceback (most recent call last):
 File "/home/jim/dev/web2py/gluon/restricted.py", line 219, in restricted
 exec(ccode, environment)
 File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
, 
line 1621, in 
 File "/home/jim/dev/web2py/gluon/globals.py", line 422, in 
 self._caller = lambda f: f()
 File "/home/jim/dev/web2py/applications/connect/controllers/producer.py" 
, 
line 1609, in edit_demo
 table_name='edit_demographics', formname='edit_demographics_form')
 File "/home/jim/dev/web2py/gluon/sqlhtml.py", line 1505, in __init__
 default = record[fieldname]
 File "/home/jim/dev/web2py/gluon/packages/dal/pydal/objects.py", line 145, in 
__getitem__
 raise KeyError(key)
KeyError: 'pt3'

I'm not understanding how to define extra_fields in this context.  In the end, 
the form is supposed to look like the attached.  I'm trying to add the 
checkboxes at the bottom of the form.  

I have it all working with SQLFORM.factory but would prefer that I do it with 
the base SQLFORM.  Thoughts?

-Jim

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/679ecdd0-fef8-4620-81b8-c218a0bc435e%40googlegroups.com.


Re: [web2py] Re: Server error when accessing admin

2020-05-01 Thread Ian W. Scott
Okay, I'm narrowing down what the problem might be. The site is presently 
using webfaction's shared SSL certificate for https, which browsers don't 
recognize as secure. Could that be causing the admin interface to throw the 
500 error?



On Thursday, April 30, 2020 at 3:02:58 PM UTC-4, Ian W. Scott wrote:
>
> Unfortunately I don't know anything about nginx. I've always worked with 
> apache2. Can anyone suggest how to debug this? I'm really at the end of my 
> rope here.
>
> On Thursday, April 30, 2020 at 10:37:58 AM UTC-4, Ian W. Scott wrote:
>>
>> Thanks very much
>>
>> Ian W. Scott, PhD
>> Associate Professor of New Testament
>> Tyndale Seminary, Toronto, Canada
>> www.ianwscott.com
>> *Paul's Way of Knowing: Story Experience and the Spirit* (Baker Academic 
>> [Mohr Siebeck], 2006)
>> *The Online Critical Pseudepigrapha* (SBL, 2006-; pseudepigrapha.org)
>> Sent from Mailspring, the best free email app for work
>> On Apr 30 2020, at 10:33 am, 'Annet' via web2py-users <
>> web2py@googlegroups.com> wrote:
>>
>> Hi Ian,
>>
>> I do have a copy of the script, it's a bit old, but I'll attach
>> it anyway, maybe it's of help.
>>
>>
>> Kind regards,
>>
>> Annet
>>
>> --
>> 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/kWdHdAv2jj0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/07767cc2-5691-4c76-b310-bd409b735ea2%40googlegroups.com
>>  
>> 
>> .
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4fb814a0-efbb-4caa-8a09-abd6a5df7014%40googlegroups.com.


[web2py] Re: The virtual fields are not accessible until I convert my records to a list

2020-05-01 Thread Andrew Rogers
Ugg, I'm a goose. Silly mistake. It works exactly as it should. Sadly i 
dont.

On Saturday, 2 May 2020 00:09:50 UTC+10, Andrew Rogers wrote:
>
> (I posted this question here as well: 
> https://stackoverflow.com/questions/61544049/the-virtual-fields-are-not-accessible-until-i-convert-my-records-to-a-list
> )
>
> The book here 
> 
>  
> gives this example for virtual fields where total_price is a virtual (not 
> calculated) field.
>
> for row in db(db.item).select():
>print row.total_price
>
>
> However when i do this my virtual fields are missing. All the non-virtual 
> fields are present.
>
> The only way i can get access to the virtual fields is to convert the 
> records to a list ...
>
> rows = db(db.Table.id>1).select()*.**as_list()*
>
>
> I read Massimo say somewhere that virtual fields are only calculated after 
> the select is done. So i cant filter on a virtual field. But this doesn't 
> seem to relate to my situation.
>
> What am I missing?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1f32ed28-b1a1-43f5-8773-04790ea0d22c%40googlegroups.com.


[web2py] The virtual fields are not accessible until I convert my records to a list

2020-05-01 Thread Andrew Rogers
(I posted this question here as well: 
https://stackoverflow.com/questions/61544049/the-virtual-fields-are-not-accessible-until-i-convert-my-records-to-a-list
)

The book here 

 
gives this example for virtual fields where total_price is a virtual (not 
calculated) field.

for row in db(db.item).select():
   print row.total_price


However when i do this my virtual fields are missing. All the non-virtual 
fields are present.

The only way i can get access to the virtual fields is to convert the 
records to a list ...

rows = db(db.Table.id>1).select()*.**as_list()*


I read Massimo say somewhere that virtual fields are only calculated after 
the select is done. So i cant filter on a virtual field. But this doesn't 
seem to relate to my situation.

What am I missing?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/60841b7f-13e6-4e4e-a200-534a0755cc4a%40googlegroups.com.


Re: [web2py] Re: web2py and ubuntu 20lts

2020-05-01 Thread Lovedie JC
On system restart, the previous pyc files for python 2+ were deleted and it
works OK.
Let me observe for now.
Regards

On Fri, May 1, 2020, 11:26 Lovedie JC  wrote:

> Let me try
>
> On Fri, May 1, 2020, 11:00 Clemens 
> wrote:
>
>> Hi Maurice,
>>
>> obviously you're trying to execute  your pythone-2-compiled code with
>> python 3 (Ubuntu 20 default). Have a try recompiling it with python 3.x.
>>
>> Does this solve the problem?
>>
>> Regards
>> Clemens
>>
>> On Friday, May 1, 2020 at 7:24:34 AM UTC+2, Maurice Waka wrote:
>>>
>>> I recently moved to ubuntu 20LTS and on login to web2py I get this error:
>>>
>>> Traceback
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>>  Traceback (most recent call last):
>>>  File "/home/maurice/web2py/gluon/main.py", line 440, in wsgibase
>>>  serve_controller(request, response, session)
>>>  File "/home/maurice/web2py/gluon/main.py", line 174, in
>>> serve_controller
>>>  run_models_in(environment)
>>>  File "/home/maurice/web2py/gluon/compileapp.py", line 562, in
>>> run_models_in
>>>  ccode = getcfs(model, model, f)
>>>  File "/home/maurice/web2py/gluon/cfs.py", line 50, in getcfs
>>>  data = filter()
>>>  File "/home/maurice/web2py/gluon/compileapp.py", line 559, in 
>>>  f = lambda: read_pyc(model)
>>>  File "/home/maurice/web2py/gluon/compileapp.py", line 427, in read_pyc
>>>  raise SystemError('compiled code is incompatible')
>>> SystemError: compiled code is incompatible
>>>
>>>
>>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/5e0165da-cac3-4398-93b2-ebc7c3a4c120%40googlegroups.com
>> 
>> .
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAAcHJF-F8pei%2B9moXc-kz-iRn4kaiOkgbD-Tv_HyyxkXQc77%3DQ%40mail.gmail.com.


[web2py] Re: Visual Studio Code

2020-05-01 Thread Andrew Rogers
Thanks for the reminder re the intellisense. Do you think it still works 
fine? I tried to out just now and had some issues. But  the problem may 
well be me and not it.

On Friday, 1 May 2020 19:55:39 UTC+10, villas wrote:
>
> Further to Andrew's reply you could also try these ideas:
>
>
> http://www.web2py.com/books/default/chapter/29/14/other-recipes?search=ide+#Using-general-purpose-IDEs-with-web2py
>
> https://github.com/Andyhasit/web2py_intellisense
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8f2dde44-02ef-4343-a288-0b117ed8cf18%40googlegroups.com.


Re: [web2py] Re: Why would new code be ignored and old code be executed?

2020-05-01 Thread Andrew Rogers
Hi again

I am having a similar problem again. I havent compiled the app - i have 
learnt from that mistake, thanks.

I am now trying to import some of my custom functions from other python 
files in the same app. After i got an __init.py__ file in place i was able 
to see and use my imported functions.

However, now when i make a change to the imported function, the new code is 
ignored. I step through line by line in Visual Studio Code and can see it 
'process' my new code but it is running the old line.

I can 'fix' the problem 
1. by restarting the server - but it is only fixed until i make another 
change which is then ignored.
2. by removing 'from common_functions import DetermineMediaRepresentation' 
- it just uses the web2py magic to find the function

'common_functions.py' lives in the 'models' folder, not the 'modules' 
folder.

Can anyone tell me what i am doing wrong?

PS: The reason for the change to explicitly importing was that i wanted to 
just right-click the function in VSC and choose 'Go to Definition'. If i 
dont explicitly import then VSC doesnt know where my functions are and I 
have to go find them by hand.





On Saturday, 7 March 2020 02:01:35 UTC+10, Val K wrote:
>
> oh yeah, it is definitely due to you press compile in appadmin, it is 
> intended for production. Dont compile app while you develop. I use modules 
> without any issues with tracking as i mentoined above

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/aaf77894-c9d1-409c-a8a2-3b2e8ef9a1c3%40googlegroups.com.


[web2py] Re: How to debug appadmin CSV uploading

2020-05-01 Thread Clemens
Hi Jon,

I prefer to upload csv files to the database via the python console, 
starting it as follows:
python **/web2py.py -S ** 
-M -P

There you can import the csv as follows (assuming your database is 
reference by db, i.e. db = DAL(...)):
filename = **/**.csv'; print(filename)

*python2:*
db.import_from_csv_file(open(filename, 'rb')); db.commit()

*python3:*
db.import_from_csv_file(open(str(filename), 'r', encoding='utf-8')); 
db.commit()

To empty an existing database I do it the same way as follows:
for table_name in db.tables():
>>> db[table_name].drop()

db.commit()

Hope it helps!

Regards
Clemens


On Friday, May 1, 2020 at 8:57:38 AM UTC+2, Jonsubs wrote:
>
> Hi everyone,
> I'm trying to upload a CSV file to my MySQL database using appadmin.
>
> I do get a "data uploaded" flash message as if I succeeded, but data is 
> not there.
>
> Could anyone suggest me how to debug this operation?
> Thanks, Jon.
>
>
> 
>  Libre 
> de virus. www.avast.com 
> 
>  
> <#CAK8tz31FLL14iggF+geUS_piGUFSmjKQV7ie34f=7OeQBFRh3Q@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2f6897b9-51fc-4765-8893-30a736e6ba51%40googlegroups.com.


[web2py] Re: Visual Studio Code

2020-05-01 Thread villas
Further to Andrew's reply you could also try these ideas:

http://www.web2py.com/books/default/chapter/29/14/other-recipes?search=ide+#Using-general-purpose-IDEs-with-web2py

https://github.com/Andyhasit/web2py_intellisense

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/46690636-d005-45f2-b91b-d40f9c48ebb2%40googlegroups.com.


Re: [web2py] Re: web2py and ubuntu 20lts

2020-05-01 Thread Lovedie JC
Let me try

On Fri, May 1, 2020, 11:00 Clemens 
wrote:

> Hi Maurice,
>
> obviously you're trying to execute  your pythone-2-compiled code with
> python 3 (Ubuntu 20 default). Have a try recompiling it with python 3.x.
>
> Does this solve the problem?
>
> Regards
> Clemens
>
> On Friday, May 1, 2020 at 7:24:34 AM UTC+2, Maurice Waka wrote:
>>
>> I recently moved to ubuntu 20LTS and on login to web2py I get this error:
>>
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>>  Traceback (most recent call last):
>>  File "/home/maurice/web2py/gluon/main.py", line 440, in wsgibase
>>  serve_controller(request, response, session)
>>  File "/home/maurice/web2py/gluon/main.py", line 174, in serve_controller
>>  run_models_in(environment)
>>  File "/home/maurice/web2py/gluon/compileapp.py", line 562, in
>> run_models_in
>>  ccode = getcfs(model, model, f)
>>  File "/home/maurice/web2py/gluon/cfs.py", line 50, in getcfs
>>  data = filter()
>>  File "/home/maurice/web2py/gluon/compileapp.py", line 559, in 
>>  f = lambda: read_pyc(model)
>>  File "/home/maurice/web2py/gluon/compileapp.py", line 427, in read_pyc
>>  raise SystemError('compiled code is incompatible')
>> SystemError: compiled code is incompatible
>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/5e0165da-cac3-4398-93b2-ebc7c3a4c120%40googlegroups.com
> 
> .
>

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


[web2py] Re: web2py and ubuntu 20lts

2020-05-01 Thread Clemens
Hi Maurice,

obviously you're trying to execute  your pythone-2-compiled code with 
python 3 (Ubuntu 20 default). Have a try recompiling it with python 3.x.

Does this solve the problem?

Regards
Clemens

On Friday, May 1, 2020 at 7:24:34 AM UTC+2, Maurice Waka wrote:
>
> I recently moved to ubuntu 20LTS and on login to web2py I get this error:
>
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
>  Traceback (most recent call last):
>  File "/home/maurice/web2py/gluon/main.py", line 440, in wsgibase
>  serve_controller(request, response, session)
>  File "/home/maurice/web2py/gluon/main.py", line 174, in serve_controller
>  run_models_in(environment)
>  File "/home/maurice/web2py/gluon/compileapp.py", line 562, in 
> run_models_in
>  ccode = getcfs(model, model, f)
>  File "/home/maurice/web2py/gluon/cfs.py", line 50, in getcfs
>  data = filter()
>  File "/home/maurice/web2py/gluon/compileapp.py", line 559, in 
>  f = lambda: read_pyc(model)
>  File "/home/maurice/web2py/gluon/compileapp.py", line 427, in read_pyc
>  raise SystemError('compiled code is incompatible')
> SystemError: compiled code is incompatible
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/5e0165da-cac3-4398-93b2-ebc7c3a4c120%40googlegroups.com.


[web2py] How to debug appadmin CSV uploading

2020-05-01 Thread Jon Subscripted
Hi everyone,
I'm trying to upload a CSV file to my MySQL database using appadmin.

I do get a "data uploaded" flash message as if I succeeded, but data is not
there.

Could anyone suggest me how to debug this operation?
Thanks, Jon.


Libre
de virus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAK8tz31FLL14iggF%2BgeUS_piGUFSmjKQV7ie34f%3D7OeQBFRh3Q%40mail.gmail.com.