[web2py] Re: OT PollyReports generate PDF using bands from DB

2020-11-02 Thread 'DenesL' via web2py-users
Sounds promising.
Below is an example of a PollyReport.
Each band (B) contains a list of elements (E).
For each E you can define pos=(x,y), font=(name,size), text, key, align, 
width (among other parameters).
Note that an element's x,y is relative to the containing band's x,y (top 
left corner).
So maybe use a texpos box around a table with one row and try to get 
relative positions that way. 
Note: 72dpi, so x=600 is 8.33 inches from the left edge of the band

H = ("Helvetica", 10)
HB = ("Helvetica-Bold", 10)
E = PR.Element
B = PR.Band
Rule = PR.Rule # horizontal line
R = "right"

rep = PR.Report(rr)
rep.titleband = B([ E((600, 0), ("Times-Bold", 20), "Picklist"),
  E((36,30), H, f"Ship to\n{soi[4]} {soi[5]}\n{adr}"), E((380,30), H, now), 
# soi = sales order query results
  E((480,30), H, f"Order\n{so}"), E((560,30), H, f"Doc.Date\n{dd}"), 
E((630,30), H, f"Allow partial\n{soi[2]}"),
  E((480,60), H, f"MoT: {soi[7]}\nRemarks: {soi[3]}"),
])
rep.groupheaders = [ B([ Rule((36,0),650),], getvalue = lambda x: x[0] ), ]
rep.pageheader = B([
  Rule((36,0),650),
  E((90,0), H, "Item Number"), E((166,0), H, "Description"), E((410,0), HB, 
"Pick Qty", align=R),
  E((450,0), H, "UoM"), E((538,0), H, "Bin Location", align=R), E((626,0), 
H, "OnHand", align=R),
  E((680,0), H, "Picked", align=R),
  Rule((36,12),650),
])
rep.pagefooter = B([ E((72*7, 0), H, sysvar = "pagenumber", format = lambda 
x: f"[{now}]  Order {so} page {x}"), ])
rep.detailband = B([ E((52,0), H, getvalue=lambda r: r[1]+1, align=R),
  E((90,0), H, key=2), E((166,0), H, key=8), E((410,0), HB, key=6, align=R),
  E((450,0), H, key=9), E((573,0), H, key=11, width=42),
  ]
)

Regards,
Denes
On Monday, November 2, 2020 at 4:01:16 AM UTC-5 Clemens wrote:

> Hi, you can realize absolute positioning by the TeX package texpos 
> <https://ctan.org/pkg/textpos>. But I don't know PollyReports very well, 
> I only heard of it. Thus, do you have an example PDF on what you want to 
> generate?
>
> Regards
> Clemens
>
> On Monday, November 2, 2020 at 12:51:40 AM UTC+1 DenesL wrote:
>
>> Hi Clemens
>>
>> does TeX, or any of other formats supported by LyX, store the position on 
>> the page (x,y), formatting (e.g. font type and size), alignment or other 
>> valuable information about text elements that could be used to generate 
>> PollyReports Elements & Bands ?
>>
>> Regards,
>> Denes
>>
>> On Sunday, November 1, 2020 at 7:52:56 AM UTC-5 Clemens wrote:
>>
>>> Hi, you're right, I'm generate everything, because I need this in my 
>>> case. BUT: You can use LyX <https://en.wikipedia.org/wiki/LyX>as 
>>> WYSIWYG editor generating the TeX file (pure text). Then just find and 
>>> replace the things you want to adapt (e.g. date). This should be easy. If 
>>> you want to evaluate this way and you need some more assistance, please let 
>>> me know.
>>>
>>> Best regards
>>> Clemens
>>>
>>> On Saturday, October 31, 2020 at 11:29:53 PM UTC+1 DenesL wrote:
>>>
>>>> @roger: you are welcome.
>>>> @villas: probably reportlab.
>>>> @ramos: reportbro is open-source license for non-commercial open-source 
>>>> or personal projects only.
>>>> @clemens: interesting but you probably have to handle everything e.g. 
>>>> page breaks, page headers, etc. , right?.
>>>>
>>>> My need was to generate PDF documents (e.g. invoices) with report 
>>>> headers/footers, page headers/footers, detail lines, and even sub-reports 
>>>> from database queries without having to handle all the intricacies (e.g. 
>>>> page breaks, total, page numbers, etc.) and PollyReports fit the bill in a 
>>>> small and easy to use package.
>>>>
>>>> What is missing is a WYSIWYG page designer to simplify the layout 
>>>> creation. 
>>>> As an alternative I have been looking for a way to convert a template 
>>>> created by some open source program such as OpenOffice, FreeOffice,  or 
>>>> LibreOffice to the bands/elements used in PollyReports but without much 
>>>> luck so far.
>>>>
>>>> Regards,
>>>> Denes
>>>>
>>>> On Tuesday, October 6, 2020 at 11:16:18 AM UTC-4 Clemens wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> my fav is just to write a TeX file by Python and then trigger LaTeX to 
>>>>> produce the PDF document. I'm using this solution since 2 years

[web2py] Re: OT PollyReports generate PDF using bands from DB

2020-11-01 Thread 'DenesL' via web2py-users
Hi Clemens

does TeX, or any of other formats supported by LyX, store the position on 
the page (x,y), formatting (e.g. font type and size), alignment or other 
valuable information about text elements that could be used to generate 
PollyReports Elements & Bands ?

Regards,
Denes

On Sunday, November 1, 2020 at 7:52:56 AM UTC-5 Clemens wrote:

> Hi, you're right, I'm generate everything, because I need this in my case. 
> BUT: You can use LyX <https://en.wikipedia.org/wiki/LyX>as WYSIWYG editor 
> generating the TeX file (pure text). Then just find and replace the things 
> you want to adapt (e.g. date). This should be easy. If you want to evaluate 
> this way and you need some more assistance, please let me know.
>
> Best regards
> Clemens
>
> On Saturday, October 31, 2020 at 11:29:53 PM UTC+1 DenesL wrote:
>
>> @roger: you are welcome.
>> @villas: probably reportlab.
>> @ramos: reportbro is open-source license for non-commercial open-source 
>> or personal projects only.
>> @clemens: interesting but you probably have to handle everything e.g. 
>> page breaks, page headers, etc. , right?.
>>
>> My need was to generate PDF documents (e.g. invoices) with report 
>> headers/footers, page headers/footers, detail lines, and even sub-reports 
>> from database queries without having to handle all the intricacies (e.g. 
>> page breaks, total, page numbers, etc.) and PollyReports fit the bill in a 
>> small and easy to use package.
>>
>> What is missing is a WYSIWYG page designer to simplify the layout 
>> creation. 
>> As an alternative I have been looking for a way to convert a template 
>> created by some open source program such as OpenOffice, FreeOffice,  or 
>> LibreOffice to the bands/elements used in PollyReports but without much 
>> luck so far.
>>
>> Regards,
>> Denes
>>
>> On Tuesday, October 6, 2020 at 11:16:18 AM UTC-4 Clemens wrote:
>>
>>> Hi,
>>>
>>> my fav is just to write a TeX file by Python and then trigger LaTeX to 
>>> produce the PDF document. I'm using this solution since 2 years after I was 
>>> really frustrated by the Python PDF packages available. LaTeX gives you all 
>>> freedom to produces a PDF document, it's perfectly documented (finding a 
>>> solution for every problem), it's absolutely stable, it can be expanded by 
>>> packages, you have things like a table of contents ... Long story 
>>> short: I like it!
>>>
>>> Regards
>>> Clemens
>>>
>>> On Thursday, October 1, 2020 at 4:58:39 PM UTC+2 DenesL wrote:
>>>
>>>>
>>>> While searching for a Python PDF package I found PollyReports and was 
>>>> pleasantly surprised by it, and it is also nicely documented.
>>>>
>>>> PollyReports is a small, light module providing a simple way to 
>>>> generate reports from databases using Python.
>>>>
>>>> Reference: https://pythonhosted.org/PollyReports/docs.html
>>>> Tutorial: https://pythonhosted.org/PollyReports/tutorial.html
>>>> Other features (subreports): https://opensource.gonnerman.org/?cat=4
>>>>
>>>> I hope you find it as useful as I did.
>>>>
>>>> Regards,
>>>> Denes
>>>>
>>>>
>>>>
>>>>

-- 
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/5c442388-25d9-4535-954f-963d87bd6eefn%40googlegroups.com.


[web2py] Re: OT PollyReports generate PDF using bands from DB

2020-10-31 Thread 'DenesL' via web2py-users
@roger: you are welcome.
@villas: probably reportlab.
@ramos: reportbro is open-source license for non-commercial open-source or 
personal projects only.
@clemens: interesting but you probably have to handle everything e.g. page 
breaks, page headers, etc. , right?.

My need was to generate PDF documents (e.g. invoices) with report 
headers/footers, page headers/footers, detail lines, and even sub-reports 
from database queries without having to handle all the intricacies (e.g. 
page breaks, total, page numbers, etc.) and PollyReports fit the bill in a 
small and easy to use package.

What is missing is a WYSIWYG page designer to simplify the layout creation. 
As an alternative I have been looking for a way to convert a template 
created by some open source program such as OpenOffice, FreeOffice,  or 
LibreOffice to the bands/elements used in PollyReports but without much 
luck so far.

Regards,
Denes

On Tuesday, October 6, 2020 at 11:16:18 AM UTC-4 Clemens wrote:

> Hi,
>
> my fav is just to write a TeX file by Python and then trigger LaTeX to 
> produce the PDF document. I'm using this solution since 2 years after I was 
> really frustrated by the Python PDF packages available. LaTeX gives you all 
> freedom to produces a PDF document, it's perfectly documented (finding a 
> solution for every problem), it's absolutely stable, it can be expanded by 
> packages, you have things like a table of contents ... Long story short: 
> I like it!
>
> Regards
> Clemens
>
> On Thursday, October 1, 2020 at 4:58:39 PM UTC+2 DenesL wrote:
>
>>
>> While searching for a Python PDF package I found PollyReports and was 
>> pleasantly surprised by it, and it is also nicely documented.
>>
>> PollyReports is a small, light module providing a simple way to generate 
>> reports from databases using Python.
>>
>> Reference: https://pythonhosted.org/PollyReports/docs.html
>> Tutorial: https://pythonhosted.org/PollyReports/tutorial.html
>> Other features (subreports): https://opensource.gonnerman.org/?cat=4
>>
>> I hope you find it as useful as I did.
>>
>> Regards,
>> Denes
>>
>>
>>
>>

-- 
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/e6cb8ed6-5f67-4a02-a172-3cfdb5becf08n%40googlegroups.com.


[web2py] OT PollyReports generate PDF using bands from DB

2020-10-01 Thread 'DenesL' via web2py-users

While searching for a Python PDF package I found PollyReports and was 
pleasantly surprised by it, and it is also nicely documented.

PollyReports is a small, light module providing a simple way to generate 
reports from databases using Python.

Reference: https://pythonhosted.org/PollyReports/docs.html
Tutorial: https://pythonhosted.org/PollyReports/tutorial.html
Other features (subreports): https://opensource.gonnerman.org/?cat=4

I hope you find it as useful as I did.

Regards,
Denes



-- 
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/53fdf8b1-d571-4e60-a9cc-1d000524043fn%40googlegroups.com.


[web2py] Re: sum decimal error?

2020-09-14 Thread 'DenesL' via web2py-users

I have found my mistake, in the query
db(ti.DocNum == doc)
I was using the wrong variable (doc) which is a row,
it should be docnum.

Thanks villas for your help and words of encouragement.



On Friday, September 11, 2020 at 11:26:51 AM UTC-4 DenesL wrote:

> Hi villas
>
> thanks for your suggestion.
> I ran a test in the shell and it works:
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2020
> Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
> Database drivers available: sqlite3, pyodbc, imaplib, pymysql
> WARNING:web2py:import IPython error; use default python shell
> Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 
> 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> db.tables
> ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
> 'auth_event', 'auth_cas', 'docscan', 'itmscan']
> >>> ti=db.itmscan
> >>> ss=db(ti.DocNum==350).select()
> >>> print(ss)
> itmscan.id
> ,itmscan.DocNum,itmscan.ItemCode,itmscan.Dscription,itmscan.box,itmsca
>
> n.scanqty,itmscan.scanid,itmscan.empid,itmscan.status,itmscan.spcins,itmscan.tstamp
> 1,350,P10002,"PC - 12x core, 64GB, 5 x 150GB 
> SSD",1,1.00,SCANNER1,emp003,,,2020-09-09 09:14:12
> 2,350,P10002,"PC - 12x core, 64GB, 5 x 150GB 
> SSD",1,1.00,SCANNER1,emp003,,,2020-09-09 09:15:25
> >>> scnqtysum = ti.scanqty.sum()
> >>> ss=db(ti.DocNum==350).select(scnqtysum)
> >>> print(ss)
> "SUM(""itmscan"".""scanqty"")"
> 2.00
>
> so something is amiss somewhere...
>
> BTW, having DocNum=='350' makes no difference.
>
> Denes
>
> On Friday, September 11, 2020 at 6:34:50 AM UTC-4 villas wrote:
>
>> Are you sure your *doc *search value is an integer?
>>
>> Maybe a little more experimentation.  Simplify and then incrementally add 
>> complexity.  Start here...
>> ss = db(ti.DocNum == 99).select(scnqtysum) 
>>
>> Also, check the SQL:
>> ss = db(ti.DocNum == doc)._select(scnqtysum)  ## note the underline chr _ 
>>
>> On Friday, 11 September 2020 at 03:30:54 UTC+1 DenesL wrote:
>>
>>> Hi villas
>>>
>>> thanks for your reply.
>>> There should be no NULLs in there since I deleted all tables and started 
>>> from a blank slate.
>>> Still no idea why this happens. Why is trying to use __int__ if it is a 
>>> decimal?.
>>>
>>> Denes
>>>
>>> On Thursday, September 10, 2020 at 12:04:44 PM UTC-4 villas wrote:
>>>
>>>> Hi Denes
>>>> Just a thought,  and I'm not sure if this is the answer,  but the 
>>>> following indicates that there is a null value in the DB field:
>>>> TypeError: __int__ returned non-int (type NoneType) 
>>>>
>>>> Maybe you initially created the field without a default and then added 
>>>> the default=0.0 later.  This may have enabled you to create records with 
>>>> null values?
>>>>
>>>> I therefore suggest you search for any null values and replace them 
>>>> with 0.0.  Perhaps you could run this query
>>>> update itmscan set scanqty = 0.0 where scanqty is null
>>>>
>>>>
>>>> On Wednesday, 9 September 2020 at 15:31:59 UTC+1 DenesL wrote:
>>>>
>>>>> Hi group
>>>>>
>>>>> running Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
>>>>> with SQL Server 2012 on Win 8.1
>>>>>
>>>>> I am getting the following error when I try to sum a decimal field in 
>>>>> a table:
>>>>>
>>>>> Traceback (most recent call last):
>>>>> File "C:\w2p\web2py22004py3\gluon\restricted.py", line 219, in 
>>>>> restricted
>>>>> exec(ccode, environment)
>>>>> File 
>>>>> "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>>>>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>,
>>>>>  
>>>>> line 1948, in 
>>>>> File "C:\w2p\web2py22004py3\gluon\globals.py", line 430, in 
>>>>> self._caller = lambda f: f()
>>>>> File 
>>>>> "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>>>>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>,
&

[web2py] Re: sum decimal error?

2020-09-11 Thread 'DenesL' via web2py-users
Hi villas

thanks for your suggestion.
I ran a test in the shell and it works:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2020
Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
Database drivers available: sqlite3, pyodbc, imaplib, pymysql
WARNING:web2py:import IPython error; use default python shell
Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> db.tables
['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
'auth_event', 'auth_cas', 'docscan', 'itmscan']
>>> ti=db.itmscan
>>> ss=db(ti.DocNum==350).select()
>>> print(ss)
itmscan.id,itmscan.DocNum,itmscan.ItemCode,itmscan.Dscription,itmscan.box,itmsca
n.scanqty,itmscan.scanid,itmscan.empid,itmscan.status,itmscan.spcins,itmscan.tstamp
1,350,P10002,"PC - 12x core, 64GB, 5 x 150GB 
SSD",1,1.00,SCANNER1,emp003,,,2020-09-09 09:14:12
2,350,P10002,"PC - 12x core, 64GB, 5 x 150GB 
SSD",1,1.00,SCANNER1,emp003,,,2020-09-09 09:15:25
>>> scnqtysum = ti.scanqty.sum()
>>> ss=db(ti.DocNum==350).select(scnqtysum)
>>> print(ss)
"SUM(""itmscan"".""scanqty"")"
2.00

so something is amiss somewhere...

BTW, having DocNum=='350' makes no difference.

Denes

On Friday, September 11, 2020 at 6:34:50 AM UTC-4 villas wrote:

> Are you sure your *doc *search value is an integer?
>
> Maybe a little more experimentation.  Simplify and then incrementally add 
> complexity.  Start here...
> ss = db(ti.DocNum == 99).select(scnqtysum) 
>
> Also, check the SQL:
> ss = db(ti.DocNum == doc)._select(scnqtysum)  ## note the underline chr _ 
>
> On Friday, 11 September 2020 at 03:30:54 UTC+1 DenesL wrote:
>
>> Hi villas
>>
>> thanks for your reply.
>> There should be no NULLs in there since I deleted all tables and started 
>> from a blank slate.
>> Still no idea why this happens. Why is trying to use __int__ if it is a 
>> decimal?.
>>
>> Denes
>>
>> On Thursday, September 10, 2020 at 12:04:44 PM UTC-4 villas wrote:
>>
>>> Hi Denes
>>> Just a thought,  and I'm not sure if this is the answer,  but the 
>>> following indicates that there is a null value in the DB field:
>>> TypeError: __int__ returned non-int (type NoneType) 
>>>
>>> Maybe you initially created the field without a default and then added 
>>> the default=0.0 later.  This may have enabled you to create records with 
>>> null values?
>>>
>>> I therefore suggest you search for any null values and replace them with 
>>> 0.0.  Perhaps you could run this query
>>> update itmscan set scanqty = 0.0 where scanqty is null
>>>
>>>
>>> On Wednesday, 9 September 2020 at 15:31:59 UTC+1 DenesL wrote:
>>>
>>>> Hi group
>>>>
>>>> running Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
>>>> with SQL Server 2012 on Win 8.1
>>>>
>>>> I am getting the following error when I try to sum a decimal field in a 
>>>> table:
>>>>
>>>> Traceback (most recent call last):
>>>> File "C:\w2p\web2py22004py3\gluon\restricted.py", line 219, in 
>>>> restricted
>>>> exec(ccode, environment)
>>>> File 
>>>> "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>>>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>, 
>>>> line 1948, in 
>>>> File "C:\w2p\web2py22004py3\gluon\globals.py", line 430, in 
>>>> self._caller = lambda f: f()
>>>> File 
>>>> "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>>>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>, 
>>>> line 1941, in scanvsdoc
>>>> ss = db(ti.DocNum == doc).select(ti.ItemCode, scnqtysum, groupby = ti.
>>>> ItemCode)
>>>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\objects.py", line 
>>>> 2634, in select
>>>> return adapter.select(self.query, fields, attributes)
>>>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", 
>>>> line 874, in select
>>>> colnames, sql = self._select_wcols(query, fields, **attributes)
>>>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", 
>>>> line 768, in _select_wcols

[web2py] Re: sum decimal error?

2020-09-10 Thread 'DenesL' via web2py-users
Hi villas

thanks for your reply.
There should be no NULLs in there since I deleted all tables and started 
from a blank slate.
Still no idea why this happens. Why is trying to use __int__ if it is a 
decimal?.

Denes

On Thursday, September 10, 2020 at 12:04:44 PM UTC-4 villas wrote:

> Hi Denes
> Just a thought,  and I'm not sure if this is the answer,  but the 
> following indicates that there is a null value in the DB field:
> TypeError: __int__ returned non-int (type NoneType) 
>
> Maybe you initially created the field without a default and then added the 
> default=0.0 later.  This may have enabled you to create records with null 
> values?
>
> I therefore suggest you search for any null values and replace them with 
> 0.0.  Perhaps you could run this query
> update itmscan set scanqty = 0.0 where scanqty is null
>
>
> On Wednesday, 9 September 2020 at 15:31:59 UTC+1 DenesL wrote:
>
>> Hi group
>>
>> running Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
>> with SQL Server 2012 on Win 8.1
>>
>> I am getting the following error when I try to sum a decimal field in a 
>> table:
>>
>> Traceback (most recent call last):
>> File "C:\w2p\web2py22004py3\gluon\restricted.py", line 219, in restricted
>> exec(ccode, environment)
>> File "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>, 
>> line 1948, in 
>> File "C:\w2p\web2py22004py3\gluon\globals.py", line 430, in 
>> self._caller = lambda f: f()
>> File "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
>> <http://10.0.0.27:8000/admin/default/edit/scanpak/controllers/default.py>, 
>> line 1941, in scanvsdoc
>> ss = db(ti.DocNum == doc).select(ti.ItemCode, scnqtysum, groupby = ti.
>> ItemCode)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\objects.py", line 
>> 2634, in select
>> return adapter.select(self.query, fields, attributes)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 874, in select
>> colnames, sql = self._select_wcols(query, fields, **attributes)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 768, in _select_wcols
>> query = self.expand(query, query_env=query_env)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 487, in _expand
>> rv = op(first, second, **optional_args)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\dialects\base.py", line 
>> 406, in eq
>> self.expand(second, first.type, query_env=query_env),
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\dialects\__init__.py", line 
>> 97, in expand
>> return self.adapter.expand(*args, **kwargs)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 497, in _expand
>> rv = self.represent(expression, field_type)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 430, in represent
>> return super(SQLAdapter, self).represent(obj, field_type)
>> File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
>> 384, in represent
>> return self.representer.represent(obj, field_type)
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", 
>> line 246, in represent
>> rv = self.get_representer_for_type(field_type)(rv, field_type)
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", 
>> line 138, in __call__
>> return self.adapt(self.call(value, field_type))
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", 
>> line 135, in _call
>> return self.inner_call(value)
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", 
>> line 123, in _inner_call
>> return self.obj.f(self.representer, value, **kwargs)
>> File 
>> "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\base.py", line 
>> 29, in _integer
>> return str(long(value))
>> TypeError: __int__ returned non-int (type NoneType) 
>>
>> the code looks like this:
>>   ti = db.itmscan
>>   scnqtysum = ti.scanqty.sum()
>>   ss = db(ti.DocNum == doc).select(ti.ItemCode, scnqtysum, groupby = 
>> ti.ItemCode)
>>
>> and the table definition:
>> db.define_table('itmscan',
&g

[web2py] sum decimal error?

2020-09-09 Thread 'DenesL' via web2py-users
Hi group

running Version 2.20.4-stable+timestamp.2020.05.03.05.18.50
with SQL Server 2012 on Win 8.1

I am getting the following error when I try to sum a decimal field in a 
table:

Traceback (most recent call last):
File "C:\w2p\web2py22004py3\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
, line 
1948, in 
File "C:\w2p\web2py22004py3\gluon\globals.py", line 430, in 
self._caller = lambda f: f()
File "C:/w2p/web2py22004py3/applications/scanpak/controllers/default.py" 
, line 
1941, in scanvsdoc
ss = db(ti.DocNum == doc).select(ti.ItemCode, scnqtysum, groupby = ti.
ItemCode)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\objects.py", line 2634, 
in select
return adapter.select(self.query, fields, attributes)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
874, in select
colnames, sql = self._select_wcols(query, fields, **attributes)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
768, in _select_wcols
query = self.expand(query, query_env=query_env)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
487, in _expand
rv = op(first, second, **optional_args)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\dialects\base.py", line 
406, in eq
self.expand(second, first.type, query_env=query_env),
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\dialects\__init__.py", 
line 
97, in expand
return self.adapter.expand(*args, **kwargs)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
497, in _expand
rv = self.represent(expression, field_type)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
430, in represent
return super(SQLAdapter, self).represent(obj, field_type)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\adapters\base.py", line 
384, in represent
return self.representer.represent(obj, field_type)
File 
"C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", line 
246, in represent
rv = self.get_representer_for_type(field_type)(rv, field_type)
File 
"C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", line 
138, in __call__
return self.adapt(self.call(value, field_type))
File 
"C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", line 
135, in _call
return self.inner_call(value)
File 
"C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\__init__.py", line 
123, in _inner_call
return self.obj.f(self.representer, value, **kwargs)
File "C:\w2p\web2py22004py3\gluon\packages\dal\pydal\representers\base.py", 
line 
29, in _integer
return str(long(value))
TypeError: __int__ returned non-int (type NoneType) 

the code looks like this:
  ti = db.itmscan
  scnqtysum = ti.scanqty.sum()
  ss = db(ti.DocNum == doc).select(ti.ItemCode, scnqtysum, groupby = 
ti.ItemCode)

and the table definition:
db.define_table('itmscan',
  Field('DocNum', 'integer'),
  Field('ItemCode', 'string', 20),
  Field('Dscription', 'string', 100),
  Field('box', 'integer', default=1),
  Field('scanqty', 'decimal(19,6)', default=0.0),
  Field('scanid', 'string'),
  Field('empid', 'string'),
  Field('status', 'string'),
  Field('spcins', 'string', default=''),
  Field('tstamp', 'datetime'),
)
I tried adding a represent to the field but it made no difference.

In the code I have a sum on another decimal field from a different table 
just a few lines before the failing one that works just fine. That field is 
also decimal(19,6).

Thanks for any help, if I have made a mistake I can't see it.

Denes

-- 
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/95b954f0-faea-4ad8-83bc-448f99dfa834n%40googlegroups.com.


[web2py] parse_blob override in 2.19.01

2020-04-28 Thread 'DenesL' via web2py-users
Hi all

a while back in this post 
https://groups.google.com/d/msg/web2py/v6bB7PHa7f8/aZjaIby1fTgJ this was 
said:

>
> web2py uses b64encode/decode to store/retrieve data in blobs. Legacy 
> tables probably do not do it.
>
> You need you make your own custom adapter to override a method. For 
> example for PostgreSQL:
>
> from gluon.dal import ADAPTERS, UseDatabaseStoredFile,PostgreSQLAdapter
> class MyPostgresAdapter(PostgreSQLAdapter):
>  drivers = ('psycopg2',)
>  def parse_blob(self, value, field_type): return value
>
> ADAPTERS['mypostgres'] = MyPostgresAdapter
>
> db = DAL('mypostgres://.')
>

Is this still possible with web2py 2.19.01?

Thanks,
Denes

-- 
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/ec0f7960-8d2b-4573-ba43-607741ca0ad2%40googlegroups.com.


Re: [web2py] web2py 2.16.01 legacy databases

2018-01-25 Thread 'DenesL' via web2py-users
MS SQL server 2012 (at the top of my first post) using *appadmin* to 
display tables/records.
Clear enough?.


On Thursday, January 25, 2018 at 9:33:51 AM UTC-5, Ovidio Marinho wrote:
>
> Be clearer, which databases are you using as a legacy? And what kind of 
> operation do you want to do?
>
>
>
>
>
>[image: http://itjp.net.br] <http://itjp.net.br>
>  http://itjp.net.b <http://itjp.net.br>r
>   *Ovidio Marinho Falcao Neto*
>  ovidio...@gmail.com
> Brasil
>  
>
> 2018-01-25 9:46 GMT-03:00 'DenesL' via web2py-users <
> web2py@googlegroups.com>:
>
>> Hi Ovidio, 
>>
>> the issue is that appadmin seems to be generating improper links to 
>> display records in legacy databases.
>> The sample code given to reproduce it, although not from a real scenario 
>> is syntactically correct.
>>
>> Can anyone else reproduce the issue?.
>>
>> Thanks,
>> Denes
>>
>>
>> On Wednesday, January 24, 2018 at 6:35:07 PM UTC-5, Ovidio Marinho wrote:
>>>
>>> What is the need for you to create a primary key in a field name or char?
>>> look this:
>>> It defines, stores and returns a Table object called "person" containing 
>>> a field (column) "name". This object can also be accessed via db.person, so 
>>> you do not need to catch the return value.
>>> id: Notes about the primary key
>>>
>>> Do not declare a field called "id", because one is created by web2py 
>>> anyway. Every table has a field called "id" by default. It is an 
>>> auto-increment integer field (starting at 1) used for cross-reference and 
>>> for making every record unique, so "id" is a primary key. (Note: the id 
>>> counter starting at 1 is back-end specific. For example, this does not 
>>> apply to the Google App Engine NoSQL.)
>>>
>>> Optionally you can define a Field of type='id' and web2py will use this 
>>> field as auto-increment id field. This is not recommended except when 
>>> accessing legacy database tables which have a primary key under a different 
>>> name. With some limitation, you can also use different primary keys using 
>>> the primarykey parameter. primarykey is explained shortly below.
>>>
>>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#id--Notes-about-the-primary-key
>>>
>>> a good practice of development is not creating primary keys are named, 
>>> another element would be important to social security + name ,for example.
>>>
>>> Hope this helps.
>>>
>>>
>>>
>>>
>>>[image: http://itjp.net.br] <http://itjp.net.br>
>>>  http://itjp.net.b <http://itjp.net.br>r
>>>   *Ovidio Marinho Falcao Neto*
>>>  ovidio...@gmail.com
>>> Brasil
>>>  
>>>
>>> 2018-01-24 19:54 GMT-03:00 'DenesL' via web2py-users <
>>> web2py@googlegroups.com>:
>>>
>>>> Testing web2py 2.16.01 installed from source on Windows 8 with Python 
>>>> 2.7.14
>>>>
>>>> I have two tables on MS SQL Server 2012, one is legacy, the other not:
>>>>
>>>> w2p.define_table('person',
>>>>   Field('name', 'string', length=100, notnull=True),
>>>>   Field('info', 'string', length=100),
>>>>   primarykey=['name']
>>>> )
>>>>
>>>> w2p.define_table('persona',
>>>>   Field('name', 'string', length=100, notnull=True),
>>>>   Field('info', 'string', length=100)
>>>> )
>>>>
>>>> The appadmin shows the records for both tables but the legacy anchors 
>>>> to display each record are being incorrectly generated as:
>>>>
>>>> Ana
>>>> 
>>>>
>>>>
>>>> http://10.0.0.27:8000/test/appadmin/select/%3Cfunction%20%3Clambda%3E%20at%200x071AAEB8%3E/person?name=Ana
>>>>
>>>> Regards,
>>>> Denes
>>>>
>>>> -- 
>>>> 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 

[web2py] Re: auth.messages.subject

2018-01-25 Thread 'DenesL' via web2py-users
While doing what in auth?. 
you might be able to set one the default subjects in Auth.default_messages, 
namely:

['verify_email_subject', 'reset_password_subject', 
'retrieve_username_subject',
'bulk_invite_subject', 'retrieve_two_factor_code_subject', 
'retrieve_password_subject']


On Wednesday, January 24, 2018 at 1:47:50 PM UTC-5, Mark Billion wrote:
>
> So, this does not work.  Any way to set the subject line? (maybe Im just 
> missing it)
>

-- 
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] web2py 2.16.01 legacy databases

2018-01-25 Thread 'DenesL' via web2py-users
Hi Ovidio, 

the issue is that appadmin seems to be generating improper links to display 
records in legacy databases.
The sample code given to reproduce it, although not from a real scenario is 
syntactically correct.

Can anyone else reproduce the issue?.

Thanks,
Denes

On Wednesday, January 24, 2018 at 6:35:07 PM UTC-5, Ovidio Marinho wrote:
>
> What is the need for you to create a primary key in a field name or char?
> look this:
> It defines, stores and returns a Table object called "person" containing a 
> field (column) "name". This object can also be accessed via db.person, so 
> you do not need to catch the return value.
> id: Notes about the primary key
>
> Do not declare a field called "id", because one is created by web2py 
> anyway. Every table has a field called "id" by default. It is an 
> auto-increment integer field (starting at 1) used for cross-reference and 
> for making every record unique, so "id" is a primary key. (Note: the id 
> counter starting at 1 is back-end specific. For example, this does not 
> apply to the Google App Engine NoSQL.)
>
> Optionally you can define a Field of type='id' and web2py will use this 
> field as auto-increment id field. This is not recommended except when 
> accessing legacy database tables which have a primary key under a different 
> name. With some limitation, you can also use different primary keys using 
> the primarykey parameter. primarykey is explained shortly below.
>
> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#id--Notes-about-the-primary-key
>
> a good practice of development is not creating primary keys are named, 
> another element would be important to social security + name ,for example.
>
> Hope this helps.
>
>
>
>
>[image: http://itjp.net.br] <http://itjp.net.br>
>  http://itjp.net.b <http://itjp.net.br>r
>   *Ovidio Marinho Falcao Neto*
>  ovidio...@gmail.com
> Brasil
>  
>
> 2018-01-24 19:54 GMT-03:00 'DenesL' via web2py-users <
> web2py@googlegroups.com>:
>
>> Testing web2py 2.16.01 installed from source on Windows 8 with Python 
>> 2.7.14
>>
>> I have two tables on MS SQL Server 2012, one is legacy, the other not:
>>
>> w2p.define_table('person',
>>   Field('name', 'string', length=100, notnull=True),
>>   Field('info', 'string', length=100),
>>   primarykey=['name']
>> )
>>
>> w2p.define_table('persona',
>>   Field('name', 'string', length=100, notnull=True),
>>   Field('info', 'string', length=100)
>> )
>>
>> The appadmin shows the records for both tables but the legacy anchors to 
>> display each record are being incorrectly generated as:
>>
>> Ana
>> 
>>
>>
>> http://10.0.0.27:8000/test/appadmin/select/%3Cfunction%20%3Clambda%3E%20at%200x071AAEB8%3E/person?name=Ana
>>
>> Regards,
>> Denes
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] web2py 2.16.01 legacy databases

2018-01-24 Thread 'DenesL' via web2py-users
Testing web2py 2.16.01 installed from source on Windows 8 with Python 2.7.14

I have two tables on MS SQL Server 2012, one is legacy, the other not:

w2p.define_table('person',
  Field('name', 'string', length=100, notnull=True),
  Field('info', 'string', length=100),
  primarykey=['name']
)

w2p.define_table('persona',
  Field('name', 'string', length=100, notnull=True),
  Field('info', 'string', length=100)
)

The appadmin shows the records for both tables but the legacy anchors to 
display each record are being incorrectly generated as:

Ana

http://10.0.0.27:8000/test/appadmin/select/%3Cfunction%20%3Clambda%3E%20at%200x071AAEB8%3E/person?name=Ana

Regards,
Denes

-- 
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: custom pydal adapter

2018-01-18 Thread 'DenesL' via web2py-users
I tried the following:

import datetime
from pydal.parsers import for_type

def _blob(self,value):
  return to_native(to_bytes(value))

def _time(self, value):
  if isinstance(value, datetime.time):
return value.time()
  return datetime.time(int(value[0:2]), int(value[2:4]))

BLOBPARSER = for_type(_blob)
TIMEPARSER = for_type(_time)

if SQLSRVER >= 2012:
  ADAPTER = 'mssql4'
elif SQLSRVER >=2008:
  ADAPTER = 'mssql3'
else:
  ADAPTER = 'mssql'

db = DAL('%s://...'%(ADAPTER, ...))
db._adapter.parser._declared_parsers_['_blob'] = BLOBPARSER
db._adapter.parser._declared_parsers_['_time'] = TIMEPARSER


but it does not work 

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python2711\lib\site-packages\pydal\objects.py", line 2250, in 
select
return adapter.select(self.query, fields, attributes)
  File "C:\Python2711\lib\site-packages\pydal\adapters\base.py", line 762, 
in select
return self._select_aux(sql, fields, attributes, colnames)
  File "C:\Python2711\lib\site-packages\pydal\adapters\base.py", line 741, 
in _select_aux
return processor(rows, fields, colnames, cacheable=cacheable)
  File "C:\Python2711\lib\site-packages\pydal\adapters\base.py", line 305, 
in parse
for row in rows
  File "C:\Python2711\lib\site-packages\pydal\adapters\base.py", line 231, 
in _parse
value = self.parse_value(value, fit, ft, blob_decode)
  File "C:\Python2711\lib\site-packages\pydal\adapters\base.py", line 198, 
in parse_value
return self.parser.parse(value, field_itype, field_type)
  File "C:\Python2711\lib\site-packages\pydal\parsers\__init__.py", line 101
, in parse
return self.registered[field_itype](value, field_type)
  File "C:\Python2711\lib\site-packages\pydal\parsers\__init__.py", line 76, 
in __call__
return self.call(value, field_type)
  File "C:\Python2711\lib\site-packages\pydal\parsers\__init__.py", line 73, 
in _call
return self.f(self.parser, value)
  File "C:\Python2711\lib\site-packages\pydal\parsers\base.py", line 37, in 
_blob
return to_native(b64decode(to_bytes(value)))
  File "C:\Python2711\lib\base64.py", line 77, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding

which I kind of expected.
Is there a way to modify the parser before the adapter is used to define 
the db without adding to the source?.

Thanks,
Denes

On Thursday, January 18, 2018 at 11:14:31 AM UTC-5, DenesL wrote:
>
> Hello
>
> in an older version of web2py I had code to create a custom adapter.
> This code does not work in the latest version of web2py so I tried to 
> update it, but web2py has changed so much internally that I am having a bit 
> of trouble.
> Any hints on how to rewrite the following are appreciated:
>
> from pydal.adapters import ADAPTERS
> if SQLSRVER == '2008' or SQLSRVER == '2008R2':
>   from pydal.adapters.mssql import MSSQL3Adapter
>   class MSSQLSBO(MSSQL3Adapter):
>   def parse_blob(self, value, field_type):
>   return value
>   def parse_time(self, value, field_type):
>   if not isinstance(value, datetime.time):
>   value = datetime.time(int(value[0:2]), int(value[2:4]))
>   return value
> elif SQLSRVER == '2012':
>   from pydal.adapters.mssql import MSSQL4Adapter
>   class MSSQLSBO(MSSQL4Adapter):
>   def parse_blob(self, value, field_type):
>   return value
>   def parse_time(self, value, field_type):
>   if not isinstance(value, datetime.time):
>   value = datetime.time(int(value[0:2]), int(value[2:4]))
>   return value
> else:
>   from pydal.adapters.mssql import MSSQL2Adapter
>   class MSSQLSBO(MSSQL2Adapter):
>   def parse_blob(self, value, field_type):
>   return value
>   def parse_time(self, value, field_type):
>   if not isinstance(value, datetime.time):
>   value = datetime.time(int(value[0:2]), int(value[2:4]))
>   return value
> ADAPTERS['mssqlsbo'] = MSSQLSBO
>
> Thank you,
> Denes
>

-- 
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] custom pydal adapter

2018-01-18 Thread 'DenesL' via web2py-users
Hello

in an older version of web2py I had code to create a custom adapter.
This code does not work in the latest version of web2py so I tried to 
update it, but web2py has changed so much internally that I am having a bit 
of trouble.
Any hints on how to rewrite the following are appreciated:

from pydal.adapters import ADAPTERS
if SQLSRVER == '2008' or SQLSRVER == '2008R2':
  from pydal.adapters.mssql import MSSQL3Adapter
  class MSSQLSBO(MSSQL3Adapter):
  def parse_blob(self, value, field_type):
  return value
  def parse_time(self, value, field_type):
  if not isinstance(value, datetime.time):
  value = datetime.time(int(value[0:2]), int(value[2:4]))
  return value
elif SQLSRVER == '2012':
  from pydal.adapters.mssql import MSSQL4Adapter
  class MSSQLSBO(MSSQL4Adapter):
  def parse_blob(self, value, field_type):
  return value
  def parse_time(self, value, field_type):
  if not isinstance(value, datetime.time):
  value = datetime.time(int(value[0:2]), int(value[2:4]))
  return value
else:
  from pydal.adapters.mssql import MSSQL2Adapter
  class MSSQLSBO(MSSQL2Adapter):
  def parse_blob(self, value, field_type):
  return value
  def parse_time(self, value, field_type):
  if not isinstance(value, datetime.time):
  value = datetime.time(int(value[0:2]), int(value[2:4]))
  return value
ADAPTERS['mssqlsbo'] = MSSQLSBO

Thank you,
Denes

-- 
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] Access DB2/400 from IBM i (AS/400) PASE environment

2017-04-30 Thread 'DenesL' via web2py-users
Have you tried the rname parameter in the table definition?.
Denes

On Thursday, April 27, 2017 at 8:20:40 AM UTC-4, Jim S wrote:
>
> Yes, I was able to get it to connect and the DAL created my tables, but 
> not it won't access them because it is looking for lower case table names 
> and evidently when the tables were created the names became upper case.  
> Since I'm working with this in a Litmis space I don't have full access to 
> do all the work needed.  I do have a 7.3 IBM i box that I'm just getting 
> setup with the new OPS PTFs and am planning on continuing my testing when 
> that becomes available. I was planning on reporting back once I had that 
> all working.
>
> Anyone know if there is a quick way to tell the DAL to ignore the case of 
> the table/field names when connecting?
>
> -Jim
>
> On Thu, Apr 27, 2017 at 6:48 AM, António Ramos wrote:
>
>> @Jim any news on this ?
>>
>>
>>
>> 
>>  Sem 
>> vírus. www.avast.com 
>> 
>>  
>> <#CAERBpoBUu9KQD4Uj8Ar933yoAb8QOCH7cLr+sW0Xj8SU-4DPTw@mail.gmail.com_m_1226437280183523027_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> 2017-04-21 16:36 GMT+01:00 Massimo Di Pierro:
>>
>>> We do have an adapter for db2:ibm_db_dbi did you try it? Anyway, in 
>>> general adapter are defined in 
>>>
>>> web2py/gluon/packages/dal/pydal/adapters
>>> You can make your own adapter. The first step is identify which existing 
>>> adapter to extend. You want to pick the one with the closest SQL dialect. 
>>> Then you create (in a new adapter file) a new class that extends that 
>>> adapter. db2:ibm_db_dbi for example is defined in db2.py as follows:
>>>
>>> @adapters.register_for('db2:ibm_db_dbi')
>>>
>>> class DB2IBM(DB2):
>>>
>>> drivers = ('ibm_db_dbi',)
>>>
>>>
>>> def connector(self):
>>>
>>> uriparts = self.ruri.split(";")
>>>
>>> cnxn = {}
>>>
>>> for var in uriparts:
>>>
>>> v = var.split('=')
>>>
>>> cnxn[v[0].lower()] = v[1]
>>>
>>> return self.driver.connect(
>>>
>>> cnxn['dsn'], cnxn['uid'], cnxn['pwd'], **self.driver_args)
>>>
>>> and can be called as:
>>>
>>> db = DAL('db2:ibm_db_dbi:dsn=;uid=...;pwd=...')
>>>
>>>
>>>
>>>
>>>
>>> On Friday, 21 April 2017 09:50:03 UTC-5, Jim S wrote:

 I would love to do some work on this if there was a mentor out there 
 willing to help me get started.

 -Jim

 On Fri, Apr 21, 2017 at 5:34 AM, António Ramos wrote:

> Maybe Massimo will read this and give us some hints on how to make 
>  DAL use the ibm_dbi
>
> Regards
>
>
> 
>  Sem 
> vírus. www.avast.com 
> 
>  
> <#CAERBpoBUu9KQD4Uj8Ar933yoAb8QOCH7cLr+sW0Xj8SU-4DPTw@mail.gmail.com_m_1226437280183523027_m_7092998039415557888_CAERBpoB9XHiZLmMc2ZRmOb=JTAwUc+3=AKTvYoVXpYzostc8gQ@mail.gmail.com_m_-8595142087007992887_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> 2017-03-17 21:06 GMT+00:00 Jim S:
>
>> Hi
>>
>> In a former (and somewhat current) life I was an AS/400 guy.  Our 
>> shop still uses the platform though most of my time is spent on Python 
>> and 
>> web2py now.
>>
>> Recently Python became available and officially supported on IBM i 
>> and I'm trying to get web2py running there accessing the local DB2/400 
>> database.  Using the local python on the system I can create a database 
>> connection to the local database doing this:
>>
>> import ibm_db_dbi as db
>>
>> conn = db.connect(database='*LOCAL')
>>
>> I'm hoping to find an easy way to convert this into a connectstring 
>> for the DAL so I can have my database created there.  The SQL-flavor it 
>> should use would be the same as ODBC-flavored SQL.  
>>
>> Can anyone give me a clue how to modify the DAL code to connect to my 
>> db?  Any pointers to other articles or links would really be 
>> appreciated.  
>> It would be exciting for me to get this working since I could then show 
>> RPG 
>> developers how easy it would be to get an application on the web from 
>> the 
>> AS/400 using python/web2py.
>>
>> -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 

Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-04-04 Thread 'DenesL' via web2py-users
The instruction is to use a git clone command as follows

[usro5gha@SPACES]~% git clone --recursive https://github.com/web2py/web2py.git  
Cloning into 'web2py'...
fatal: Unable to find remote helper for 'https'

but it obviuosly fails. 
I have never used the git version of web2py, any ideas?.

On Tuesday, April 4, 2017 at 11:03:48 AM UTC-4, Jim S wrote:
>
> And then if I try to install pysqlite I get:
>
>
> [usrxkcon@SPACES]~/web2py% easy_install pysqlite==2.7.0   
>   
>
> Searching for pysqlite==2.7.0 
>   
> Reading http://pypi.python.org/simple/pysqlite/
>  
>
> Best match: pysqlite 2.7.0
>   
> Downloading 
> https://pypi.python.org/packages/81/08/4de886dc16aaf99b5466c2b8b7aa4
>
> d1b79fd52f557ae52c04a293b712389/pysqlite-2.7.0.tar.gz#md5=a8ca3c5426efc56c0d0e18
>
> e41b9ebe4c
>   
>
> Processing pysqlite-2.7.0.tar.gz  
>   
>
> Running pysqlite-2.7.0/setup.py -q bdist_egg --dist-dir 
> /tmp/easy_install-0TAVEK
>
> /pysqlite-2.7.0/egg-dist-tmp-nB2v6w   
>   
>
> warning: no files found matching 'doc/*.txt'  
>   
>
> unable to execute xlc_r: No such file or directory
>   
>
> error: Setup script exited with error: command 'xlc_r' failed with exit 
> status 1
>
> -Jim
>
> On Tuesday, April 4, 2017 at 9:43:23 AM UTC-5, Jim S wrote:
>>
>> Pretty sure I downloaded the zip file from github and extracted it.  Then 
>> started with command line options specifying IP of 0.0.0.0 and port.  Port 
>> can be determined by clicking on the More Info icon on the on your Spaces 
>> page.
>>
>> Also, here is the error I'm getting with the Welcome app:
>>
>> [image: Inline image 1]
>>
>> -Jim
>>
>>
>> On Tue, Apr 4, 2017 at 9:28 AM, 'DenesL' via web2py-users <
>> web2py@googlegroups.com> wrote:
>>
>>> Could you detail how you install and start web2py on litmis?.
>>>
>>>
>>> On Tuesday, April 4, 2017 at 9:40:38 AM UTC-4, Jim S wrote:
>>>>
>>>> The error I'm getting on litmis has to do with pysqlite.  I was going 
>>>> to jump on and get you my error message, but seems I can't connect right 
>>>> now.
>>>>
>>>> -Jim
>>>>
>>>> On Tue, Apr 4, 2017 at 8:30 AM, 'DenesL' via web2py-users <
>>>> web2py@googlegroups.com> wrote:
>>>>
>>>>> I tried running web2py on PUB400 but I get
>>>>>
>>>>>   File 
>>>>> "/QOpenSys/QIBM/ProdData/OPS/Python2.7/lib/python2.7/threading.py", line 
>>>>> 736, in start
>>>>> _start_new_thread(self.__bootstrap, ()) 
>>>>> thread.error: can't start new thread
>>>>>
>>>>> Does web2py work on litmis?.
>>>>>
>>>>> Denes 
>>>>>
>>>>> On Wednesday, March 29, 2017 at 2:40:07 PM UTC-4, Jim S wrote:
>>>>>>
>>>>>> I need a DAL adapter for the ibm_db_dbi connector and have no idea 
>>>>>> where to even begin.  It's on the back-burner for now but will pick it 
>>>>>> up 
>>>>>> again when I have some free time.
>>>>>>
>>>>>> -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 a topic in the 
>>>>> Google Groups "web2py-users" group.
>>>>> To unsubscribe from this topic, visit 
>>>>> https://groups.google.com/d/topic/web2py/qrlN5TSSBgs/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 a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/qrlN5TSSBgs/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.


Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-04-04 Thread 'DenesL' via web2py-users
Could you detail how you install and start web2py on litmis?.


On Tuesday, April 4, 2017 at 9:40:38 AM UTC-4, Jim S wrote:
>
> The error I'm getting on litmis has to do with pysqlite.  I was going to 
> jump on and get you my error message, but seems I can't connect right now.
>
> -Jim
>
> On Tue, Apr 4, 2017 at 8:30 AM, 'DenesL' via web2py-users <
> web2py@googlegroups.com> wrote:
>
>> I tried running web2py on PUB400 but I get
>>
>>   File 
>> "/QOpenSys/QIBM/ProdData/OPS/Python2.7/lib/python2.7/threading.py", line 
>> 736, in start
>> _start_new_thread(self.__bootstrap, ()) 
>> thread.error: can't start new thread
>>
>> Does web2py work on litmis?.
>>
>> Denes 
>>
>> On Wednesday, March 29, 2017 at 2:40:07 PM UTC-4, Jim S wrote:
>>>
>>> I need a DAL adapter for the ibm_db_dbi connector and have no idea where 
>>> to even begin.  It's on the back-burner for now but will pick it up again 
>>> when I have some free time.
>>>
>>> -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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/qrlN5TSSBgs/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.


Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-04-04 Thread 'DenesL' via web2py-users
I tried running web2py on PUB400 but I get

  File "/QOpenSys/QIBM/ProdData/OPS/Python2.7/lib/python2.7/threading.py", 
line 736, in start
_start_new_thread(self.__bootstrap, ()) 
thread.error: can't start new thread

Does web2py work on litmis?.

Denes 

On Wednesday, March 29, 2017 at 2:40:07 PM UTC-4, Jim S wrote:
>
> I need a DAL adapter for the ibm_db_dbi connector and have no idea where 
> to even begin.  It's on the back-burner for now but will pick it up again 
> when I have some free time.
>
> -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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-03-20 Thread 'DenesL' via web2py-users
Thanks Ramos. Python 2.7.11 at pub400.

Can you guys provide a save file to FTP to pub400? they are running v7r3m0.

Denes


On Monday, March 20, 2017 at 10:23:34 AM UTC-4, Ramos wrote:
>
> Iseries 7.x in the cloud
>
> http://pub400.com/
>
> tutorial about iseries using pub400
>
> https://www.youtube.com/watch?v=vTOC0YXs9Ts
>
> 2017-03-20 14:07 GMT+00:00 Jim Steil :
>
>> Are you familiar with Aaron Bartell's work and litmis spaces?  
>> spaces.litmis.com
>>
>> There you can get a free PASE session on their boxes.  Use the code BETA 
>> when signing up.  Let me know if you have any questions.
>>
>> -Jim
>>
>> On Mon, Mar 20, 2017 at 8:56 AM, 'DenesL' via web2py-users <
>> web2py@googlegroups.com> wrote:
>>
>>>
>>> Last summer uh? Not keeping up with i news lately...
>>>
>>> I looked it up as soon as I saw your post today, that is why I said it 
>>> seems to need a modified adapter to map things thru ibm_db.
>>> It might be fairly easy and I would like to help but the lack of a newer 
>>> i box to test with doesn't help.
>>>
>>> Denes 
>>>
>>> On Monday, March 20, 2017 at 9:31:04 AM UTC-4, Jim S wrote:
>>>>
>>>> Yes, support became available for Python 2 and Python 3 last summer.  
>>>> Came out in Technology Refreshes.  They still have a long way to go 
>>>> getting 
>>>> more packages supported, but base support is there.  They also have a 
>>>> local 
>>>> dbapi connector to connect to a DB2/400 database which is what I'm trying 
>>>> to connect to with the DAL.
>>>>
>>>> I don't know where to begin modifying an adapter, looking for help.
>>>>
>>>> -Jim
>>>>
>>>> On Monday, March 20, 2017 at 8:18:41 AM UTC-5, DenesL wrote:
>>>>>
>>>>> Hi Jim
>>>>>
>>>>> Python officially supported on i, finally!!
>>>>> I wish this had happened a while back.
>>>>>
>>>>> It seems that this would require a modified adapter in web2py,
>>>>> sadly I have no access to a current 7.x box to test.
>>>>>
>>>>> Denes
>>>>>
>>>>> On Saturday, March 18, 2017 at 11:11:34 AM UTC-4, Jim S wrote:
>>>>>>
>>>>>> In this example he is connecting using a DB2 connector.  However, I'm 
>>>>>> hoping to use the ibm_db_dbi connector and don't know how to specify it 
>>>>>> on 
>>>>>> the dal connection.  He is using:
>>>>>>
>>>>>> db = DAL('db2://DSN=MYDSN;UID=x;PWD=x', migrate_enabled=False)
>>>>>>
>>>>>>
>>>>>> I'm not sure what to put in place of the db2://DSN...
>>>>>>
>>>>>> Anyone?
>>>>>>
>>>>>> -Jim
>>>>>>
>>>>>>
>>>>>> On Fri, Mar 17, 2017 at 7:38 PM, António Ramos wrote:
>>>>>>
>>>>>>> maybe
>>>>>>>
>>>>>>> http://www.web2pyslices.com/slice/show/1474/calling-remote-program-on-db2-from-pythonweb2py
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <#CAEM0BxP54xTLcQR9-+P+_wF0xYhSEY8_XhVUjcimaf8c7f_CwA@mail.gmail.com_m_8440901031396165177_m_-7554748344480484208_269cefbd-24e0-4f4b-98ec-bed31dff4d60@googlegroups.com_c78e0319-5078-4af6-9a39-37e920755dac@googlegroups.com_CAERBpoCttAv9kGK=rqf1z1TiNvGQS-h99VwVWD9JJZ3ZAVeMaw@mail.gmail.com_m_-838279669736982895_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>>>>
>>>>>>> 2017-03-17 21:06 GMT+00:00 Jim S :
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> In a former (and somewhat current) life I was an AS/400 guy.  Our 
>>>>>>>> shop still uses the platform though most of my time is spent on Python 
>>>>>>>> and 
>>>>>>>> web2py now.
>>>>>>>>
>>>>>>>> Recently Python became available and officially supported on IBM i 
>>>>>>>> and I'm trying to get web2py running there accessing the local DB2/400 
>>>>>>>> database.  Using the local python on the system I can create a 
>>>>>>>> database 
>>>>>>>> connection to the local database d

Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-03-20 Thread 'DenesL' via web2py-users
Litmis only has Python-3.4.4 


On Monday, March 20, 2017 at 10:08:07 AM UTC-4, Jim S wrote:
>
> Are you familiar with Aaron Bartell's work and litmis spaces?  
> spaces.litmis.com
>
> There you can get a free PASE session on their boxes.  Use the code BETA 
> when signing up.  Let me know if you have any questions.
>
> -Jim
>
> On Mon, Mar 20, 2017 at 8:56 AM, 'DenesL' via web2py-users wrote:
>
>>
>> Last summer uh? Not keeping up with i news lately...
>>
>> I looked it up as soon as I saw your post today, that is why I said it 
>> seems to need a modified adapter to map things thru ibm_db.
>> It might be fairly easy and I would like to help but the lack of a newer 
>> i box to test with doesn't help.
>>
>> Denes 
>>
>> On Monday, March 20, 2017 at 9:31:04 AM UTC-4, Jim S wrote:
>>>
>>> Yes, support became available for Python 2 and Python 3 last summer.  
>>> Came out in Technology Refreshes.  They still have a long way to go getting 
>>> more packages supported, but base support is there.  They also have a local 
>>> dbapi connector to connect to a DB2/400 database which is what I'm trying 
>>> to connect to with the DAL.
>>>
>>> I don't know where to begin modifying an adapter, looking for help.
>>>
>>> -Jim
>>>
>>> On Monday, March 20, 2017 at 8:18:41 AM UTC-5, DenesL wrote:
>>>>
>>>> Hi Jim
>>>>
>>>> Python officially supported on i, finally!!
>>>> I wish this had happened a while back.
>>>>
>>>> It seems that this would require a modified adapter in web2py,
>>>> sadly I have no access to a current 7.x box to test.
>>>>
>>>> Denes
>>>>
>>>> On Saturday, March 18, 2017 at 11:11:34 AM UTC-4, Jim S wrote:
>>>>>
>>>>> In this example he is connecting using a DB2 connector.  However, I'm 
>>>>> hoping to use the ibm_db_dbi connector and don't know how to specify it 
>>>>> on 
>>>>> the dal connection.  He is using:
>>>>>
>>>>> db = DAL('db2://DSN=MYDSN;UID=x;PWD=x', migrate_enabled=False)
>>>>>
>>>>>
>>>>> I'm not sure what to put in place of the db2://DSN...
>>>>>
>>>>> Anyone?
>>>>>
>>>>> -Jim
>>>>>
>>>>>
>>>>> On Fri, Mar 17, 2017 at 7:38 PM, António Ramos wrote:
>>>>>
>>>>>> maybe
>>>>>>
>>>>>> http://www.web2pyslices.com/slice/show/1474/calling-remote-program-on-db2-from-pythonweb2py
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <#CAERBpoCHvvgNfbffSKAFcDFZTik10ACs69rAY__7rG7whA_5wA@mail.gmail.com_m_-7554748344480484208_269cefbd-24e0-4f4b-98ec-bed31dff4d60@googlegroups.com_c78e0319-5078-4af6-9a39-37e920755dac@googlegroups.com_CAERBpoCttAv9kGK=rqf1z1TiNvGQS-h99VwVWD9JJZ3ZAVeMaw@mail.gmail.com_m_-838279669736982895_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>>>
>>>>>> 2017-03-17 21:06 GMT+00:00 Jim S :
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> In a former (and somewhat current) life I was an AS/400 guy.  Our 
>>>>>>> shop still uses the platform though most of my time is spent on Python 
>>>>>>> and 
>>>>>>> web2py now.
>>>>>>>
>>>>>>> Recently Python became available and officially supported on IBM i 
>>>>>>> and I'm trying to get web2py running there accessing the local DB2/400 
>>>>>>> database.  Using the local python on the system I can create a database 
>>>>>>> connection to the local database doing this:
>>>>>>>
>>>>>>> import ibm_db_dbi as db
>>>>>>>
>>>>>>> conn = db.connect(database='*LOCAL')
>>>>>>>
>>>>>>> I'm hoping to find an easy way to convert this into a connectstring 
>>>>>>> for the DAL so I can have my database created there.  The SQL-flavor it 
>>>>>>> should use would be the same as ODBC-flavored SQL.  
>>>>>>>
>>>>>>> Can anyone give me a clue how to modify the DAL code to connect to 
>>>>>>> my db?  Any pointers to other articles or links would really be 
>>>>>>> appreciated.  It would be exciting for m

Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-03-20 Thread 'DenesL' via web2py-users

Last summer uh? Not keeping up with i news lately...

I looked it up as soon as I saw your post today, that is why I said it 
seems to need a modified adapter to map things thru ibm_db.
It might be fairly easy and I would like to help but the lack of a newer i 
box to test with doesn't help.

Denes 

On Monday, March 20, 2017 at 9:31:04 AM UTC-4, Jim S wrote:
>
> Yes, support became available for Python 2 and Python 3 last summer.  Came 
> out in Technology Refreshes.  They still have a long way to go getting more 
> packages supported, but base support is there.  They also have a local 
> dbapi connector to connect to a DB2/400 database which is what I'm trying 
> to connect to with the DAL.
>
> I don't know where to begin modifying an adapter, looking for help.
>
> -Jim
>
> On Monday, March 20, 2017 at 8:18:41 AM UTC-5, DenesL wrote:
>>
>> Hi Jim
>>
>> Python officially supported on i, finally!!
>> I wish this had happened a while back.
>>
>> It seems that this would require a modified adapter in web2py,
>> sadly I have no access to a current 7.x box to test.
>>
>> Denes
>>
>> On Saturday, March 18, 2017 at 11:11:34 AM UTC-4, Jim S wrote:
>>>
>>> In this example he is connecting using a DB2 connector.  However, I'm 
>>> hoping to use the ibm_db_dbi connector and don't know how to specify it on 
>>> the dal connection.  He is using:
>>>
>>> db = DAL('db2://DSN=MYDSN;UID=x;PWD=x', migrate_enabled=False)
>>>
>>>
>>> I'm not sure what to put in place of the db2://DSN...
>>>
>>> Anyone?
>>>
>>> -Jim
>>>
>>>
>>> On Fri, Mar 17, 2017 at 7:38 PM, António Ramos wrote:
>>>
>>>> maybe
>>>>
>>>> http://www.web2pyslices.com/slice/show/1474/calling-remote-program-on-db2-from-pythonweb2py
>>>>
>>>>
>>>>
>>>>
>>>> <#269cefbd-24e0-4f4b-98ec-bed31dff4d60@googlegroups.com_c78e0319-5078-4af6-9a39-37e920755dac@googlegroups.com_CAERBpoCttAv9kGK=rqf1z1TiNvGQS-h99VwVWD9JJZ3ZAVeMaw@mail.gmail.com_m_-838279669736982895_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>
>>>> 2017-03-17 21:06 GMT+00:00 Jim S :
>>>>
>>>>> Hi
>>>>>
>>>>> In a former (and somewhat current) life I was an AS/400 guy.  Our shop 
>>>>> still uses the platform though most of my time is spent on Python and 
>>>>> web2py now.
>>>>>
>>>>> Recently Python became available and officially supported on IBM i and 
>>>>> I'm trying to get web2py running there accessing the local DB2/400 
>>>>> database.  Using the local python on the system I can create a database 
>>>>> connection to the local database doing this:
>>>>>
>>>>> import ibm_db_dbi as db
>>>>>
>>>>> conn = db.connect(database='*LOCAL')
>>>>>
>>>>> I'm hoping to find an easy way to convert this into a connectstring 
>>>>> for the DAL so I can have my database created there.  The SQL-flavor it 
>>>>> should use would be the same as ODBC-flavored SQL.  
>>>>>
>>>>> Can anyone give me a clue how to modify the DAL code to connect to my 
>>>>> db?  Any pointers to other articles or links would really be appreciated. 
>>>>>  
>>>>> It would be exciting for me to get this working since I could then show 
>>>>> RPG 
>>>>> developers how easy it would be to get an application on the web from the 
>>>>> AS/400 using python/web2py.
>>>>>
>>>>> -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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Access DB2/400 from IBM i (AS/400) PASE environment

2017-03-20 Thread 'DenesL' via web2py-users
Hi Jim

Python officially supported on i, finally!!
I wish this had happened a while back.

It seems that this would require a modified adapter in web2py,
sadly I have no access to a current 7.x box to test.

Denes

On Saturday, March 18, 2017 at 11:11:34 AM UTC-4, Jim S wrote:
>
> In this example he is connecting using a DB2 connector.  However, I'm 
> hoping to use the ibm_db_dbi connector and don't know how to specify it on 
> the dal connection.  He is using:
>
> db = DAL('db2://DSN=MYDSN;UID=x;PWD=x', migrate_enabled=False)
>
>
> I'm not sure what to put in place of the db2://DSN...
>
> Anyone?
>
> -Jim
>
>
> On Fri, Mar 17, 2017 at 7:38 PM, António Ramos wrote:
>
>> maybe
>>
>> http://www.web2pyslices.com/slice/show/1474/calling-remote-program-on-db2-from-pythonweb2py
>>
>>
>>
>>
>> <#CAERBpoCttAv9kGK=rqf1z1TiNvGQS-h99VwVWD9JJZ3ZAVeMaw@mail.gmail.com_m_-838279669736982895_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> 2017-03-17 21:06 GMT+00:00 Jim S :
>>
>>> Hi
>>>
>>> In a former (and somewhat current) life I was an AS/400 guy.  Our shop 
>>> still uses the platform though most of my time is spent on Python and 
>>> web2py now.
>>>
>>> Recently Python became available and officially supported on IBM i and 
>>> I'm trying to get web2py running there accessing the local DB2/400 
>>> database.  Using the local python on the system I can create a database 
>>> connection to the local database doing this:
>>>
>>> import ibm_db_dbi as db
>>>
>>> conn = db.connect(database='*LOCAL')
>>>
>>> I'm hoping to find an easy way to convert this into a connectstring for 
>>> the DAL so I can have my database created there.  The SQL-flavor it should 
>>> use would be the same as ODBC-flavored SQL.  
>>>
>>> Can anyone give me a clue how to modify the DAL code to connect to my 
>>> db?  Any pointers to other articles or links would really be appreciated.  
>>> It would be exciting for me to get this working since I could then show RPG 
>>> developers how easy it would be to get an application on the web from the 
>>> AS/400 using python/web2py.
>>>
>>> -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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py and Spatial / GIS support

2016-05-24 Thread 'DenesL' via web2py-users
I believe the original web2py GIS sponsor (http://sahanafoundation.org/) 
uses it in their products, which are production ready.

Expanding it depends on:
- existence of desired functionality in the supported databases
- desirability of said functions for the community
- willingness to contribute, from developers and users


On Tuesday, May 24, 2016 at 9:56:33 AM UTC-4, Pierre wrote:
>
>
> too bad
> do you think the existing implementation is still usable in a production 
> context or is it too dangerous / unstable ?
> there's a python package called *pyproj* that might offer some 
> workarounds to transform points coordinatesand "stay in touch" with 
> the dal
>

-- 
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: Dropdown doesn't show on response.menu

2016-05-14 Thread 'DenesL' via web2py-users
Bootstrap 3 does not support menu depths beyond level 2.
See 
https://groups.google.com/forum/#!searchin/web2py/menu|sort:relevance/web2py/UkIV84MuE6w/QtJtfQkyAwAJ

On Saturday, May 14, 2016 at 4:45:34 PM UTC-4, anamarie06...@gmail.com 
wrote:
>
> Question from a new user. I defined the response.menu as following and the 
> dropdown doesn't show in inventory
>
>
> response.menu = [
> (T('Home'), False, URL('default', 'index'), [ 
> (T('shopping'),False,URL('default','make_list')), 
>(T('List'),False,URL('default','store_item')),  
>(T('Inventory'),False,URL('default','Inventories'),[(T('My Sales'), 
> False, URL('default', 'sales')),(T('My buys'), False, URL('default', 
> 'buys')),(T('My Cart'), False, URL('default', 'cart')),(T('My Orders'), 
> False, URL('default', 'myorders'))]),   
>(T('Contact'),False,URL('default','contact'))])
>]
>
>
>
>

-- 
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: invalid request

2016-05-10 Thread 'DenesL' via web2py-users
Have you tried starting web2py without Apache?.
You seem to have change IP addresses and ports, they are stored and need to 
be reset.
http://www.web2py.com/books/default/chapter/29/04/the-core#Command-line-options


On Tuesday, May 10, 2016 at 6:38:42 AM UTC-4, Laer Cius wrote:
>
> Hi,
>
> I know this is going to be a bit vague but I have a web2py folder in my 
> home : /home/user/web2py which I can reach in my browser at 127.0.0.1:8080 
> and that I now try to access through public_html.
>
> Then I copied all files into public_html, made apache and file system 
> modifications (selinux, rights, firewall) but I only get an "invalid 
> request" answer at http://192.168.0.10/~user/web2py. It does not seem to 
> be an apache misconfiguration as I have no error in apache logs and I can 
> even get my "invalid request" from another computer on my local network at 
> the same address.
>
> I guess it comes from a web2py misconfiguration but I don't know what or 
> where to look at first or even second. I tried to rebuild all databases but 
> it stops even before it can get to model files. And the tricky part is that 
> I don't have any error ticket.
>
> So my simple question would be : where and for what I should look for ? 
> Any idea is welcomed, I'm kind of dry at the time..
>
> 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: create file outside of web2py using IDE

2016-05-09 Thread 'DenesL' via web2py-users
The models are executed in alphabetic order, so check that the newly 
created model file is not executed before the db is defined.


On Wednesday, May 4, 2016 at 11:56:08 AM UTC-4, Vic Ding wrote:
>
> Hi all,
>
> I am using Pycharm together with web2py. I created a model file 
> models/db1.py in IDE and sync it back to the server through SSH. The file 
> is pickup by the server (I can see it in the web IDE) however, I get a 
> complain when visiting the site
> name 'db' is not defined
> How can I deal with this situation?
>
> Thanks!
>
> Cheers,
> Vic
>

-- 
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: DB2 truncate()

2016-05-09 Thread 'DenesL' via web2py-users
There are different platforms on which DB2 runs and in some the TRUNCATE 
command is supported, but that is not the case for iSeries DB2.
Which version of OS are you running?.

The alternative seems to be a DELETE without a WHERE clause which could be 
set as a TRUNCATE override in another db2 class adapter.
You can use the mssql one as a reference.

Or CLRPFM.

Denes

On Friday, May 6, 2016 at 4:02:18 PM UTC-4, Auden RovelleQuartz wrote:
>
> when i attempt to do a db.tablename.truncate() on a DB2 table, I get the 
> following error:
>
> Ticket ID
>
> 127.0.0.1.2016-05-06.14-57-20.5ee10f85-fb6e-4bfe-8d16-db0b224313b9
>  ('42000', '[42000] [IBM][iSeries Access 
> ODBC Driver][DB2 UDB]SQL0104 - Token TRUNCATE was not valid. Valid tokens: 
> ( END GET SET CALL DROP FREE HOLD LOCK OPEN WITH ALTER. (-104) 
> (SQLExecDirectW)')Version
> web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16
> Python Python 2.7.9: 
> C:\Users\arovellequartz\Desktop\web2py_win\web2py\web2py.exe (prefix: )
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
>
> Traceback (most recent call last):
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\restricted.py", line 
> 227, in restricted
> exec ccode in environment
>   File 
> "C:/Users/arovellequartz/Desktop/web2py_win/web2py/applications/test/controllers/default.py"
>  , line 
> 57, in 
>   File "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\globals.py", 
> line 417, in 
> self._caller = lambda f: f()
>   File 
> "C:/Users/arovellequartz/Desktop/web2py_win/web2py/applications/test/controllers/default.py"
>  , line 
> 52, in user
> db.riqtemp26.truncate()
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\objects.py",
>  line 838, in truncate
> return self._db._adapter.truncate(self, mode)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  line 1004, in truncate
> self.execute(query)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\db2.py",
>  line 98, in execute
> return self.log_execute(command)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  line 1382, in log_execute
> ret = self.get_cursor().execute(command, *a[1:], **b)
> ProgrammingError: ('42000', '[42000] [IBM][iSeries Access ODBC Driver][DB2 
> UDB]SQL0104 - Token TRUNCATE was not valid. Valid tokens: ( END GET SET CALL 
> DROP FREE HOLD LOCK OPEN WITH ALTER. (-104) (SQLExecDirectW)')
>
>
> Is there something special required to use the truncate() feature with DB2 
> databases?
>

-- 
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: executeSQL returns None (Cassandra)

2016-05-09 Thread 'DenesL' via web2py-users
As far as I know web2py does not oficially support Cassandra, however it 
could be added with some work.


On Monday, May 9, 2016 at 5:06:10 AM UTC-4, MrRedmerlot wrote:
>
> Hi,
>
> My web2py is connected to Cassandra.
> I need to use ALLOW FILTERING flag in the command.
> I don't see how I could include it in DAL, so I tried using raw 
> db.executesql(), but it seems that even simplest command 'select * from 
> ' returns None.
>
> Is this a known bug? Any suggestions?
>
> 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: Not Authorized - but I don't know why

2016-05-08 Thread 'DenesL' via web2py-users
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#login-required-by-default-for-data-updates
By default all the URLs generated by the grid are digitally signed and 
verified. This means one cannot perform certain actions (create, update, 
delete) without being logged-in.


On Sunday, May 8, 2016 at 11:58:08 AM UTC-4, Simon Carr wrote:
>
> Here is the code in my controller.
>
> # -*- coding: utf-8 -*-
> # try something like
> def index():
> return dict(message="hello from supplier.py")
>
>
> def manage_suppliers():
> links = [lambda row: A(SPAN(_class='glyphicon glyphicon-search'),' 
> View',_class='button btn btn-default',_href=URL("supplier","view",args=[
> row.id]))]
> form = SQLFORM.grid(db.suppliers,links=links,details=False)
> return locals()
>
>
> def view():
> supplier = db.suppliers(request.args(0))
> form = SQLFORM.grid(db.supplier_contacts)
> return supplier
>
>
> I can get to manage_suppliers just fine, but when I click "View" against 
> one of the suppliers I get "Not Authorized".
>
> If I remove 
> form = SQLFORM.grid(db.supplier_contacts)
>
> from the the view method. It works fine, so the issue seems with this line 
> of code.
>

-- 
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: About the database adminstration

2016-05-08 Thread 'DenesL' via web2py-users
It means that you can not name a table or field "ALL" because it is a 
keyword (it has special meaning) in the current DB.
You have to use a different name.

On Sunday, May 8, 2016 at 9:48:23 AM UTC-4, Abhijeet Singh Tomer wrote:
>
> when I create a no of fields in the db.py file after then when I click on 
> the database administration it shows me error which is as follows:
>  invalid table/column name "state" is a 
> "ALL" reserved SQL/NOSQL keyword
>
>
>
>

-- 
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: Label in Form

2016-05-08 Thread 'DenesL' via web2py-users
You don't say how you are creating the form.
Assuming you are using SQLFORM then the label is in the Field definition:
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-constructor


On Sunday, May 8, 2016 at 9:48:28 AM UTC-4, R U wrote:
>
> I am fairly new to all things coding and the learning has been slow.  My 
> question is how to insert a label or legend in a form when making the form 
> from the model.  
> If that is not possible I will need to make the form in the controller. 
>  the problem I run into there is how to create a boolean.  The example in 
> the book only shows how to make input fields.  
>
> My form has a section for dates and a couple groups of check-boxes and 
> would greatly benefit from some labels. 
>
> thanks Rob
>

-- 
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: checkboxes framework7.io and validate

2016-04-21 Thread 'DenesL' via web2py-users

I am still using F7 to develop mobile apps, unlike other frameworks/tools 
that I have tried before, which were dropped because of their lack of 
features or performance issues, and I have tried a few of them along the 
way: jquery mobile, kendoui, lungo, semantic, and some others I can't 
recall now.

Obviously F7 is not a perfect fit but what is?. At times its way of doing 
things might clash with w2p but so far so good.
Got to love the richness of features.

If more w2p-iers used it then we could eventually build a set of 
interfacing widgets to smooth out the bumps. 
So I am interested in hearing other people's experiences with it.

Denes

-- 
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: checkboxes framework7.io and validate

2016-04-19 Thread 'DenesL' via web2py-users
The solution I came up to this issue is at
http://forum.framework7.io/#!/bugs-and-issues:formtojson-checkbox-encodin

I would like to hear from others that might be using F7 with web2py.

Denes

-- 
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: Pre populating form with list:string field

2016-04-18 Thread 'DenesL' via web2py-users
Hmmm... you are right.
I would have to check the source.
As an alternative you can do:

  Field('test', 'list:string', default=['asdasd','2435345']),



On Monday, April 18, 2016 at 11:45:45 AM UTC-4, Carlos Cesar Caballero 
wrote:
>
> Is just what I am doing, this is the code:
>
> def index():response.flash = T("Hello World")form = SQLFORM.factory(
> Field('name', requires=IS_NOT_EMPTY()),Field('test', 
> 'list:string'),)
> form.vars.test = ['asdasd','2435345']
> if form.process().accepted:response.flash = form.vars.name
>
> return dict(message=T('Welcome to web2py!'), form=form)
>
>
> But my test field keeps empty.
>
> Greetings.
>
> El 18/04/16 a las 10:56, 'DenesL' via web2py-users escribió:
>
> You would use a list.
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#list--type--and-contains
>
>
> On Monday, April 18, 2016 at 9:27:13 AM UTC-4, Carlos Cesar Caballero 
> wrote: 
>>
>> Hi, I am trying to pre-populate a form who has a list:string field, but 
>> if I pass a list to form.vars.my_list_field it keeps empty, And if I try 
>> something like "|value1|value2|value3|" just the first field of the list 
>> is filled with that string. How can I pre-populate a list:string field? 
>>
>> Greetings. 
>>
>> -- 
>> Este mensaje le ha llegado mediante el servicio de correo electronico que 
>> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
>> Nacional de Salud. La persona que envia este correo asume el compromiso de 
>> usar el servicio a tales fines y cumplir con las regulaciones establecidas 
>>
>> Infomed: http://www.sld.cu/ 
>>
>> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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: Pre populating form with list:string field

2016-04-18 Thread 'DenesL' via web2py-users
You would use a list.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#list--type--and-contains


On Monday, April 18, 2016 at 9:27:13 AM UTC-4, Carlos Cesar Caballero wrote:
>
> Hi, I am trying to pre-populate a form who has a list:string field, but 
> if I pass a list to form.vars.my_list_field it keeps empty, And if I try 
> something like "|value1|value2|value3|" just the first field of the list 
> is filled with that string. How can I pre-populate a list:string field? 
>
> Greetings. 
>
> -- 
> Este mensaje le ha llegado mediante el servicio de correo electronico que 
> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
> Nacional de Salud. La persona que envia este correo asume el compromiso de 
> usar el servicio a tales fines y cumplir con las regulaciones establecidas 
>
> Infomed: http://www.sld.cu/ 
>
>

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


[web2py] Re: Web2py -> MYSQL issue when querying database in background applicaiton

2016-04-18 Thread 'DenesL' via web2py-users
Your private test script works fine for me on web2py 2.14.05 with rocket 
and ms sqlserver.

In your post it says "test module" but I have the db & table in the models.

Denes


On Saturday, April 16, 2016 at 12:53:35 AM UTC-4, David wrote:
>
> Let me start by saying Web2py is awesome and I'm excited about the 
> capabilities of this program.  
>
> I have run into an issue that I will layout here: 
>
> Problem Statement: When running web2py with mySQL (XAMPP v3.2.2) and 
> running background queries the db().select statement doesn't pull a fresh 
> copy, but seems to pulled from a chaced copy of the database.  I can 
> perform a row.update_record succesfully which, but any new inserts into the 
> database from the website don't show in the query.  
>
> Background:  I had this working with SqlLite, but migrated to mySQL to 
> improve the amount of concurrent connections I was making. 
>
> I'm running Web2py like this:
>
> web2py.exe -S appname -M -R c:\web2py\applications\appname\private\test.py
>
> 
> ---test module
> db.define_table('tests',
> Field('test'), #This field I'm adding manually 
> Field('updated'), #This field is being updated by the 
> script.
> )
>
>
>
> 
> ---test.py
>
>
> import time
> count = 0 #Used to show the count 
> while True:
> count = count+ 1
> print 'This is a Test while True:'
> try:
> results = db(db.tests.updated=='').select()
> except:
> print 'Failed to get results'
> if results:
> print 'Test = True'
> print 'Count: %s' % count
> print results
> for row in results:
> print 'Id: %s  Test: %s  Updated: %s' % (row.id,row.test,row.
> updated)
> row.update_record(updated='Yes')
> db.commit()
> print 'Completed'
> else:
> print 'Test = False'
> print 'Count: %s' % count
> print 'waiting 10'
> print results
> print'All database'
> print db(db.tests.id>0).select()
> time.sleep(10)
>
>
> Steps I'm taking.
>
>
>
>
>
>1. Add two records to the test database (through the appadmin 
>interface) 
>
>
> 
>2. Starting the python script with :web2py.exe -S appname -M -R 
>c:\web2py\applications\appname\private\test.py
>
>
> 
>3. From this point It updates the blank field with a 'Yes'.  Then in 
>starts looping through and checking if any new records are in the database 
>and blank
>It does sucesssfully update the record with 
>row.update_record(updated='Yes')
>4. I insert another record Test 7 into the database leaving the 
>updated field blank
>5. The script has continued to run, but never sees the new Test 7.  It 
>continues to only see the Test 6 as the last record.  
>I am able to see the Test 7 from the appadmin interface.  
>
> I have checked mysql and caching is turned off. I'm using the default 
> config of XAMPP.  
>
> Any assistance would be greatly appreciated.  I'm starting to feel like 
> this might be a bug within Web2py?
>
>
> --
> The information transmitted, including any attachments, is intended only 
> for the person or entity to which it is addressed and may contain 
> confidential and/or privileged material. Any review, retransmission, 
> dissemination or other use of, or taking of any action in reliance upon, 
> this information by persons or entities other than the intended recipient 
> is prohibited, and all liability arising therefrom is disclaimed. If you 
> received this in error, please contact the sender and delete the material 
> from any computer. PricewaterhouseCoopers LLP is a Delaware limited 
> liability partnership. This communication may come from 
> PricewaterhouseCoopers LLP or one of its subsidiaries.
>

-- 
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: Some help with computed field in a query

2016-04-06 Thread 'DenesL' via web2py-users
Maybe you could use a virtual field and not a computed one:

db.rentals.urlid = Field.Virtual( 'urlid', lambda r: URL('rentals_manage', 
args=r.id) )

then after rows = db(db.rentals...).select(...)
the rows will contain an urlid field.

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Virtual-fields


On Sunday, April 3, 2016 at 8:17:25 PM UTC-4, Henk huisman wrote:
>
> Could anyone show me how to build a query with a computed field that 
> consists of a constant and a value of the ID of the records.
> The constant is an URL and the value is the ID of the row.
>
> I tried this (among several other attempts).
>
> rowsb=db.executesql("SELECT 'dikke bmw' as caption, startdate as start, 
>  '../rentals_manage/'+ %s  as url, FROM rentals;",as_dict = 
> True,placeholders=('id',))
>
> but that doesn't seem to be valid syntax...
>
> the output is needed by Timeline which is actually a very nice widget 
> http://www.simile-widgets.org/timeline/
>
> Danki
>
>

-- 
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: smartgrid header sorting

2016-04-05 Thread 'DenesL' via web2py-users
The links argument must be a list of dict(header='name',body=lambda row: 
A(...)) where header is the header of the new column and body is a function 
that takes a row and returns a value. In the example, the value is a A(...) 
helper.
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-signature

On Saturday, April 2, 2016 at 9:10:02 PM UTC-4, Jeff Riley wrote:
>
> Hello all.  I have the following function to display a smartgrid.  My 
> issue is I am not able select a header to sort.  It gives me a 404.
>
> @auth.requires_login()
> def manage_sheets():
> if 'new' in request.args:
> redirect(URL('new_sheet', args=[session.cust_id]))
> elif 'edit' in request.args:
> redirect(URL('edit_sheet', args=[request.args(3)]))
> elif 'view' in request.args:
> redirect(URL('view_sheet', args=[request.args(3)]))
> sheets = db.sheet.customer_id==request.args(0,cast=int)
> this_customer = db.customer(db.customer.id==request.args(0,cast=int))
> session.cust_id = this_customer.id
> LINKS=[lambda row: A('Sheet 
> Archive',_href=URL('manage_sheet_archive',args=[row.id, 
> session.cust_id]))]
> form = SQLFORM.smartgrid(db.sheet, constraints = dict(sheet = sheets),
>  searchable=True, editable=True, 
> deletable=False,
>  create=True, paginate=20, maxtextlength=60, 
> fields=[db.sheet.title,
>  db.sheet.sheet_version, db.sheet.created_by, 
> db.sheet.created_on],
>  orderby=db.sheet.title, links=LINKS, 
> linked_tables={})
> return dict(form=form, customer=this_customer)
>

-- 
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: Perform Queries with SQLFORM.smartgrid()

2016-04-05 Thread 'DenesL' via web2py-users
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-smartgrid
is designed to take as input not a query but only one table and to browse 
said table and selected referencing tables.

http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid
The first argument of SQLFORM.grid can be a table or a query.


On Tuesday, April 5, 2016 at 4:12:20 PM UTC-4, Boken . . wrote:
>
> Hi,
>
> I need to use smartgrid with a query to avoid users view records of other 
> users, but I don't how does.
> This code:
> form = SQLFORM.smartgrid(db(db.t_table.user == 
> auth.user).select(),onupdate=auth.archive)
>
> raise an error:
>  'Rows' object has no attribute '_db'
>
> Thanks you very much.
> Regards.
>

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


[web2py] Re: SQLFORM, custom, widget

2016-04-05 Thread 'DenesL' via web2py-users
Chapter 7: 
http://web2py.com/books/default/chapter/29/07/forms-and-validators
in different sections:
process 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#The-process-and-validate-methods
custom & widget 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms


On Tuesday, April 5, 2016 at 4:12:20 PM UTC-4, Jun Q wrote:
>
> May be a dummy question, I am a new user of Web2py
>
> * I have created a table with couple attributes in the model
>
> I saw a code written in the following way:
> *In the controller:*
> myform = SQLFORM(db.tablename).process()
> 
>
> *In the view:*
> {{=myform.custom.begin}}
> 
> {{=myform.custom.widget.attribute1}}
> 
> {{=myform.custom.widget.attribute2}}
> 
> {{=myform.custom.end}}
>
> Could any one tell me what is the SQLFORM(db.tablename).process() return ? 
> And what is the "custom" and "widget" here? 
> Which part in the web2py manual I can look for more detail?
>

-- 
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 make two css work for a view such that one is for pc and the other for mobiles?

2016-04-05 Thread 'DenesL' via web2py-users
See 
http://web2py.com/books/default/chapter/29/05/the-views#Mobile-development

On Tuesday, April 5, 2016 at 3:51:03 PM UTC-4, Stephen Duisberg wrote:
>
> Can we write two css files for the same?
>

-- 
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: checkboxes framework7.io and validate

2016-03-31 Thread 'DenesL' via web2py-users

Let me re-phrase the question.
Would it be invalid to post the input field name='box1' type='checkbox' as 
box1[] ?

I have been unsuccessfull in replicating a post with box1[] from checkboxes 
without Framework7 except when the input itself is named box1[].
F7 uses javascript to modify the DOM and probably during form submission so 
it could be messing up the names.

Thanks,
Denes 

-- 
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] move detect_record_change section under SQLFORM in the book

2016-03-31 Thread 'DenesL' via web2py-users
Suggestion:

the detect_record_change section appears under FORM in the book
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Detect-record-change
but it does *not* work with FORM.
Its existence might be missed since there is no mention of it under SQLFORM.

Denes

-- 
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: Why is id field not hiding here at all in the form displaying?

2016-03-30 Thread 'DenesL' via web2py-users
You don't need that script to hide the id, just set the showid param in 
SQLFORM to False.
See the signature of the SQLFORM constructor:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM

Denes


On Wednesday, March 30, 2016 at 4:00:13 PM UTC-4, Jacob Devin wrote:
>
> def screen():
> dpform=SQLFORM(db.info,row.id,fields=['dp']).process()
> return locals()
>
> def delformforscreen():
> row=db(db.info.info_id==auth.user_id).select().first()
> 
> form=SQLFORM(db.info,row.id,fields=['first_name','last_name','dob','sex','hometown',
>  
> 'highschool', 'university', 'oneself']).process()
> return locals()
>
> in view:
> default/delformforscreen.load
> 
> jQuery(document).ready(function(){
>   jQuery('#info_id__row').hide();
> jQuery('#info_id__row').hide();
> });
> 
> {{=form}}
>
> in default/screen.html:
>
> {{extend 'layout.html'}}
> {{=dpform}}
>{{=LOAD('default', 'delformforscreen.load', ajax=True)}}
>
>

-- 
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] checkboxes framework7.io and validate

2016-03-30 Thread 'DenesL' via web2py-users
Hi

while creating some pages with framework7 I noticed that the checkbox 
inputs were not validating.

On a closer look I noticed that they where being submitted as 
checkbox_name[] instead of just checkbox_name.

I tried to fix the issue by replacing the offending vars in request.vars 
with their non-square-bracketed versions but validate seems to work with 
different copy of them.

Has anybody encountered something similar?.

Thanks,
Denes

-- 
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: Print all items from inner join while grouping them

2016-01-24 Thread 'DenesL' via web2py-users
Hi Hermann

You can add an inner loop to each user found by the original code:

for row in db(db.person.id==db.thing.owner_id).select(db.person.id, db.
person.name, count, groupby=db.person.name):
  print row.person.name, row[count]
  for t in db(db.thing.owner_id==row.person.id).select(db.thing.name):
print t.name

Denes


On Saturday, January 23, 2016 at 2:13:36 PM UTC-5, Hermann Tchehoun wrote:
>
> Hi Denes,
> Thanks for your answer. But in your answer, you've removed the "groupby" 
> and the count.
> What I need is to print the 
> - the Owner
> - the quantity of thing owned
> -and the list of these things
>  what you suggest don't give me the number of things.
>
> Is there a way to have all the 3 (owner, number of things, list of thing) 
> at the same time ; i mean something like this:
>
> Alex  2
> Boat
> Chair
> Bob  1
> Shoes
>
>
>

-- 
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 programatically create virtual fields in aliased table

2016-01-24 Thread 'DenesL' via web2py-users

Iif you want virtual fields to show up in a query over a single table they 
have to be defined in that table, otherwise you need to join a table where 
they exist.

The definition of a virtual field needs a name and usually a lambda 
function over fields in a row.
Lets add a virtual field to the auth_user table:

db.auth_user.full_name = Field.Virtual('full_name', lambda row: '%s %s' %(
row.auth_user.first_name, row.auth_user.last_name))

Now everytime you retrieve rows from auth_user, whether directly or via a 
join, they will have a field called full_name.

There are also Method fields which are functions than can be called to 
obtain a value.

db.items.createdbyfullname = Field.Method('createdbyfullname', 
  lambda row: db(db.auth_user.id==row.items.created_by).select()[0].
full_name)

So now, after retrieving rows from item, you can call the row's 
createdbyfullname function to get the full name of the user that created 
the entry.

Note that is over simplified but helps to illustrate the use.

Denes





On Thursday, January 21, 2016 at 5:24:00 PM UTC-5, Oliva Lemke wrote:
>
> hi
>
> i have table
> db.define_table('items', Field('name'), Field('created_by'), 
> Field('modified_by'))
>
> fields `created_by` and `modified_by` has defined relation to 
> db.auth_user.user_id (not auth_user.id)
>
> how to programatically create virtual fields created_by.full_name and 
> modified_by.full_name?
>
>
> lefts = []
> auth_user_fields = ('created_by', 'modified_by')
> for field in auth_user_fields:
> table = db.auth_user.with_alias(field)
> table.full_name = self.db.Field.Virtual('full_name', lambda 
> row, field=field: '%s %s' % (row[field].first_name, row[field].last_name))
> lefts.append(table.on(table.user_id==self.model[field]))
>
> rows = db(db.items).select(left=lefts)
>
> but `rows` in last line contains only fields/columns from `db.items` , 
> aliased `created_by` and `modified_by` `auth_user` table is missing
>
> am i doing something wrong?
>

-- 
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: Print all items from inner join while grouping them

2016-01-23 Thread 'DenesL' via web2py-users
Use orderby:

for row in db(db.person.id==db.thing.owner_id).select(
 db.person.name,db.thing.name, orderby=db.person.name):
 print row.person.name, row.thing.name

Denes


On Saturday, January 23, 2016 at 11:59:59 AM UTC-5, Hermann Tchehoun wrote:
>
> Hello Everyone !
>
> Following this code example in the manual 
> ,
>  
> I can only print the first thing owned by alex when I do "print 
> row.thing.name"
> What to do to have all the thing owned by someone displayed while grouping 
> them ?
>
> db.define_table('person',
> Field('name'),
> format='%(name)s')
> db.define_table('thing',
> Field('name'),
> Field('owner_id', 'reference person'),
> format='%(name)s')
>
> 
> count = db.person.id.count()
> for row in db(db.person.id==db.thing.owner_id).select(
> db.person.name, count, groupby=db.person.name):
> print row.person.name, row[count]
> Alex 2
> Bob 1
>
> 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: Retrieve value of dictionary in field with requires=IS_IN_SET(dictcionary)

2016-01-23 Thread 'DenesL' via web2py-users
web2py will only store the key part (1,2,.. or 5) in the category field.
You have to provide the value part for the key:value pairs.

courses = {1:'Arte',2:'Artigianato',3:'Cucina',4:'sport',5:'informatica'}

db.courses.category.requires = IS_IN_SET(courses, zero='Scegli la categoria'
) # it can be set dynamically

{{=courses[course.category]}}

Note that you have to include the courses dictionary in your return so it 
is available to the view or define it in a model.

Denes

On Saturday, January 23, 2016 at 1:36:02 PM UTC-5, Fabio Ceccarani wrote:
>
> Hi all, 
> I create a field with requires=IS_IN_SET where list of values is a 
> dictionary:
>
> db.define_table('courses',
>   ...
>   Field('category',requires=IS_IN_SET({1:'Arte',2:'Artigianato',3:'Cucina'
> ,4:'sport',5:'informatica'},zero='Scegli la categoria'))
>   ...)
>
>
> In default.py *result* function return result of a query in *courses* 
> variable used by* results.html*.
> In view file *results.html* I retrieve it with:
>
> {{for course in courses:}}
> ...
> {{=course.category}}
> ...
> {{pass}}
>
> but so I can retrieve only key (1,2,3,4,...).
> How can I retrieve values ('Arte','Artigianato',...)?
>
> Thanks
> Fabio
>
>

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


[web2py] Re: Use auto complete without SQL

2016-01-18 Thread 'DenesL' via web2py-users
Hello Seraaj

1) You can still use SQLFORM if you want, just preset the widget and use 
the fields parameter of SQLFORM to filter:

def someaction():
  db.table.fieldX.widget = SQLFORM.widgets.autocomplete(request, ...)
  form = SQLFORM(db.table, fields=['fieldX',], ...)
  if form.validate():
# do something with the form's data


or you can use SQLFORM.factory:

 form = SQLFORM.factory( db.table.fieldX.clone(...) )

2) Set the default for the is_default field to False 
and check if there is a record in the db with is_default==True and a 
different id that the current insert/update in the accepted portion of your 
form processing, and set it to False.

Denes. 

On Sunday, January 17, 2016 at 6:33:56 PM UTC-5, Seraaj Muneer wrote:
>
> Hello everyone from Accra Ghana.
>
> I've a small issue I'm not sure how to go about.
>
> I've a number of companies in the database. What I want to do is create a 
> form with just a select field containing the companies in the database, and 
> naturally a submit button to post the form to a controller. How do I use 
> the Autocomplete widget outside of SQLForm? Is it even possible? If not, 
> how do I represent the list of companies in HTML in a way that the user 
> will not have to scroll endlessly to select a company as would be the case 
> with a traditional HTML select? 
>
> Also every company entity in the database has a boolean field, 
> 'is_default', now how do I make sure only one company has 'is_default' set 
> to True? So all others have it as False? Also if upon inserting or updating 
> a company, the new or updated record has 'is_default' set to True, then I 
> want to set that of all other companies as False. 
>
>
>
>
> 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: how to import_from_csv or export_to_csv without primary key

2016-01-17 Thread 'DenesL' via web2py-users
The concept is applicable to any number of tables.
Tables store the names of their fields in db.table.fields so you can create 
a copy of that without the id field (or any other(s)) an use it to select 
the rows in your program.

Denes


On Sunday, January 17, 2016 at 1:20:10 PM UTC-5, Alex Glaros wrote:
>
> sorry Denes, I forgot to explain that I'm migrating to Postgres and doing 
> all tables at once.  Would like to automate the ."id" removal.  Any ideas 
> on that?
>
> for table in db.tables: 
> rows = db(db[table]).select()
> table_name =  str([table]) + '.csv'
> rows.export_to_csv_file(open(table_name, 'wb'))
>
> thanks
>
> Alex
>

-- 
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: Length and requires is not null together

2016-01-17 Thread 'DenesL' via web2py-users
When you need several validators on a field you create a list of them:

... requires=[ IS_NOT_EMPTY(), IS_LENGTH(50) ]

Denes

On Sunday, January 17, 2016 at 4:22:38 PM UTC-5, Alessio Varalta wrote:
>
> Hi I have a problem with filed and validate
>
> 
> Field('nome',),type="string",length=50,requires=IS_NOT_EMPTY()),
> I generate a sqlform grid and when i add new element and try to compile 
> requires is not empty work but not length=50 if i eliminate requires is not 
> empty i have that length work...How does to have the two controll together?
>
> I have another important question, If I send the data throught Javascript 
> and insert this data with a query for example 
> db(db.nome.id=2).insert(nome=request.vars.nome) 
> there is a exception if the user insert too text?
>

-- 
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: Edit form style

2016-01-17 Thread 'DenesL' via web2py-users
The 3 at the end is calculated in the _inner function of the 
formstyle_bootstrap3_inline_factory function in sqlhtml.py (around line 909 
in 2.12.03).

Denes 

On Friday, January 15, 2016 at 4:41:33 AM UTC-5, desta wrote:
>
> I would like to make a change a the Login form.
> Currently I see that the login button has a slight offset which I like to 
> remove
>
> 
>   
> 
>
> I tried to search for *col-sm-offset-3 *to find where the form is 
> generated but I could only find .css files where the style is defined. I 
> searched in the gluon/sqlhtml.py but again I couldn't find how to edit 
> this. Where are those divs generated?
>
> 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: best advice on customer/client picklist popup.

2016-01-17 Thread 'DenesL' via web2py-users
How about using an autocomplete?
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Autocomplete-widget

Denes

On Sunday, January 17, 2016 at 9:54:32 AM UTC-5, lucas wrote:
>
> oh, i forgot to mention, that i know how to do an ajax query and pass post 
> variable to it using web2py.  i don't know the best javascript/jQuery 
> method for creating and displaying the proper HTML code and 
> inputs/buttons/and such, and then pass the result back to the main parent 
> page.
>

-- 
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 import_from_csv or export_to_csv without primary key

2016-01-17 Thread 'DenesL' via web2py-users
Since the export_to_csv_file acts on a rows object you can select the 
fields to your liking.

rows = db(qry).select(*list_of_fields_to_export)
rows.export_to_csv_file(open(...))

Denes

On Saturday, January 16, 2016 at 11:27:18 PM UTC-5, Alex Glaros wrote:
>
> is there a way to import_from_csv without primary key from the old 
> system, or export_to_csv without the primary key?
>
> otherwise, I have to edit the file in excel and delete the primary key 
> column before importing the file
>
> thanks
>
> Alex Glaros
>
>
>

-- 
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: AttributeError: 'Table' object has no attribute '_primarykey'

2016-01-13 Thread 'DenesL' via web2py-users
Which web2py version is that?.
Not sure when objects.py was fixed but the fix is there in 2.12.03 for sure.

Regards,
Denes

On Wednesday, January 13, 2016 at 8:49:34 AM UTC-5, Manuele wrote:
>
> Hi *, 
> I got this strange error. Where I have to look for the cuase? 
> The table object of my query is defined by: 
>
> # Note: defined as class parameter 
> table = Table(None, table_name, 
> Field("uuid", unique=True, default=lambda: web2py_uuid()), 
> Field("service", required=True), 
> Field("command", required=True), 
> Field("args", 'json', default={}), 
> Field("status", default="QUEUED", 
> requires=IS_IN_SET(task_states)), 
> Field("command_output", 'json'), 
> Field("start_time", "datetime"), 
> Field("end_time", "datetime"), 
> Field('created_on', 'datetime', default=current.request.now), 
> Field('updated_on', 'datetime', update=current.request.now), 
> Field('created_by', 'integer'), 
> Field('updated_by', 'integer'), 
> ) 
>
> and 
>
> self.db.define_table(self.table_name, self.table) 
>
> and the exception (cited below) is raides calling the method: 
> validate_and_update_or_insert 
>
> --- 
>
> AttributeErrorTraceback (most recent call 
> last) 
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/models/utils.py
>  
>
> in () 
> > 1 iproot.queue_task("noproot", "test") 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in queue_task(self, service, command, force_new, **args) 
> 301 command = command, 
> 302 status = "QUEUED", 
> --> 303 args = args 
> 304 ) 
> 305 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in wrapper(self, *args, **vars) 
>  94 def wrapper(self, *args, **vars): 
>  95 self.db[self.table_name].args.requires = [] 
> ---> 96 return func(self, *args, **vars) 
>  97 return wrapper 
>  98 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in __validate_and_update_or_insert(self, query, commit, **vars) 
> 254 res = 
> self.db[self.table_name].validate_and_update_or_insert( 
> 255 query, 
> --> 256 **vars 
> 257 ) 
> 258 if commit: self.db.commit() 
>
> /home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in 
> validate_and_update_or_insert(self, _key, **fields) 
> 817 response = self.validate_and_update(_key, **fields) 
> 818 primary_keys = {} 
> --> 819 for key in self._primarykey: 
> 820 primary_keys[key] = getattr(record, key) 
> 821 response.id = primary_keys 
>
> /home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in 
> __getitem__(self, key) 
> 514 return self._db(self._id == key).select(limitby=(0, 
> 1), orderby_on_limitby=False).first() 
> 515 elif key: 
> --> 516 return ogetattr(self, str(key)) 
> 517 
> 518 def __call__(self, key=DEFAULT, **kwargs): 
>
> AttributeError: 'Table' object has no attribute '_primarykey' 
>
>
> Thanks a lot 
>
> Manuele 
>

-- 
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: Changing navbar color

2016-01-03 Thread 'DenesL' via web2py-users
You could add the following to the end of web2py-bootstrap3.css

.navbar {
  background-color: #963;
  background-image: none;
}



On Wednesday, December 16, 2015 at 8:10:22 PM UTC-5, Joe wrote:
>
> I am trying to change the background-color of the nav bar in the newest 
> web2py bootstrap 3 version.
>
> In the previous version I was able to change it in web2py_bootstrap.css 
> section "other rules" but that doesn't seem to work in 
> web2py_bootstrap3.css where there is no "other rules" section.
> I have tried just about everything I could think of in 
> web2py_bootstrap3.css but I didn't succeed. Obviously, I am missing 
> something.
>
> Any help would be appreciated.
>
> Thanks.
>
> Cheers,
>
> Joe
>
>

-- 
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: SQLFORM.smartgrid with two references to same perent table

2016-01-03 Thread 'DenesL' via web2py-users

I see no way of blocking it in the source code.
You could hide it using JS, something like:

$('.row_buttons > a:nth-child(3)').addClass('hidden')




On Friday, December 25, 2015 at 11:37:54 PM UTC-5, Jose Eleudson Gurgel 
Queiroz wrote:
>
>
> *With this tables:*
> db.define_table('tbProduct', \
> Field('category_id','reference tbCategory', 
> label='Category', ondelete='RESTRICT'), \
> Field('group_id', 'reference tbGroup', label='Group', 
> ondelete='RESTRICT'), \
> Field('name', 'string', notnull=True, unique=True), \
> ...
>)
> db.define_table('tbComposition', \
> 
> *Field('product_id','reference tbProduct', label='Product', 
> writable=False), \Field('component_id','reference 
> tbProduct', label='Component', ondelete='RESTRICT'), \*
> Field('unit_id','reference tbUnit', label='Unit', 
> ondelete='RESTRICT'), \
> Field('quantity','double', notnull=True, 
> default=0.00), \
> singular='Composition', plural='Compositions' \
>)
>
> *In the stock.py controller I have:*
>
> def products():
> form=SQLFORM.smartgrid(db.tbProduct, csv=False, maxtextlength=50, 
> showbuttontext=False, \
>linked_tables=[*'tbComposition'*,'tbCostPrice'], 
> links_in_grid=False)
> return locals()
>
> *Thus, I have on the product screen view the following links:*
>
> Compositions(product_id)  
> Compositions(component_id)
> 
>
> Cost
>  
> Prices 
> 
>
> *But I did not want* 
>
>
> *Compositions link (component ID)What do I do?*
>

-- 
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: Selecting whole record with MIN query

2016-01-02 Thread 'DenesL' via web2py-users
You could do

db(db.people.city == "London").select(orderby=db.people.age).first()
>



On Saturday, January 2, 2016 at 8:12:31 AM UTC-5, UG wrote:
>
> Hi,
>
> If i have the following table 
> ID
> fist_name
> last_name
> city
> age
>
>
> I use the MIN to find the lowest age
>
> youngest = db(db.people.city == 
> "London").select(db.people.age.min()).first()
>
> This will only give me the lowest age in the city. Is there a way to get 
> the complete record in the first query without having to resort to a second 
> query like 
>
> result = db(db.people.age == youngest & db.people.city == 
> "London").select()
>
> 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: Dynamically create table from user

2016-01-02 Thread 'DenesL' via web2py-users
Yes you can.
Just think how web2py works to satisfy a user request, all models in the 
action's path are executed every time and everything is a python program.

So if you have a form that requests field_name, field_type and other 
parameters as necessary you can write to a model file the appropriate 
comands to define your table.
Note that if you use SQLite it does not change field types on the fly so 
you have to delete the whole table and redefine it from scratch.
Other DBs can cope with such changes.

Obviously you need to track which fields have been created but that info is 
available in db.table_name.fields


On Saturday, January 2, 2016 at 8:12:31 AM UTC-5, BIDUR G.C wrote:
>
> Hi All,
>
> I have a specific question. Is it possible to dynamically create table 
> from user interface. I am thinking of something like allowing user to write 
> the name of the column, adding label and assigning field type to it.
>
> Any hint on getting started would be much appreciated.
>
> Many Thanks,
> Bidur
>

-- 
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: online exam application with web2py

2016-01-02 Thread 'DenesL' via web2py-users
1) See third example in 
http://web2py.com/books/default/chapter/29/05/the-views#INPUT 

2) You could use an onchange on the question number field to call the 
create question action with the updated question number as a parameter.

3) Yes, see 
http://web2py.com/books/default/chapter/29/04/the-core#Internationalization--and-Pluralization-with-T

On Sunday, December 20, 2015 at 3:04:50 AM UTC-5, 黄祥 wrote:
>
> hi,
>
> i plan to create an online exam application with web2py (please see 
> attached file), but have the problems :
> 1. in the attached file created question.jpg it seems the answer choice is 
> build using varchar or string (in DAL) data type, but in the exam.jpg, it 
> appears in radio button. how can i create it using web2py way?
> 2. how can i create the list of question number in drop down form field so 
> that the student can skip or back to the question number they desire? (like 
> in exam.jpg 'Menuju Soal' ?)
> 3. is it possible to have the question in japanese language character 
> (hiragana, katakana n kanji)? how to set the database and application to 
> support japanese language?
>
> i've seen the pyodel and examportal example but, still can't get the 
> enlightment for what i face right now. any idea or way out to solve it 
> using web2py way?
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: Problem with Field UNIQUE when i'll edit

2016-01-02 Thread 'DenesL' via web2py-users

Your params dictionary should only contain what is being updated (except 
for id which can be there too).

params = { 'name': 'pepe', 'id': 1 } # ok

params = { 'name': 'pepe' } # ok

params = { 'name': 'pepe', 'id': 1 , 'email': '...'} # error


In your case use the first since you are selecting the record using 
params['id'].




On Thursday, December 10, 2015 at 3:58:53 PM UTC-5, 
argenio.bosa...@metamaxzone.com wrote:
>
> I have one table in my mysql db with name "users" with this:
> id - name - email
> 1 - luis - exam...@gmail.com
> 2 - steff - he...@gmail.com
>
> the field email is unique in the DAL 
> Field('email', 'string', length=255, required=True, notnull=True, 
> unique=True),
>  
>
> when i try to edit the form, I only change my name, but the email it's the 
> same, ok perfect,
> I send 2 parameters, name is diferent and email it's the same in this case 
> in the bd.
> id: 1, name: pepe, email: exam...@gmail.com
>
> result = db(db.users.id == 
> params["id"]).validate_and_update(**db.users._filter_fields(params)).as_dict()
>
> i search the register with the id, perfect, but when "update the email" i 
> got the error
>
>  (1062, u"Duplicate 
> entry ' exam...@gmail.com' for key 'email_UNIQUE'")
>
> because "exam...@gmail.com exist in the databases BUT exist in the 
> register where I UPDATE, and I send the SAME value because don't change the 
> email
>
> maybe you reply if don't have change the register, delete the params and 
> don't send to DAL and when change send it.
> that's it's not a good practice, because when i really change the email 
> get code innecesary. and I need detecte the change in front page, (ios, 
> andriod, web, etc) 
>
> now, how can i solved my problems? 
>
> I have one solutions but i don't like:
> search the register in DB, read the field email and is the same delete 
> params and dont send to insert and it's diferente send.
> BUT that generate one petition aditional to the server
>
> summarized: I check manually the unique in db.
>
> Please I need help, thx very much
> note: I dont talk good the english.
>
>
>
>
>

-- 
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: st_dwithin

2015-12-05 Thread 'DenesL' via web2py-users

Not with the current sources but they can be modified.
You can always use executesql to run a SQL command.
The actual command depends on what you are doing.

If you are running from source, modifying it is not that hard.
In \gluon\packages\dal\pydal\objects.py replace (at line 1328 in 
ver.2.12.03)
def st_dwithin(self, value, distance):
db = self.db
return Query(db, db._adapter.ST_DWITHIN, self, (value, distance))

with
def st_dwithin(self, value, distance, use_spheroid=True):
db = self.db
return Query(db, db._adapter.ST_DWITHIN, self, (value, distance, 
use_spheroid))

and in \gluon\packages\dal\pydal\adapters\postgres.py replace (at line 325)
def ST_DWITHIN(self, first, tup):
"""
http://postgis.org/docs/ST_DWithin.html
"""
second, third = tup
return 'ST_DWithin(%s,%s,%s)' %(self.expand(first),
self.expand(second, first.type),
self.expand(third, 'double'))

with
def ST_DWITHIN(self, geo1, tup):
"""
http://postgis.org/docs/ST_DWithin.html
"""
geo2, dist, use_spheroid = tup
if use_spheroid:
return 'ST_DWithin(%s,%s,%s)' %(self.expand(geo1),
self.expand(geo2, geo1.type),
self.expand(dist, 'double'))
else:
return 'ST_DWithin(%s,%s,%s,%s)' %(self.expand(geo1),
self.expand(geo2, geo1.type),
self.expand(dist, 'double'),
self.expand(False, 'boolean'))

If you or someone else is willing to test the changes we can add them to 
the next version.

Denes

On Monday, November 16, 2015 at 8:40:21 AM UTC-5, Pierre wrote:
>
> Hi,
>
> I'd like to specify use_spheroid=False when calling web2py function 
> st_dwithin 
>
> postgis ref :
> boolean *ST_DWithin*(geography gg1, geography gg2, double precision 
> distance_meters, boolean use_spheroid);
>
>  Is it possible ?
>
>
> if not can can I achieve it with  executesSQL ?
>

-- 
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: DAL equivalent of Field1 * 2 as MyComputedField

2015-12-05 Thread 'DenesL' via web2py-users

You could but it is available in rows.colnames

Note that you can define a virtual field

db.MyDatabase.MyComputedField = Field.Virtual('MyComputedField', lambda r: r
.MyDatabase.Value*2)

and then access it via row.MyComputedField for any row in rows.

Denes


On Saturday, December 5, 2015 at 11:11:00 AM UTC-5, Henk Hendricks wrote:
>
> On 2015-12-04 5:05 , Massimo Di Pierro wrote:
>
> x = db.MyDatabase.Value*2
> rows = db(db.MyDatabase.Value).select(x)
> print rows[0][x]
>
> Ok, thanks that should perfectly in my controller.
>
> But does this mean that if I want to use this my view, that I need to 
> transfer 'x', to select correct field from a row?
>
>
> -- 
> Greetings,
>
> Henk Hendricks
>
>

-- 
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 use fancytree?

2015-12-02 Thread 'DenesL' via web2py-users

Hi, assuming that the paths to the js & css files are correct you are 
missing the closing of $(function(){ in your script.
Just duplicate the last line at the very end, i.e. add });

Denes

On Tuesday, December 1, 2015 at 12:03:01 AM UTC-5, Henk huisman wrote:
>
> Fancytree looks to me as a nice javascript library to generate trees (
> https://github.com/mar10/fancytree/wiki).
> Unfortunatily I don't get it to work in Web2py.
>
> I just installed the libraries etc and copied some code from the examples 
> websites, but the function fancytree doesnothing.
>
> This is the code I tried:
>
> 
> 
> 
> Fancytree - Example: Select
>  "{{=URL('static','fancytree/dist/skin-lion/ui.fancytree.min.css')}}"/>
>  "text/javascript">
>  "text/javascript">
>  "{{=URL('static','fancytree/dist/jquery.fancytree-all.min.js')}}"
> >
>
>
> 
>   var treeData = [
> {title: "item1 with key and tooltip", tooltip: "Look, a tool tip!" },
> {title: "item2: selected on init", selected: true },
> {title: "Folder", folder: true, key: "id3",
>   children: [
> {title: "Sub-item 3.1",
>   children: [
> {title: "Sub-item 3.1.1", key: "id3.1.1" },
> {title: "Sub-item 3.1.2", key: "id3.1.2" }
>   ]
> },
> {title: "Sub-item 3.2",
>   children: [
> {title: "Sub-item 3.2.1", key: "id3.2.1" },
> {title: "Sub-item 3.2.2", key: "id3.2.2" }
>   ]
> }
>   ]
> },
> {title: "Document with some children (expanded on init)", key: "id4", 
> expanded: true,
>   children: [
> {title: "Sub-item 4.1 (active on init)", active: true,
>   children: [
> {title: "Sub-item 4.1.1", key: "id4.1.1" },
> {title: "Sub-item 4.1.2", key: "id4.1.2" }
>   ]
> },
> {title: "Sub-item 4.2 (selected on init)", selected: true,
>   children: [
> {title: "Sub-item 4.2.1", key: "id4.2.1" },
> {title: "Sub-item 4.2.2", key: "id4.2.2" }
>   ]
> },
> {title: "Sub-item 4.3 (hideCheckbox)", hideCheckbox: true },
> {title: "Sub-item 4.4 (unselectable)", unselectable: true }
>   ]
> },
> {title: "Lazy folder", folder: true, lazy: true }
>   ];
>   $(function(){
> $("#tree1").fancytree({
>   checkbox: true,
>   selectMode: 1,
>   source: treeData,
>   activate: function(event, data) {
> $("#echoActive1").text(data.node.title);
>   },
>   select: function(event, data) {
> // Display list of selected nodes
> var s = data.tree.getSelectedNodes().join(", ");
> $("#echoSelection1").text(s);
>   },
>   dblclick: function(event, data) {
> data.node.toggleSelected();
>   },
>   keydown: function(event, data) {
> if( event.which === 32 ) {
>   data.node.toggleSelected();
>   return false;
> }
>   }
> });
> 
> 
>
>
> 
>   Example: Selection and checkbox
>
>
>   
>
>   Active node: -
>   Selection: -
>
>
> 
>
>
> 
>
> The controller is  just same name as the view and returns a dict which is 
> not used anyway in the view.
>
> The view loads and what you see is:
>
> Example: Selection and checkbox
>
> Active node: -
> Selection: -
>
> 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: () appadmin

2015-11-06 Thread 'DenesL' via web2py-users
Without trying out the code I think the problem is the invalid format 
string.
format = '%(partenza,partenza)s'

In a format string each variable is formatted separately as in
format = '%(partenza)s,%(partenza)s'

Look up "String Formatting Operations" in the Python manual for full 
details.

By the way, these lines are duplicated in your code
db.esercizio_consorzio.id.readable = False
db.esercizio_consorzio.id.writable = False

maybe you want the second set to be
db.esercizio.id.readable = False
db.esercizio.id.writable = False


Denes

On Friday, November 6, 2015 at 5:40:13 AM UTC-5, Alessio Varalta wrote:
>
> Hi I have two table and I don't understand because I received a error when 
> I enter in appadmin/esercizio...I use sqlite and I try to download the Csv 
> of esercizio table and the csv is correct..the application work fine, but 
> when I try to enter esercizio I received this error(see below the 
> table)..Thanks in advance, I have no idea
>
> db.define_table('esercizio_consorzio',
> 
> Field('partenza',type='date',requires=IS_DATE(str(T('%d-%m-%Y',
> 
> Field('finale',type='date',requires=IS_DATE(str(T('%d-%m-%Y',
> Field('stato',type='boolean',requires=IS_NOT_EMPTY()),
> format = '%(partenza,partenza)s'
>
> )
> db.esercizio_consorzio.id.readable = False
> db.esercizio_consorzio.id.writable = False
>
>
>
> db.define_table('esercizio',
> Field('inviato',type='boolean',requires=IS_NOT_EMPTY()),
> Field('user_id','reference 
> auth_user',requires=IS_NOT_EMPTY(),readable=False,writable=False),
> Field('esercizio_consorzio','reference 
> esercizio_consorzio',requires=IS_NOT_EMPTY(),readable=False,writable=False),
>
> )
> db.esercizio_consorzio.id.readable = False
> db.esercizio_consorzio.id.writable = False
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File "/home/www-data/web2py/applications/coop/views/appadmin.html" 
> , line 
> 191, in 
> {{pass}}
>   File "/home/www-data/web2py/gluon/sqlhtml.py", line 3252, in __init__
> r = A(represent(field, r, record), _href=str(href))
>   File "/home/www-data/web2py/gluon/sqlhtml.py", line 68, in represent
> return f(value)
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/helpers/methods.py", 
> line 265, in __call__
> return value if value is None else _fieldformat(self.ref, value)
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/helpers/methods.py", 
> line 253, in _fieldformat
> return r._format % row
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 76, 
> in __getitem__
> raise KeyError
> KeyError
>
>
>

-- 
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: cannot disable automatic login after registration

2015-10-25 Thread 'DenesL' via web2py-users

There are more settings to play around with and the book is not always up 
to date with source code changes.
With that in mind I always check the source to see how it works when I am 
having trouble.
The registration process and how it uses those settings is located in 
gluon/tools.py around line 2944 (web2py 2.12.03).
If the way it is coded does not suit you can open an issue in github.

But why create a user account that might need to be deleted?. You seem to 
be trying to handle the situation in a roundabout way.
How about using onvalidation to check all your fields before creating the 
user?.


On Sunday, October 25, 2015 at 6:29:12 AM UTC-4, Pierre wrote:
>
> Yes ok but this is not what I want :
>
>
> extracted from web2py book:
>
> "
>
> If you want to allow people to register and automatically log them in 
> after registration but still want to send an email for verification so that 
> they cannot login again after logout, unless they completed the 
> instructions in the email, you can accomplish it as follows:
>
> auth.settings.registration_requires_verification = True
> auth.settings.login_after_registration = True
>
> "
> here is the problem :
> I added some extra fields to auth_user to provide geolocation data howewer 
> I cannot predict "geolocation user acceptance" so my idea was to simply 
> delete the user account in case geolocation is refused. but this cannot be 
> done since new user is logged in automatically (he cannot log out if his 
> account is deleted). Now I think about a different strategy using 
> permissions and roles like "cannot login till geolocation data provided". 
> This seems like a lot of complexity to solve a simple task ?
>
> Le dimanche 25 octobre 2015 03:55:34 UTC+1, DenesL a écrit :
>>
>>
>> You also need
>>
>> settings.registration_requires_verification = True
>>
>>
>>
>> On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>>>
>>> Hi everyone,
>>>
>>> I tried to do it with no success with this:
>>>
>>> auth.settings.login_after_registration = False
>>>
>>> thanks for your help
>>>
>>>

-- 
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: Appconfig - what's the best way to handle missing values

2015-10-24 Thread 'DenesL' via web2py-users

from gluon.contrib.appconfig import AppConfig
myconfig = AppConfig('/private/appconfig.ini', reload=False)

does not cause an exception even when loading the default ini below, which 
has an empty value (last one):
; App configuration

; db configuration
[db]
uri   = sqlite://storage.sqlite
migrate   = 1
pool_size = 1

; smtp address and credentials
[smtp]
server = smtp.gmail.com:587
sender = y...@gmail.com
login  = username:password


; form styling
[forms]
formstyle = bootstrap3_inline
separator =

Can you post an example of what you are doing and the error?.

Denes



On Saturday, October 24, 2015 at 8:31:45 PM UTC-4, Donald McClymont wrote:
>
> I like the appconfig file approach however I am not clear if there is a 
> recommended approach to handling missing values in the file.  It seems 
> reasonable and convenient that you might want to update the code and the 
> appconfig separately and use a default value if the key isn't present. 
>  However at present a missing value seems to raise a BaseException error 
> which isn't ideal for try... except type structures.
>
> Can someone recommend how to handle or if this situation should just be 
> avoided?
>

-- 
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 check if my user's profile is complete in web2py?

2015-10-24 Thread 'DenesL' via web2py-users

Try 
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation
 
the example is pretty clear.


On Saturday, October 24, 2015 at 8:28:15 PM UTC-4, Upendra Kumar wrote:
>
> I have made a 'user_details' table whose 'user_id' field I have referenced 
> to default 'auth_user' table. Now after registration, I show the user his 
> profile and ask him to complete it. But, the problem is that how can I 
> check if the profile is complete or not after the user submits the updated 
> profile.
>
> Here is my user_details table,
>
> db.define_table('user_details',
> Field('user_id'),
> Field('gender',requires=IS_IN_SET(['Male','Female','Other'])),
> Field('phone_number',requires=IS_MATCH('\d{10}')),
> Field('preferred_mess'),
> Field('preferred_caterer'),
> Field('state_name','string'),
> Field('account_initial_balance'),
> Field('account_curr_balance'),
> Field('your_booking_preference',requires=IS_IN_SET(['''Don't Book Food 
> Automatically''','Book Food Automatically'])))
>
>
>
>

-- 
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: Newby question about referencing fields in a lookup table

2015-10-24 Thread 'DenesL' via web2py-users

The second argument of IS_IN_DB should be the key to the reference.
And the third should be a format string to represent that key.

So your models should look something like
db.define_table('t_itemtypes',
Field('f_itemtypedesc_string', 'string'),
)
db.define_table('t_items',
Field('f_itemname_string', type='string', notnull=True, label=T(
'ItemName')),
Field('f_itemtype', type='reference t_itemtypes', label=T('ItemType')),
  requires=IS_IN_DB(db, 't_itemtypes.id', 
'%(f_itemtypedesc_string)s')
)



On Saturday, October 24, 2015 at 8:31:27 PM UTC-4, Bill Lugg wrote:
>
> I am vary new to Web2py and am very impressed with what I see so far.  I 
> come from a MS Access background and am looking for an easy way to develop 
> small db applications in similar fashion and offering some of the same 
> features that are offered in Access, but without the proprietary chains 
> that MS imposes.
>
> I've been experimenting with a simple inventory app and I have a situation 
> where I have some lookup tables that I want to reference in my main item 
> form.  In my first attempt, the lookup table contains an integer item type 
> and a string item type description.  I'd like the main form to display the 
> descriptions, but store either a link or a copy of the integer item type in 
> the items table (at this point I'm not too picky).  FWIW, I used the wizard 
> to generat the application to start.
>
> Here's the code as I modified it to display the item type description in 
> the items form:
>
> db.define_table('t_items',
> Field('f_itemname_string', type='string', notnull=True,
>   label=T('Itemname String')),
> Field('f_itemtype', type='reference t_itemtypes',
>   requires=IS_IN_DB(db, 't_itemtypes.f_itemtype', 
> 't_itemtypes.f_itemtypedesc_string'),
>   label=T('Itemtype')),
>
>
> This works, but when I insert a record I get the following error:
> e IntegrityError('FOREIGN KEY constraint failed',)
>
> Looking at the arguments up the stack a bit, it appears to be trying to 
> put an integer in for the item type so I'm a little stumped as to what 
> might be wrong.  I wonder if someone might be able to point me in the right 
> direction as I will want to do this with a couple of other fields as well.
>
> In addition, I have a couple of integer fields that I want to make a fixed 
> list from 1 to 4, inclusive.  I was going to use the requires=IS_IN_SET 
> construct for this; am I headed in the right direction?
>
> Thanks for the help with this.
>
> Bill Lugg
>

-- 
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 intended that TABLE(rows) makes a table within a table?

2015-10-24 Thread 'DenesL' via web2py-users

You can do
SQLTABLE(rows, _class="fred")



On Saturday, October 24, 2015 at 5:29:17 PM UTC-4, Edward Shave wrote:
>
> Thanks Anthony,
>
> The reason I was trying TABLE was because I wanted to include a class in 
> the table tag and was thinking this might work...
>
> TABLE(rows, _class="fred")
>
> taking account of your answer I'm now using...
>
> table_as_string = ''+rows.xml(0)[7:]
>
>

-- 
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: cannot disable automatic login after registration

2015-10-24 Thread 'DenesL' via web2py-users

You also need

settings.registration_requires_verification = True



On Saturday, October 24, 2015 at 8:30:52 PM UTC-4, Pierre wrote:
>
> Hi everyone,
>
> I tried to do it with no success with this:
>
> auth.settings.login_after_registration = False
>
> thanks for your help
>
>

-- 
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 provide feedback on button in LINKS section of sqlform.grid ?

2015-10-15 Thread 'DenesL' via web2py-users
Change that to

  el.text = "Working...";





On Sunday, October 11, 2015 at 4:20:58 AM UTC-4, Gary Cowell wrote:
>
> Hello. 
>
> I'm trying to give the user some feedback when they click on a links (link 
> button) in the links section of a sqlform grid.
>
> I have this button code:
>
>button = A(
> SPAN(_class="icon play icon-play glyphicon glyphicon-play")
> ,"Start"
> ,_id="startstop"
> ,_class="button btn btn-success"
> ,_title="Start"
> ,_onclick="return change(this);"
> ,_href=URL("dynamic","startstop",
> args=[system.id, buttonURL, buttonTitle, db.e5system] , 
> user_signature=True )
> )
>
>
> And this script in my view:
>
> 
> function change( el )
> {
> el.value = "Working...";
> }
> 
>
>
> But nothing happens when I click the button.
>
> I've tried many bits of javascript over the last few days and I'm getting 
> nowhere fast.
>
> Can someone kindly give me a steer on what to do ?
>
> 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: class being inserted behind my back..!

2015-10-11 Thread 'DenesL' via web2py-users
The btn-default class is added by web2py-bootstrap3.js via
$('button', target).addClass('btn btn-default');

The "horrible" part comes from this bit in bootstrap-theme.min.css
text-shadow: 0px 1px 0px white;

Denes

On Sunday, October 11, 2015 at 4:58:01 AM UTC-4, Edward Shave wrote:
>
> Nope, that's the whole thing running in a new simple application.
> I did this so as to eliminate anything else in my code.
>
> The controller is simply...
>
> def index():
> return dict()
>
>
> On Sunday, October 11, 2015 at 9:51:16 AM UTC+1, Leonel Câmara wrote:
>>
>> Are you getting this result via ajax?
>>
>

-- 
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: auth.requires_login redirect and session expiration

2015-10-10 Thread 'DenesL' via web2py-users

Status 401 is more appropriate since session has expired and the user is 
not authenticated.
Ajax or no ajax.

But we should return 403 when the user is authenticated and the request 
authorization fails for a component.

Do you agree with the following table?.
USER = is authenticated
COMP = current.request.ajax and current.request.cid 
RCR = raise or call/redirect

USER  COMP  RCR
  F F   401/otherwise
  F T   401
  T F   403/otherwise
  T T   403 
 
Denes

On Friday, October 9, 2015 at 11:26:42 PM UTC-4, Massimo Di Pierro wrote:
>
> Shouldn't we always return 403 is ajax?
>
> On Friday, 9 October 2015 12:22:52 UTC-5, DenesL wrote:
>>
>> Changing
>> if current.request.ajax:
>> raise HTTP(401, self.messages.ajax_failed_authentication)
>>
>> to
>> if current.request.ajax and current.request.cid:
>> raise HTTP(401, self.messages.ajax_failed_authentication)
>>
>> in gluon/tools/Auth class/requires function (line 3749 in release 2.12.03)
>> seems to solve the problem since it verifies it is a component before 
>> raising a 401, else it follows the "otherwise" or 
>> auth.settings.on_failed_authorization redirect (which I am using).
>>
>> Denes.
>>
>>
>>
>>
>> On Tuesday, October 6, 2015 at 1:50:04 PM UTC-4, DenesL wrote:
>>>
>>> Hi
>>>
>>> an expired session becomes empty but this does not seem to always 
>>> trigger auth.requires_login redirection to the login URL neither when set 
>>> via auth.requires_login(loginURL), aka the otherwise parameter, nor by 
>>> auth.settings.on_failed_authorization = loginURL *when XMLHttpRequest 
>>> (XHR) is used.*
>>> Actually the otherwise parameter is superfluous in this case.
>>>
>>> Status 401 UNAUTHORIZED with response
>>> NOT 
>>> AUTHORIZEDPlease login to view this content.
>>> but that is never seen since I am using www.idangero.us/framework7 , 
>>> which loads all links with Ajax by default, does not refresh the page.
>>>
>>> So this probably happens because the call is being treated as a 
>>> component by web2py.
>>> I can get around this by defining the links as external in framework7 
>>> but I wonder if it would not be better to have a way to tell web2py to 
>>> redirect when the session has expired even when using Ajax calls.
>>>
>>> Thanks,
>>> Denes
>>>
>>>

-- 
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: auth.requires_login redirect and session expiration

2015-10-09 Thread 'DenesL' via web2py-users
Changing
if current.request.ajax:
raise HTTP(401, self.messages.ajax_failed_authentication)

to
if current.request.ajax and current.request.cid:
raise HTTP(401, self.messages.ajax_failed_authentication)

in gluon/tools/Auth class/requires function (line 3749 in release 2.12.03)
seems to solve the problem since it verifies it is a component before 
raising a 401, else it follows the "otherwise" or 
auth.settings.on_failed_authorization redirect (which I am using).

Denes.




On Tuesday, October 6, 2015 at 1:50:04 PM UTC-4, DenesL wrote:
>
> Hi
>
> an expired session becomes empty but this does not seem to always trigger 
> auth.requires_login redirection to the login URL neither when set via 
> auth.requires_login(loginURL), aka the otherwise parameter, nor by 
> auth.settings.on_failed_authorization = loginURL *when XMLHttpRequest 
> (XHR) is used.*
> Actually the otherwise parameter is superfluous in this case.
>
> Status 401 UNAUTHORIZED with response
> NOT 
> AUTHORIZEDPlease login to view this content.
> but that is never seen since I am using www.idangero.us/framework7 , 
> which loads all links with Ajax by default, does not refresh the page.
>
> So this probably happens because the call is being treated as a component 
> by web2py.
> I can get around this by defining the links as external in framework7 but 
> I wonder if it would not be better to have a way to tell web2py to redirect 
> when the session has expired even when using Ajax calls.
>
> Thanks,
> Denes
>
>

-- 
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: auth.requires_login redirect and session expiration

2015-10-07 Thread 'DenesL' via web2py-users

Thanks for your reply but those setting do not fix the issue, maybe because 
it is not a web2py component.


On Wednesday, October 7, 2015 at 12:42:08 PM UTC-4, Leonel Câmara wrote:
>
> This should fix it:
> auth.settings.client_side=True
>
> You may want to set login_next too.
>

-- 
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: auth.requires_login redirect and session expiration

2015-10-07 Thread 'DenesL' via web2py-users
Original post edited with new info.

-- 
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: auth.requires_login redirect and session expiration

2015-10-07 Thread 'DenesL' via web2py-users

Links on the client trigger XHR calls already.
I had those settings in a model so I am pretty sure they were set before 
any controller code.


On Wednesday, October 7, 2015 at 1:41:57 PM UTC-4, Leonel Câmara wrote:
>
> That's weird it should fix it anyway because all that setting does is make 
> sure the redirect is made using javascript on the client side.
>
> Are you sure the setting is being applied before the auth.requires_login() 
> decorator runs?
>

-- 
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: login_bare custom validation

2015-10-07 Thread 'DenesL' via web2py-users

Thanks Massimo
I never really went away ;-)


On Wednesday, October 7, 2015 at 2:06:16 PM UTC-4, Massimo Di Pierro wrote:
>
> welcome back Denes. :-) 
> your fix is in trunk.
>
>
> On Monday, 5 October 2015 15:33:48 UTC-5, DenesL wrote:
>>
>> This seems to work:
>>
>> def __call__(self, value):
>> v = str(value)
>> v = v and v[:self.max_length]
>> if len(v) < self.min_length:
>> return ('', translate(self.error_message))
>> if isinstance(value, LazyCrypt):
>> return (value, None)
>> return (LazyCrypt(self, value), None)
>>
>>

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


[web2py] auth.requires_login redirect and session expiration

2015-10-06 Thread 'DenesL' via web2py-users
Hi

an expired session becomes empty but this does not seem to always trigger 
auth.requires_login redirection to the login URL neither when set via 
auth.requires_login(loginURL), aka the otherwise parameter, nor by 
auth.settings.on_failed_authorization = loginURL .
Actually the otherwise parameter is superfluous in this case.

Status 401 UNAUTHORIZED is returned but the page remains unchanged.
I believe this happens when the same function is called with args.
If I call the same function with no args or another function that has 
requires_login, the login page is shown correctly.

Maybe I am not using it correctly.

Thanks,
Denes

-- 
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: orderby with groupby in select

2015-10-06 Thread 'DenesL' via web2py-users
m1 = db.messages
m2 = db.messages.with_alias('m2')
messages = db(m2.timesent==None).select(m1.ALL, left=m2.on((m1.fromid==m2.
fromid)&(m1.toid==m1.toid)&(m1.timesent

[web2py] Re: login_bare custom validation

2015-10-05 Thread 'DenesL' via web2py-users
Tracing the execution it shows that the password is converted to a 
LazyCrypt object and then validated using the field's requires which uses 
Crypt.__call__ where this line

value = value and value[:self.max_length]

triggers a __getitem__ exception, since it is not defined in class 
LazyCrypt.

The easy solution is to add

value = str(value)

as the first in the Crypt.__call__ function.

Maybe there is a problem in the logic of login_bare but for now this works.
Here is me hoping nothing else breaks.

Denes

-- 
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: login_bare custom validation

2015-10-05 Thread 'DenesL' via web2py-users
This seems to work:

def __call__(self, value):
v = str(value)
v = v and v[:self.max_length]
if len(v) < self.min_length:
return ('', translate(self.error_message))
if isinstance(value, LazyCrypt):
return (value, None)
return (LazyCrypt(self, value), None)

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


[web2py] Re: login_bare custom validation

2015-10-05 Thread 'DenesL' via web2py-users
The error is gone but the login does not work.
This needs more thought.


On Monday, October 5, 2015 at 2:51:22 PM UTC-4, DenesL wrote:
>
> Tracing the execution it shows that the password is converted to a 
> LazyCrypt object and then validated using the field's requires which uses 
> Crypt.__call__ where this line
>
> value = value and value[:self.max_length]
>
> triggers a __getitem__ exception, since it is not defined in class 
> LazyCrypt.
>
> The easy solution is to add
>
> value = str(value)
>
> as the first in the Crypt.__call__ function.
>
> Maybe there is a problem in the logic of login_bare but for now this works.
> Here is me hoping nothing else breaks.
>
> Denes
>

-- 
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: orderby with groupby in select

2015-10-05 Thread 'DenesL' via web2py-users
You probably want the sorting and no grouping:

messages = db(db.messages.toid == auth.user.id).select(db.messages.ALL, 
orderby=db.messages.fromid|~db.messages.timesent)

Denes

On Monday, October 5, 2015 at 2:35:16 PM UTC-4, Daniel wrote:
>
> Hi all,
>
> I am trying to order messages so that the newest message from each user is 
> displayed. However when grouped by user, the oldest message is displayed 
> despite being ordered by timesent. Its like the groupby argument overrides 
> the orderby.
>
> messages = db(db.messages.toid == auth.user.id).select(db.messages.ALL, 
> orderby=~db.messages.timesent, groupby=db.messages.fromid)
>
>
> Thanks for your help
>

-- 
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: login_bare custom validation

2015-10-05 Thread 'DenesL' via web2py-users
Hi again

alternatively, could anyone post some working code sample of using 
validation with login_bare?
the examples from the book and some posts in the forum were not enough for 
me.

Thanks,
Denes 

On Saturday, October 3, 2015 at 7:58:52 PM UTC-4, DenesL wrote:
>
> Hello all,
>
> Trying to do a custom validation using login_bare, which I have never 
> needed before, but I get a ticket shown below, it includes the minimalist 
> code to reproduce it.
> The view just shows the form.
>
> Using authentication by username: 
> auth.define_tables(username=True, signature=False)
>
>  'LazyCrypt' object has no attribute 
> '__getitem__' web2py™ Version 2.12.3-stable+timestamp.2015.08.19.00.18.03 
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
>
> Traceback (most recent call last):
>   File "C:\w2p\web2py_21203_src\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
> <http://10.0.0.27:8000/admin/default/edit/test/controllers/bare.py>, line 34, 
> in 
>   File "C:\w2p\web2py_21203_src\gluon\globals.py", line 412, in 
> self._caller = lambda f: f()
>   File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
> <http://10.0.0.27:8000/admin/default/edit/test/controllers/bare.py>, line 13, 
> in user
> if form.validate(onvalidation=uservalidate, hideerror=True):
>   File "C:\w2p\web2py_21203_src\gluon\html.py", line 2238, in validate
> if self.accepts(**kwargs):
>   File "C:\w2p\web2py_21203_src\gluon\sqlhtml.py", line 1496, in accepts
> **kwargs
>   File "C:\w2p\web2py_21203_src\gluon\html.py", line 2139, in accepts
> call_as_list(onvalidation, self)
>   File "C:\w2p\web2py_21203_src\gluon\html.py", line 146, in call_as_list
> item(*a, **b)
>   File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
> <http://10.0.0.27:8000/admin/default/edit/test/controllers/bare.py>, line 26, 
> in uservalidate
> user = auth.login_bare(u, p)
>   File "C:\w2p\web2py_21203_src\gluon\tools.py", line 2352, in login_bare
> settings.passfield].validate(password)[0]
>   File "C:\w2p\web2py_21203_src\gluon\packages\dal\pydal\objects.py", line 
> 1625, in validate
> (value, error) = validator(value)
>   File "C:\w2p\web2py_21203_src\gluon\validators.py", line 2850, in __call__
> value = value and value[:self.max_length]
> TypeError: 'LazyCrypt' object has no attribute '__getitem__'
>
> In file: C:\w2p\web2py_21203_src\applications\test\controllers/bare.py 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
> 31.
> 32.
> 33.
> 34.
> 35.
>
> # -*- coding: utf-8 -*-
> auth.settings.remember_me_form = False
> auth.settings.login_url = URL 
> <http://10.0.0.27:8000/examples/global/vars/URL>('bare','user', args='login')
>
>
> @auth.requires_login()
> def index():
>   return {}
>
>
> def user():
>   form = auth()
>   if form.validate(onvalidation=uservalidate, hideerror=True):
> redirect <http://10.0.0.27:8000/examples/global/vars/redirect>(URL 
> <http://10.0.0.27:8000/examples/global/vars/URL>('bare', 'index'))
>   elif form.errors:
> response <http://10.0.0.27:8000/examples/global/vars/response>.flash = ' 
> '.join(form.errors.values())
>   return {'form':form}
>
>
>
> def uservalidate(f):
>   u = f.vars.username or ''
>   p = f.vars.password or ''
>   print 'u: %s, p: %s' %(u,p)
>   if u and p:
> user = auth.login_bare(u, p)
> print user
> if not user:
>   f.errors.password = 'Invalid Password'
> return user
>   else:
> return False
>
> response <http://10.0.0.27:8000/examples/global/vars/response>._vars=response 
> <http://10.0.0.27:8000/examples/global/vars/response>._caller(user)
>
>
> Thanks for any hints,
> Denes
>

-- 
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: SQLFORM.grid + count

2015-10-05 Thread 'DenesL' via web2py-users
Not sure if you can do it with just one query.
How about getting the count first and using it in the grid:

sm = db.invocados.modulo_servico
modulo_counts = db().select(sm, sm.count(), groupby=sm)

Denes.

On Thursday, October 1, 2015 at 9:41:59 PM UTC-4, Bruno Oliveira wrote:
>
>
> I'm trying to create a SQLFORM.grid in web2py that group 2 fields and 
> count them up, but I couldn't figure it out how to do it.
>
>
> *Model*
>
> db.define_table('invocados',
> Field('modulo_servico', 'string', label='Módulo (Serviço)', 
> default=IS_LENGTH(2)),
> Field('servico', 'string', default=IS_LENGTH(8)),
>)
>
>
> *Controller*
>
> fields=(db.invocados.modulo_servico, 
> db.invocados.servico)Invocados=SQLFORM.grid(db.invocados.modulo_servico != 
> db.invocados.modulo_consumidor, details=False, fields=fields, 
> groupby=(db.invocados.modulo_servico | db.invocados.servico) , paginate=15)
>
>
> I'm trying to count all records grouped by modulo_servico and servico. 
> I've tried:
>
> fields=(db.invocados.modulo_servico, db.invocados.servico, 
> db.invocados.count())
>
> but it doesn't work.
>
>
> Can somebody help?
>

-- 
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] keyError

2015-10-05 Thread 'DenesL' via web2py-users
You have to think in terms of the python objects.

geoNames API gives you a dictionary with one key: postalcodes
The value of the postalcodes entry in the dictionary is a list of 
dictionaries, each with the info of one postal code.

If the list is empty the previous code 

for x in location_data['postalcodes']:

should work since there would be nothing to iterate over (you never get a 
value for x and the 'for' never loops).

Denes


On Monday, October 5, 2015 at 12:27:41 AM UTC-4, Alex Glaros wrote:
>
> am having hard time finding syntax for checking for empty API data in 
> above example
>
> Here is what geoNames.org APII returns when nothing is found:
>
> {"postalcodes":[]}
>
>
> tried many variations of:
>
> {{if location_data:}}
>
> If I include "postalcodes" I receive "Key" error. Any ideas? 
>
> thanks,
>
> Alex
>

-- 
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: ST_X function on POSTGIS geography() fields

2015-10-04 Thread 'DenesL' via web2py-users
How do you propose to code those functions if they are not available in the 
DB engine?.
MS SQL Server does have functions to extract longitude and latitude data 
from geography points but PostGIS does not seem to have them.

I can send in a patch for MSSQL with the following extended methods: Lat 
Long M Z
(last two being measure and elevation info)
and more functions are available depending on the version of MSSQL.

Denes

On Wednesday, September 30, 2015 at 4:56:56 PM UTC-4, wish7...@gmail.com 
wrote:
>
> Done: https://github.com/web2py/pydal/issues/298
>
> Cheers
> Toby
>
> Am Dienstag, 29. September 2015 23:17:37 UTC+2 schrieb wish...@gmail.com:
>>
>> +1 from my side too :-) Was a pydal ticket ever opened?
>> Otherwise I would do now...
>>
>> Cheers 
>> Toby
>>
>> Am Montag, 22. Juni 2015 08:51:59 UTC+2 schrieb Massimo Di Pierro:
>>>
>>> Please open a pydal ticket. I do not think we support this yet but we 
>>> can add it.
>>>
>>> On Wednesday, 23 April 2014 05:44:39 UTC-5, libe...@gmail.com wrote:

 Hi everyone,
 I am trying to extract latitude and longitude from a POSTGIS 
 geography() field. Unfortunately the usual st_x() and st_y() functions 
 normally used
 for geometry() fields won't work.
 How can I extract the required values or transform geography in 
 geometry?

 Thanks

>>>

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


Re: [web2py] keyError

2015-10-03 Thread 'DenesL' via web2py-users

The location_data received from geoNames can contain more than one country 
code, your first sample has 3: MK DE US.
Your second sample has only one: MX

By the name of the variable being used (your_country) I assume you want to 
get only one postalcode.
In any case you could use:

location_data['postalcodes'][0]['countryCode']

which gives you the countryCode of the first entry (check if there is at 
least one before hand).

Denes

On Saturday, October 3, 2015 at 2:31:48 PM UTC-4, Alex Glaros wrote:
>
> Single item works Laer,
>
> your_country = (db.Country.countryCode == 
> location_data['postalcodes'][5]['countryCode'])
>
> how can all of the values be accessed? See my guess below:
>
> your_country = (db.Country.countryCode == location_data['postalcodes'][ALL
> ]['countryCode'])
>
> thanks,
>
> Alex
>

-- 
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] login_bare custom validation

2015-10-03 Thread 'DenesL' via web2py-users
Hello all,

Trying to do a custom validation using login_bare, which I have never 
needed before, but I get a ticket shown below, it includes the minimalist 
code to reproduce it.
The view just shows the form.

Using authentication by username: 
auth.define_tables(username=True, signature=False)

 'LazyCrypt' object has no attribute 
'__getitem__' web2py™ Version 2.12.3-stable+timestamp.2015.08.19.00.18.03 
Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.

Traceback (most recent call last):
  File "C:\w2p\web2py_21203_src\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 34, 
in 
  File "C:\w2p\web2py_21203_src\gluon\globals.py", line 412, in 
self._caller = lambda f: f()
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 13, 
in user
if form.validate(onvalidation=uservalidate, hideerror=True):
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 2238, in validate
if self.accepts(**kwargs):
  File "C:\w2p\web2py_21203_src\gluon\sqlhtml.py", line 1496, in accepts
**kwargs
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 2139, in accepts
call_as_list(onvalidation, self)
  File "C:\w2p\web2py_21203_src\gluon\html.py", line 146, in call_as_list
item(*a, **b)
  File "C:/w2p/web2py_21203_src/applications/test/controllers/bare.py" 
, line 26, 
in uservalidate
user = auth.login_bare(u, p)
  File "C:\w2p\web2py_21203_src\gluon\tools.py", line 2352, in login_bare
settings.passfield].validate(password)[0]
  File "C:\w2p\web2py_21203_src\gluon\packages\dal\pydal\objects.py", line 
1625, in validate
(value, error) = validator(value)
  File "C:\w2p\web2py_21203_src\gluon\validators.py", line 2850, in __call__
value = value and value[:self.max_length]
TypeError: 'LazyCrypt' object has no attribute '__getitem__'

In file: C:\w2p\web2py_21203_src\applications\test\controllers/bare.py 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.

# -*- coding: utf-8 -*-
auth.settings.remember_me_form = False
auth.settings.login_url = URL 
('bare','user', args='login')


@auth.requires_login()
def index():
  return {}


def user():
  form = auth()
  if form.validate(onvalidation=uservalidate, hideerror=True):
redirect (URL 
('bare', 'index'))
  elif form.errors:
response .flash = ' 
'.join(form.errors.values())
  return {'form':form}



def uservalidate(f):
  u = f.vars.username or ''
  p = f.vars.password or ''
  print 'u: %s, p: %s' %(u,p)
  if u and p:
user = auth.login_bare(u, p)
print user
if not user:
  f.errors.password = 'Invalid Password'
return user
  else:
return False

response ._vars=response 
._caller(user)


Thanks for any hints,
Denes

-- 
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] keyError

2015-10-03 Thread 'DenesL' via web2py-users
[x['countryCode'] for x in location_data['postalcodes']]

will give you an array of the country codes in location_data, but note that 
you could have duplicated entries.

If you don't want duplicates you could do:

cc=[]
for x in location_data['postalcodes']:
  c=x['countryCode']
  if c not in cc:
cc.append(c)

Denes.




On Saturday, October 3, 2015 at 8:39:31 PM UTC-4, Alex Glaros wrote:
>
> Hi Denes,
>
> sorry, I want all the countries.  For example, if zip, is 95694, it exists 
> in more than one country,  I display all countries and let user choose 
> their country.
>
> What is syntax for all?  I've tried a million combinations, read 
> tutorials, and cannot find examples in discussion groups.
>
> "your_country" is the query for a grid.
>
> thanks,
>
> Alex
>

-- 
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_IN_DB validation error

2015-10-02 Thread 'DenesL' via web2py-users
Oops, thanks Anthony. It should be:

IS_IN_DB(db(geo_item.f_collection_id == geo_collection.id 

),...)

Hope it helps.
Denes


On Friday, October 2, 2015 at 9:25:15 AM UTC-4, Anthony wrote:
>
> Note, it is actually the first argument that must be a Set object (or a 
> DAL) object. The second argument must be a Field object or a string 
> representation of a field in 'tablename.fieldname' format.
>
> 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: ST_X function on POSTGIS geography() fields

2015-10-01 Thread 'DenesL' via web2py-users

Has anyone tried using the functions?.
They are defined in web2py 2.12.03 pydal/adapters/postgres.py  as ST_X and 
ST_Y.


On Wednesday, September 30, 2015 at 4:56:56 PM UTC-4, wish7...@gmail.com 
wrote:
>
> Done: https://github.com/web2py/pydal/issues/298
>
> Cheers
> Toby
>
> Am Dienstag, 29. September 2015 23:17:37 UTC+2 schrieb wish...@gmail.com:
>>
>> +1 from my side too :-) Was a pydal ticket ever opened?
>> Otherwise I would do now...
>>
>> Cheers 
>> Toby
>>
>> Am Montag, 22. Juni 2015 08:51:59 UTC+2 schrieb Massimo Di Pierro:
>>>
>>> Please open a pydal ticket. I do not think we support this yet but we 
>>> can add it.
>>>
>>> On Wednesday, 23 April 2014 05:44:39 UTC-5, libe...@gmail.com wrote:

 Hi everyone,
 I am trying to extract latitude and longitude from a POSTGIS 
 geography() field. Unfortunately the usual st_x() and st_y() functions 
 normally used
 for geometry() fields won't work.
 How can I extract the required values or transform geography in 
 geometry?

 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: IS_IN_DB validation error

2015-10-01 Thread 'DenesL' via web2py-users
The second parameter of IS_IN_DB should be a set not a query:

query: (geo_item.f_collection_id == geo_collection.id) 

set: db(geo_item.f_collection_id == geo_collection.id) 


IS_IN_DB(db, db(geo_item.f_collection_id == geo_collection.id 

),...)

Been there, done that. Not so easy to spot.


On Thursday, October 1, 2015 at 9:44:56 PM UTC-4, John Smidt wrote:
>
>
> Im currently creating a website for a geology museum. Each exhibit in the 
> museum contains different collections (or categories) of minerals, and each 
> collection has a handful of individual minerals that are being shown at 
> this museum. The part that I am currently working on is to allow an admin 
> to select a featured image of a specific item in each collection via a drop 
> down box within the collection table. However, the validation of this field 
> is acting up. Here is the code:
>
> db.geo_collection.f_featured_img.requires=IS_IN_DB(db, 
> (geo_item.f_collection_id == geo_collection.id 
> ),lambda
>  
> row: '%s' % row.f_name)
>
> The comparison in this line of code (geo_item.f_collection_id == 
> geo_collection.id) is not working, stating that I am unpacking too many 
> values. 
>
> Here is the traceback:
>
> Traceback (most recent call last):
>   File "/home/SIRI/web2py/gluon/restricted.py", line 217, in restricted
> exec ccode in environment
>   File "/home/SIRI/web2py/applications/mqr/models/db_wizard.py" 
> , 
> line 148, in 
> db.geo_collection.f_featured_img.requires=IS_IN_DB(db, 
> (db.geo_item.f_collection_id == db.geo_collection.id),lambda row: '%s' % 
> row.f_name)
>   File "/home/SIRI/web2py/gluon/validators.py", line 497, in __init__
> (ktable, kfield) = str(field).split('.')
> ValueError: too many values to unpack
>
>
> I believe that the tuple "(ktable, kfield)" is the reason why I'm 
> unpacking too many values, since it requires one table and one field, and I 
> have a table and *two* fields. The question that I have is 
> *how can I reference these items in my table without breaking the code?*
> Some extra info, I have tried to change the IS_IN_DB to IS_IN_SET, but 
> received an error stating that " 'Query' 
> object does not support indexing".
>
> Any information would be greatly appreciated.
> Thank you,
> John
>

-- 
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: LOAD and export to CSV

2015-09-30 Thread 'DenesL' via web2py-users
Thanks for the link Brian. Checking it out right now.


On Tuesday, September 29, 2015 at 9:19:33 PM UTC-4, Brian M wrote:
>
> Yeah, with a little looking, and also another recent post here, you can't 
> start a download with JavaScript so you'll have to do something else. 
> Either just redirect the user to a download page that'll generate the CSV 
> or else look into using something like this --> 
> http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
>  
> I haven't tried that but it looks interesting.
>
> On Monday, September 28, 2015 at 11:04:57 PM UTC-5, DenesL wrote:
>>
>>
>> Yes, the content is properly set but it is returned as the component 
>> content instead of a separate file, which is what should happen IMHO.
>> What I need is some way to "cancel" the LOAD so the file is returned 
>> instead and the component is not updated, because otherwise it would become 
>> empty.
>>
>> So far the best solution seems to be to create the file and set a link to 
>> download it as part of the LOAD return, a two step process for the export 
>> scenario.
>> I was just hoping someone had a better idea.
>>
>> Thanks,
>> Denes
>>
>>  
>>
>> On Monday, September 28, 2015 at 8:38:37 PM UTC-4, Brian M wrote:
>>>
>>> Have you tried setting the appropriate content type header before 
>>> returning? I've not done it inside a LOAD before but know that setting the 
>>> content type will normally get the browser to download & save a CSV file 
>>> rather than just display it.
>>>
>>> Brian
>>>
>>

-- 
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: LOAD and export to CSV

2015-09-28 Thread 'DenesL' via web2py-users

Yes, the content is properly set but it is returned as the component 
content instead of a separate file, which is what should happen IMHO.
What I need is some way to "cancel" the LOAD so the file is returned 
instead and the component is not updated, because otherwise it would become 
empty.

So far the best solution seems to be to create the file and set a link to 
download it as part of the LOAD return, a two step process for the export 
scenario.
I was just hoping someone had a better idea.

Thanks,
Denes

 

On Monday, September 28, 2015 at 8:38:37 PM UTC-4, Brian M wrote:
>
> Have you tried setting the appropriate content type header before 
> returning? I've not done it inside a LOAD before but know that setting the 
> content type will normally get the browser to download & save a CSV file 
> rather than just display it.
>
> Brian
>

-- 
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] LOAD and export to CSV

2015-09-27 Thread 'DenesL' via web2py-users
Hello all,

recently I came across this little problem and I have not been able to find 
a solution to it.

I have an export button that gets enabled under certain conditions inside a 
LOAD ajax=True component.
When one clicks on the button, form values are posted to build the CSV, but 
then I can not separate the component return from the CSV return and the 
later replaces my component in the browser.

Maybe I could cancel the LOAD and just return the file?.
There is nothing to update on the component. 
I would like to keep it as easy as possible for the end user.

Thanks,
Denes

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


  1   2   3   4   5   6   7   8   9   10   >