Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-04-04 Thread Rahul
Hey All,
   This is *finally fixed.* I spent some time debugging on it 
today. The fix was actually very simple, all I had to do was to convert 
some values to integer. Here is the final fixed version on 
*plugin_solidform.py. 
*For all the folks who want to use this awesome plugin with python 3.x.x 
can give it a try. 

[image: working.png]

*Thanks snide.. and all*


Regards,

*Rahul*

On Sunday, April 3, 2022 at 11:07:05 PM UTC+5:30 snide...@gmail.com wrote:

> On Friday, March 25, 2022 at 11:14:07 PM UTC-7 Rahul wrote:
>
>> yes I used some things like *trunc *or *ceil *to fix it however the 
>> error persists on the same line. Pretty weird. Also used what was suggested 
>> like // 
>> but did not work for me. I want to get this fixed soon. However, 
>>  If its not possible to fix it "quickly" perhaps someone can suggest me 
>> some plugin to manage fields in the layout for proper UI orientation. 
>>
>> All suggestions are welcome
>>
>> Regards,
>> *Rahul*
>>
>>
>
> Have you examined the type of structured_fields and it's components at 
> the time of the exception?  I would add some debug prints just before the 
> for statement.
>
> /dps
>
> On Thursday, March 24, 2022 at 4:51:46 PM UTC+5:30 snide...@gmail.com 
>> wrote:
>>
>>> On Thursday, March 24, 2022 at 3:21:01 AM UTC-7 Massimiliano wrote:
>>>
 This could be one problem:

 for i in range((max_row_lines - extra_colspan) / colspan):

 there are many of this. 

 *range* take an integer, but a division in python3 return a float...


>>> Interesting, but why doesn't the exception occur in the quoted line with 
>>> the range statement?
>>>
>>> The stack trace suggests it occurs after the for loop completes.
>>>
>>> (I' also dizzy from the number of places where self.structured fields 
>>> get redone by enumerating itself)
>>>
>>> /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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/22201292-5249-4f25-a15d-84cdfef0840an%40googlegroups.com.
# -*- coding: utf-8 -*-
# This plugins is licensed under the MIT license: 
http://www.opensource.org/licenses/mit-license.php
# Authors: Kenji Hosoda 
from gluon import *
import copy


class SOLIDFORM(SQLFORM):

def __init__(self, *args, **kwds):
self.structured_fields = kwds.get('fields')
self.showid = kwds.get('showid', True)

table = args and args[0] or kwds['table']
if not self.structured_fields:
self.structured_fields = [f.name for f in table if self._is_show(f)]
else:
self.structured_fields = copy.copy(self.structured_fields)
_precedent_row_len = 1

include_id = False
flat_fields = []
max_row_lines = 1

for i, inner in enumerate(self.structured_fields):

if type(inner) in (list, tuple):
_inner = []
for field in inner:
   
if field == 'id':
include_id = True
self.showid = True
if field and self._is_show(table[field]):
flat_fields.append(field)
_inner.append(field)
self.structured_fields[i] = _inner
max_row_lines = max(len(_inner), max_row_lines)

_precedent_row_len = len(_inner)
elif inner:
if inner == 'id':
include_id = True
self.showid = True
if self._is_show(table[inner]):
flat_fields.append(inner)
else:
self.structured_fields[i] = None
else:
self.structured_fields[i] = [inner for i in 
range(_precedent_row_len)]


self.structured_fields = [e for e in self.structured_fields if e or e 
is None]
  

row_spans = dict((e, 1) for e in flat_fields)
col_spans = dict((e, 1) for e in flat_fields)

row_lines = [[] for i in range(max_row_lines)]
for row_no, inner in enumerate(self.structured_fields):
if type(inner) in (list, tuple):
num_lines = len(inner)
colspan = int(max_row_lines / num_lines)
   
extra_colspan = max_row_lines % num_lines 


for i in range( int((max_row_lines - extra_colspan) / colspan)):
field = inner[i]
if field:
col_span

Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-04-03 Thread Dave S

On Friday, March 25, 2022 at 11:14:07 PM UTC-7 Rahul wrote:

> yes I used some things like *trunc *or *ceil *to fix it however the error 
> persists on the same line. Pretty weird. Also used what was suggested like 
> // 
> but did not work for me. I want to get this fixed soon. However, 
>  If its not possible to fix it "quickly" perhaps someone can suggest me 
> some plugin to manage fields in the layout for proper UI orientation. 
>
> All suggestions are welcome
>
> Regards,
> *Rahul*
>
>

Have you examined the type of structured_fields and it's components at the 
time of the exception?  I would add some debug prints just before the for 
statement.

/dps

On Thursday, March 24, 2022 at 4:51:46 PM UTC+5:30 snide...@gmail.com wrote:
>
>> On Thursday, March 24, 2022 at 3:21:01 AM UTC-7 Massimiliano wrote:
>>
>>> This could be one problem:
>>>
>>> for i in range((max_row_lines - extra_colspan) / colspan):
>>>
>>> there are many of this. 
>>>
>>> *range* take an integer, but a division in python3 return a float...
>>>
>>>
>> Interesting, but why doesn't the exception occur in the quoted line with 
>> the range statement?
>>
>> The stack trace suggests it occurs after the for loop completes.
>>
>> (I' also dizzy from the number of places where self.structured fields get 
>> redone by enumerating itself)
>>
>> /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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/66548933-081a-4894-9a69-b6e38a58dfe6n%40googlegroups.com.


Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-04-02 Thread Rahul
Do we have alternatives to this feature  ? 

Rahul

On Saturday, March 26, 2022 at 11:44:07 AM UTC+5:30 Rahul wrote:

> yes I used some things like *trunc *or *ceil *to fix it however the error 
> persists on the same line. Pretty weird. Also used what was suggested like 
> // 
> but did not work for me. I want to get this fixed soon. However, 
>  If its not possible to fix it "quickly" perhaps someone can suggest me 
> some plugin to manage fields in the layout for proper UI orientation. 
>
> All suggestions are welcome
>
> Regards,
> *Rahul*
>
> On Thursday, March 24, 2022 at 4:51:46 PM UTC+5:30 snide...@gmail.com 
> wrote:
>
>> On Thursday, March 24, 2022 at 3:21:01 AM UTC-7 Massimiliano wrote:
>>
>>> This could be one problem:
>>>
>>> for i in range((max_row_lines - extra_colspan) / colspan):
>>>
>>> there are many of this. 
>>>
>>> *range* take an integer, but a division in python3 return a float...
>>>
>>>
>> Interesting, but why doesn't the exception occur in the quoted line with 
>> the range statement?
>>
>> The stack trace suggests it occurs after the for loop completes.
>>
>> (I' also dizzy from the number of places where self.structured fields get 
>> redone by enumerating itself)
>>
>> /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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/675bd526-d362-447d-80d7-df5657983ba1n%40googlegroups.com.


Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-03-25 Thread Rahul
yes I used some things like *trunc *or *ceil *to fix it however the error 
persists on the same line. Pretty weird. Also used what was suggested like 
// 
but did not work for me. I want to get this fixed soon. However, 
 If its not possible to fix it "quickly" perhaps someone can suggest me 
some plugin to manage fields in the layout for proper UI orientation. 

All suggestions are welcome

Regards,
*Rahul*

On Thursday, March 24, 2022 at 4:51:46 PM UTC+5:30 snide...@gmail.com wrote:

> On Thursday, March 24, 2022 at 3:21:01 AM UTC-7 Massimiliano wrote:
>
>> This could be one problem:
>>
>> for i in range((max_row_lines - extra_colspan) / colspan):
>>
>> there are many of this. 
>>
>> *range* take an integer, but a division in python3 return a float...
>>
>>
> Interesting, but why doesn't the exception occur in the quoted line with 
> the range statement?
>
> The stack trace suggests it occurs after the for loop completes.
>
> (I' also dizzy from the number of places where self.structured fields get 
> redone by enumerating itself)
>
> /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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2e802ab4-233d-45e9-ad27-fdc1bc46157cn%40googlegroups.com.


Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-03-24 Thread Dave S


On Thursday, March 24, 2022 at 3:21:01 AM UTC-7 Massimiliano wrote:

> This could be one problem:
>
> for i in range((max_row_lines - extra_colspan) / colspan):
>
> there are many of this. 
>
> *range* take an integer, but a division in python3 return a float...
>
>
Interesting, but why doesn't the exception occur in the quoted line with 
the range statement?

The stack trace suggests it occurs after the for loop completes.

(I' also dizzy from the number of places where self.structured fields get 
redone by enumerating itself)

/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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6983bf12-0a5e-444b-9066-5c86e553730dn%40googlegroups.com.


Re: [web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-03-24 Thread Massimiliano
This could be one problem:

for i in range((max_row_lines - extra_colspan) / colspan):

there are many of this.

*range* take an integer, but a division in python3 return a float...




Il giorno gio 24 mar 2022 alle ore 09:47 Rahul  ha
scritto:

> anyone has any ideas ?
>
> On Wednesday, March 23, 2022 at 5:13:15 PM UTC+5:30 Rahul wrote:
>
>> Hi All,
>>  I am migrating my python 2.7 project to py 3.7 - I am facing
>> issues with plugin solid form conversion to py3 code. My code uses this
>> plugin a lot. Rest all code works fine except the plugin part - While using
>> it I am getting the error - I tried web recommendations but to no avail -
>> Please suggest !
>>
>>  'float' object cannot be interpreted as an integer
>> Version
>> web2py™
>> Version 2.22.3-stable+timestamp.2022.02.15.15.14.38
>> Python
>> Python 3.7.5: C:\Python37\python.exe (prefix: C:\Python37)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> Traceback (most recent call last):
>> File "E:\web2py_src\web2py\gluon\restricted.py", line 219, in restricted
>> exec(ccode, environment)
>> File "E:/web2py_src/web2py/applications/artpic/controllers/default.py"
>> ,
>> line 9599, in 
>> File "E:\web2py_src\web2py\gluon\globals.py", line 430, in 
>> self._caller = lambda f: f()
>> File "E:/web2py_src/web2py/applications/artpic/controllers/default.py"
>> ,
>> line 6200, in contact
>> form = SOLIDFORM(db.contactus, fields=fields, submit_button='Submit')
>> File
>> "E:\web2py_src\web2py\applications\artpic\modules\plugin_solidform.py", line
>> 59, in __init__
>> for row_no, inner in enumerate(self.structured_fields):
>> TypeError: 'float' object cannot be interpreted as an integer
>>
>>
>> Attached is the file
>>
>> also here is the code -
>>
>>
>> # -*- coding: utf-8 -*-
>> # This plugins is licensed under the MIT license:
>> http://www.opensource.org/licenses/mit-license.php#
>> #Authors: Kenji Hosoda 
>> from gluon import *
>> import copy
>> from math import trunc, ceil
>>
>> class SOLIDFORM(SQLFORM):
>> def __init__(self, *args, **kwds):
>> self.structured_fields = kwds.get('fields')
>> self.showid = kwds.get('showid', True)
>> table = args and args[0] or kwds['table']
>> if not self.structured_fields:
>> self.structured_fields = [f.name for f in table if
>> self._is_show(f)]
>> else:
>> self.structured_fields = copy.copy(self.structured_fields)
>> _precedent_row_len = 1
>>
>> include_id = False
>> flat_fields = []
>> max_row_lines = 1
>> for i, inner in enumerate(self.structured_fields):
>> if type(inner) in (list, tuple):
>> _inner = []
>> for field in inner:
>> if field == 'id':
>> include_id = True
>> self.showid = True
>> if field and self._is_show(table[field]):
>> flat_fields.append(field)
>> _inner.append(field)
>> self.structured_fields[i] = _inner
>> max_row_lines = max(len(_inner), max_row_lines)
>> _precedent_row_len = len(_inner)
>> elif inner:
>> if inner == 'id':
>> include_id = True
>> self.showid = True
>> if self._is_show(table[inner]):
>> flat_fields.append(inner)
>> else:
>> self.structured_fields[i] = None
>> else:
>> self.structured_fields[i] = [inner for i in
>> range(_precedent_row_len)]
>> self.structured_fields = [e for e in self.structured_fields if e
>> or e is None]
>> row_spans = dict((e, 1) for e in flat_fields)
>> col_spans = dict((e, 1) for e in flat_fields)
>> row_lines = [[] for i in range(max_row_lines)]
>> for row_no, inner in enumerate(self.structured_fields):
>> if type(inner) in (list, tuple):
>> num_lines = trunc (len(inner))
>> colspan = max_row_lines / num_lines
>> extra_colspan = max_row_lines % num_lines
>> for i in range((max_row_lines - extra_colspan) / colspan):
>> field = inner[i]
>> if field:
>> col_spans[field] = colspan
>> row_lines[i * colspan].append(field)
>> else:
>> for _row_no in reversed(list(range(row_no))):
>> try:
>>
>> row_spans[self.structured_fields[_row_no][i]] += 1
>> break
>> except KeyError:
>> pass
>> if extra_colspan

[web2py] Re: Do we have Plugin solid form upgraded code for python 3 ?

2022-03-24 Thread Rahul
anyone has any ideas ? 

On Wednesday, March 23, 2022 at 5:13:15 PM UTC+5:30 Rahul wrote:

> Hi All,
>  I am migrating my python 2.7 project to py 3.7 - I am facing 
> issues with plugin solid form conversion to py3 code. My code uses this 
> plugin a lot. Rest all code works fine except the plugin part - While using 
> it I am getting the error - I tried web recommendations but to no avail - 
> Please suggest ! 
>
>  'float' object cannot be interpreted as an integer
> Version
> web2py™
> Version 2.22.3-stable+timestamp.2022.02.15.15.14.38
> Python
> Python 3.7.5: C:\Python37\python.exe (prefix: C:\Python37)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> Traceback (most recent call last):
> File "E:\web2py_src\web2py\gluon\restricted.py", line 219, in restricted
> exec(ccode, environment)
> File "E:/web2py_src/web2py/applications/artpic/controllers/default.py" 
> , 
> line 
> 9599, in 
> File "E:\web2py_src\web2py\gluon\globals.py", line 430, in 
> self._caller = lambda f: f()
> File "E:/web2py_src/web2py/applications/artpic/controllers/default.py" 
> , 
> line 
> 6200, in contact
> form = SOLIDFORM(db.contactus, fields=fields, submit_button='Submit')
> File "E:\web2py_src\web2py\applications\artpic\modules\plugin_solidform.py", 
> line 59, in __init__
> for row_no, inner in enumerate(self.structured_fields):
> TypeError: 'float' object cannot be interpreted as an integer
>
>
> Attached is the file
>
> also here is the code - 
>
>
> # -*- coding: utf-8 -*-
> # This plugins is licensed under the MIT license: 
> http://www.opensource.org/licenses/mit-license.php#
> #Authors: Kenji Hosoda 
> from gluon import *
> import copy
> from math import trunc, ceil
>
> class SOLIDFORM(SQLFORM):
> def __init__(self, *args, **kwds):
> self.structured_fields = kwds.get('fields')
> self.showid = kwds.get('showid', True)
> table = args and args[0] or kwds['table']
> if not self.structured_fields:
> self.structured_fields = [f.name for f in table if 
> self._is_show(f)]
> else:
> self.structured_fields = copy.copy(self.structured_fields)
> _precedent_row_len = 1
>
> include_id = False
> flat_fields = []
> max_row_lines = 1
> for i, inner in enumerate(self.structured_fields):
> if type(inner) in (list, tuple):
> _inner = []
> for field in inner:
> if field == 'id':
> include_id = True
> self.showid = True
> if field and self._is_show(table[field]):
> flat_fields.append(field)
> _inner.append(field)
> self.structured_fields[i] = _inner
> max_row_lines = max(len(_inner), max_row_lines)
> _precedent_row_len = len(_inner)
> elif inner:
> if inner == 'id':
> include_id = True
> self.showid = True
> if self._is_show(table[inner]):
> flat_fields.append(inner)
> else:
> self.structured_fields[i] = None
> else:
> self.structured_fields[i] = [inner for i in 
> range(_precedent_row_len)]
> self.structured_fields = [e for e in self.structured_fields if e 
> or e is None]
> row_spans = dict((e, 1) for e in flat_fields)
> col_spans = dict((e, 1) for e in flat_fields)
> row_lines = [[] for i in range(max_row_lines)]
> for row_no, inner in enumerate(self.structured_fields):
> if type(inner) in (list, tuple):
> num_lines = trunc (len(inner))
> colspan = max_row_lines / num_lines
> extra_colspan = max_row_lines % num_lines
> for i in range((max_row_lines - extra_colspan) / colspan):
> field = inner[i]
> if field:
> col_spans[field] = colspan
> row_lines[i * colspan].append(field)
> else:
> for _row_no in reversed(list(range(row_no))):
> try:
> 
> row_spans[self.structured_fields[_row_no][i]] += 1
> break
> except KeyError:
> pass
> if extra_colspan:
> for line_no in range(max_row_lines - extra_colspan, 
> max_row_lines):
> row_lines[line_no].append(None)
> else:
> field = inner
> col_spans[field] = max_row_lines
> row_lines[0].append(field)
>
> self.row