[web2py] Re: How can I return a report to the user in the view?

2019-04-29 Thread 'Francis Windram' via web2py-users
Brilliant, thank you! The pre tags worked exactly as required.

-- 
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 Windows edition with 3.x Interpreter

2019-04-29 Thread Nico Zanferrari
Hi rama,

first of all, note that the shell.py fix will resolve only the 'cosmethic'
problem of the help command (and "copyright", "credits" , "license"
commands) that doesn't work in the interactive shell. But it will not
change the import problem in any way.


According to the manual, if you run web2py *from source* you can import
from it any python module that is in the PYTHONPATH (sys.path) - which is
automatically changed by web2py in order to include also
web2py/site-packages (globally) and web2py/application/yourapp/modules
(inside yourapp).
The last one is preferred if you are planning to distribute the app or you
are experimenting with different versions of the same module. It also has
higher priority and can even be accessed by other apps as
web2py/application/anotherapp/modules.

If you run web2py *from the compiled binary*, any system-wide folder will
be ignored - only what's down the web2py folder will be available. Modules
can be placed on the folders: web2py, web2py/site-packages (globally for
all the apps) and web2py/application/yourapp/modules (inside yourapp). You
can check it by yourself with the interactive shell and the simple
helloworld.py module.

What's different and problematic in the 'running from binary' is that you
cannot use pip (or similar) for installing modules inside. You instead have
to pip-install them on a full system (that has python of the same version
of the binary one) and manually copy the related files inside the binary
folders. For complex module like pandas, you also have to copy all the
files for the related pre-requisites - and possibly test them one by one.
Unfortunately, this could fail - expecially if the modules have binary
files. In this case, the last resort is to try to compile the binary
version by yourself from a working web2py source - following the
instructions on my repository and specifying your additional needed
modules. Maybe PyInstaller will play the module dependency game better than
you ;-)


I've also copied these advices on this howto page

for
future reference - feel free to correct me if I was wrong somewhere!


Cheers,
Nico


Il giorno lun 29 apr 2019 alle ore 04:24 rāma  ha
scritto:

> Hi Nico,
>
> Thank you for the insights. I am actually importing a number of modules
> within the controllers fyi, not only via shell.
>
> Would patching shell.py fix the behaviour application wide?
>
> Do you suggest I pip install into site-packages again instead of copying
> from my source version? I suspect that it's not going to fix it.
>
> Folder structure:
> web2py
>|_site-packages <- here's where my modules are
>
> I am trying to package and bundle the whole web2py for work as an app
> solution and for test release soon.
> Your experimental binaries would definitely help me to do early test with
> users while waiting for the official binaries. I could do some quick
> patches on web2py if required too, please advise how.
>
> Best,
> rama
>
> On Monday, 29 April 2019 05:30:55 UTC+8, Nico Zanferrari wrote:
>>
>> I've found why the help command (and "copyright", "credits" ,
>> "license")  it's missing. It's due to the fact that PyInstaller replaces
>> the original python module 'site'  with a fake one
>> 
>> that contains this comment:
>>
>>
>> "This is a fake 'site' module available in default Python Library.
>>
>> The real 'site' does some magic to find paths to other possible
>> Python modules. We do not want this behaviour for frozen applications.
>>
>> Fake 'site' makes PyInstaller to work with distutils and to work inside
>> virtualenv environment."
>>
>> It's possible to change this behaviour on gluon/shell.py by adding the
>> missing code - I'm setting up a PR for this ;-)
>>
>> Nico
>>
>>
>> Il giorno dom 28 apr 2019 alle ore 19:45 Nico Zanferrari <
>> nico...@gmail.com> ha scritto:
>>
>>> Hi rāma,
>>>
>>> in fact we are both wrong and the console is working fine!
>>> I've tested it with a simple module (the simplest one, helloword.py ,
>>> see
>>> https://stackoverflow.com/questions/15746675/how-to-write-a-python-module-package)
>>> and it can be regularly imported if it's placed on the main folder or on
>>> the site-packages one. So, it seems that your problem is strictly related
>>> to copying the pandas module.
>>>
>>> But indeed the interactive console is not so perfect. It's  somehow
>>> missing the help command (and "copyright", "credits" , "license"), and this
>>> happens with PyInstaller on PY2/PY3 with Windows and Mac even with the
>>> simple 2-lines program:
>>>
>>> import code
>>> code.interact()
>>>
>>> Nico
>>>
>>> Il giorno sab 27 apr 2019 alle ore 13:45 rāma  ha
>>> scritto:
>>>
 Any quick fix will be appreciated though.

 On Friday, 26 April 2019 15:30:57 UTC+8, Massimo Di Pierro wrote:
>
> Yes. The plan is to provide the following executab

Re: [web2py] bye bye T, welcome pluralize

2019-04-29 Thread Carlos Cesar Caballero Díaz
It looks good!! I can work to support categories if you think it worth 
it. Allow something like T("string", "category") or T("string", 
cat="category"). A category would map to an specific folder of json 
internationalization files, if there is no category specified, it will 
map to a default category. Something like this would make the 
translations reutilization easier.


Greetings.

El 26/4/19 a las 1:53 a.m., Massimo Di Pierro escribió:

web3py now uses this:

https://pypi.org/project/pluralize/
https://github.com/web2py/pluralize

thoughts? comments?

--
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] 2.18.5 admin app search error

2019-04-29 Thread JSalvat
Hi all,

I'm getting  An error occurred, please reload the page

when using the search feature in edit application. It used to work on 
previus releases!

-- 
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: custom search

2019-04-29 Thread villas
Hi Andfae
It seems you are using additional inputs to submit searches to a 
SQLFORM.grid search widget...

1. Do not wrap the new inputs inside a form, as you are adding them to an 
existing search form.  
2. Add something like this as the last line in your *datainizioSrch *
function

$("#w2p_keywords").closest('form').find(':submit').click();


Best regards, D


On Friday, 26 April 2019 12:35:09 UTC+1, andfae wrote:
>
> Hello I will give you the codeok? 
>
> 
> var srchI, srchF, srch;
> 
> // funzione che consente di impostare la ricerca Dalla Data
> function datainizioSrch(){
> var dataDa = 
> moment($('#datepickerI').datepicker("getDate")).format('-MM-DD');
> srchI ='evento.inizio >= ' + '"' + dataDa + '"';
> if (srchF != undefined) {
>srch = srchI + ' and ' + srchF;
> } else {
> srch = srchI;
> }
> // console.log(srch);
> $("#w2p_keywords").val(srch);
> }
> // funzione che consente di impostare la ricerca Alla Data
> function datafineSrch(){
> // aggiunge 1 giorno per includere anche l'ultimo giorno della 
> data di ricerca dataA
> var dataA = moment($('#datepickerF').datepicker("getDate")).add(1, 
> 'days').format('-MM-DD');
> srchF ='evento.fine <= ' + '"' + dataA + '"';
> if (srchI != undefined) {
>srch = srchI + ' and ' + srchF;
> } else {
> srch = srchF;
> }
> // console.log(srch);
> $("#w2p_keywords").val(srch);
> }
>
> $(document).ready(function(){
>
> // la funzione di ricerca standard della grid viene nascosta  
> $("#w2p_keywords").prop("type", "hidden");
>
> // Inserire gli elementi della ricerca custom dopo la ricerca 
> standard ("#w2p_keywords").
> // Questo consente di non farla vedere sulle pagine edit e view
> // inserire i campi di ricerca nell'ordine inverso con i quali 
> appaiono nella pagina
> var inputStr  = '
class="form-group" style="padding-bottom:5px;">Dalla Data: type="text" id="datepickerI" class="datepicker" readonly="true" > onchange="datainizioSrch()">
style="padding-bottom:5px;">Alla Data: class="datepicker" readonly="true" onchange="datafineSrch()">
'; > $(inputStr).insertAfter("#w2p_keywords"); > > // definisco il datepicker > $("#datepickerI").datepicker({ > dateFormat: "dd/mm/yy", > autoSize: true, > firstDay: 1, > dayNamesMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"], > monthNames: [ "Gennaio", "Febbraio", "Marzo", "Aprile", > "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", > "Dicembre" ], > }); > $("#datepickerF").datepicker({ > dateFormat: "dd/mm/yy", > autoSize: true, > firstDay: 1, > dayNamesMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"], > monthNames: [ "Gennaio", "Febbraio", "Marzo", "Aprile", > "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", > "Dicembre" ], > }); > }); > > > > Il ven 26 apr 2019, 12:31 Massimiliano > > ha scritto: > >> Is difficult to understand how you intend to trigger the search without >> some infos. >> Anyway just to give you an hint: >> >> jQuery("#your_custom_widget").closest('form').trigger('submit'); >> >> On Fri, Apr 26, 2019 at 12:22 PM Andrea Fae' > > wrote: >> >>> They are the standard buttons "Search" and "Reset". I'd like from >>> javascript in the html view to execute "Search" by code. >>> Thank you >>> >>> Il giorno venerdì 26 aprile 2019 00:05:39 UTC+2, João Matos ha scritto: You don't have the standard buttons, but have a search button created by you? quinta-feira, 25 de Abril de 2019 às 15:21:41 UTC+1, Andrea Fae' escreveu: > > I create a custom search, so not standard field with "Search" and > "reset" button standard. How to click the button "Search" > programmatically? > 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 web...@googlegroups.com . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> Massimiliano >> >> -- >> 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) >> --- >> Y

[web2py] Re: MARKMIN - Sanitizing

2019-04-29 Thread villas
Hi Paul

If you are worried about saving dodgy text in the DB,  you could sanitize 
it first using XML()

e.g.

XML('dodgy();**Hello**',sanitize=True).xml()

***Hello***


On Thursday, 25 April 2019 12:19:44 UTC+1, Paul Ellis wrote:
>
> I am using an editable span with some js to submit the input via ajax to 
> the server. The span is only editable by admins. 
>
> To give them some formatting options they can use MARKMIN in the span.
>
> The problem is it only seems to be one directional. 
> How can I take the processed HTML and turn it back into MARKMIN in order 
> to allow editing?
>
> or at least sanitize it that I can be sure no malicious code has been 
> submitted so I can save the MARKMIN in the db.
>
>  js that sends the span contents.
> $("document").ready(function() {
>
> // set the event listeners on the edit button
> $("button[name='buttonedit']").click(function() {
> var panel = $(this)[0].previousSibling
> panel.innerText = panel.getAttribute("data-raw")
> panel.setAttribute("contenteditable", "true")
> // console.log(panel)
> $(this).hide()
> $(this)[0].nextSibling.setAttribute("style", "display:true")
> })
> $("button[name='buttonsave']").click(function() {
> $(this).disabled = true
> var xhttp = new XMLHttpRequest();
> xhttp.open('POST', '/assist/update_info_panel', true);
> xhttp.setRequestHeader("Content-type", 
> "application/x-www-form-urlencoded");
> var panel = $(this)[0].previousElementSibling.
> previousElementSibling
> var body = {
> 'pid': panel.id, 
> 'body': panel.innerText,
> };
> // console.log(body);
> xhttp.onreadystatechange = function() {
> // debug code
> // if (this.readyState == 4) {
> // console.log(this);
> // };
> if (this.readyState == 4 && this.status == 200) {
> var rObj = JSON.parse(this.responseText);
> $("span#"+rObj.pid).replaceWith(rObj.body)
> $("span#"+rObj.pid)
> .next().attr("style", "display:true")
> .next().attr("style", "display:None")
> $("span#"+rObj.pid).find("a").attr("target", "_blank")
>
> }
> };
> xhttp.send(JSON.stringify(body));
> })
> })
>
> the controller function that receives the markmin (via json) and returns 
> the HTML.
>
> In order to allow editing the raw markmin is stored in a data attribute. I 
> feel this is very unsafe which is why I am asking for help.
> def update_info_panel():
> if auth.has_membership('assistant_admin', cached=True):
> raw_json = None
> for key in request.vars.keys():
> if len(key) > 10:
> raw_json = key
> inData = Storage(json.loads(raw_json))
> pid = inData.pid[5:]
> record = db.product[pid]
> assist_info = inData.body
> if record:
> record.update_record(assist_info=assist_info)
> body = {
> 'pid': inData.pid,
> 'body': SPAN(MARKMIN(assist_info),
> _id=inData.pid,
> _name='info_panel',
> _contenteditable='false',
> data = {'raw': assist_info}
> ).__str__()
> }
> return json.dumps(body) 
> else:
> pass
>
> The section of the view which holds the span and edit buttons.
> 
> {{try:}}
> {{for item in extra_info:}}
> {{=DIV(
> SPAN(MARKMIN(item['info']),
> _id= 'info_{0}'.format(item['pid']),
> _name= 'info_panel', 
> _contenteditable= 'false',
> _style="display:block",
> data= {
> 'raw':item['info'] if 
> auth.has_membership('assistant_admin') else '',
> },
> ),
> BUTTON(SPAN(_class="glyphicon glyphicon-pencil"), 
> _class='btn btn-sm btn-default', 
> _name='buttonedit')\
> if auth.has_membership('assistant_admin') 
> else '',
> BUTTON(SPAN(_class='glyphicon 
> glyphicon-floppy-disk'),
> _class="btn btn-sm btn-primary", 
> _name="buttonsave",
> _style="display:none")\
> if auth.has_membership('assistant_admin') 
> else '',
> _id= 'box_{0}'.format(item['id']),
> _style='display:none', 
> )}}
> {{pass}}
> {{except Exception as e:}}
> {{print e}}
> {{pass}

[web2py] Re: Duplicates in SQLgrid

2019-04-29 Thread villas
Not sure if this personal experience helps but...
I only use SQLFORM.grid when it is clearly a quick and simple solution.
Otherwise, I use DataTables, which I think is great.


-- 
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: MARKMIN - Sanitizing

2019-04-29 Thread Paul Ellis
Hey Villas,

thanks. I actually thought that the XML sanitization would break the
MARKMIN conversion but it doesn't.

I probably should have tested that first.

Regards

On Mon, Apr 29, 2019 at 7:06 PM villas  wrote:

> Hi Paul
>
> If you are worried about saving dodgy text in the DB,  you could sanitize
> it first using XML()
>
> e.g.
>
> XML('dodgy();**Hello**',sanitize=True).xml()
>
> ***Hello***
>
>
> On Thursday, 25 April 2019 12:19:44 UTC+1, Paul Ellis wrote:
>>
>> I am using an editable span with some js to submit the input via ajax to
>> the server. The span is only editable by admins.
>>
>> To give them some formatting options they can use MARKMIN in the span.
>>
>> The problem is it only seems to be one directional.
>> How can I take the processed HTML and turn it back into MARKMIN in order
>> to allow editing?
>>
>> or at least sanitize it that I can be sure no malicious code has been
>> submitted so I can save the MARKMIN in the db.
>>
>>  js that sends the span contents.
>> $("document").ready(function() {
>>
>> // set the event listeners on the edit button
>> $("button[name='buttonedit']").click(function() {
>> var panel = $(this)[0].previousSibling
>> panel.innerText = panel.getAttribute("data-raw")
>> panel.setAttribute("contenteditable", "true")
>> // console.log(panel)
>> $(this).hide()
>> $(this)[0].nextSibling.setAttribute("style", "display:true")
>> })
>> $("button[name='buttonsave']").click(function() {
>> $(this).disabled = true
>> var xhttp = new XMLHttpRequest();
>> xhttp.open('POST', '/assist/update_info_panel', true);
>> xhttp.setRequestHeader("Content-type",
>> "application/x-www-form-urlencoded");
>> var panel = $(this)[0].previousElementSibling.
>> previousElementSibling
>> var body = {
>> 'pid': panel.id,
>> 'body': panel.innerText,
>> };
>> // console.log(body);
>> xhttp.onreadystatechange = function() {
>> // debug code
>> // if (this.readyState == 4) {
>> // console.log(this);
>> // };
>> if (this.readyState == 4 && this.status == 200) {
>> var rObj = JSON.parse(this.responseText);
>> $("span#"+rObj.pid).replaceWith(rObj.body)
>> $("span#"+rObj.pid)
>> .next().attr("style", "display:true")
>> .next().attr("style", "display:None")
>> $("span#"+rObj.pid).find("a").attr("target", "_blank")
>>
>> }
>> };
>> xhttp.send(JSON.stringify(body));
>> })
>> })
>>
>> the controller function that receives the markmin (via json) and returns
>> the HTML.
>>
>> In order to allow editing the raw markmin is stored in a data attribute.
>> I feel this is very unsafe which is why I am asking for help.
>> def update_info_panel():
>> if auth.has_membership('assistant_admin', cached=True):
>> raw_json = None
>> for key in request.vars.keys():
>> if len(key) > 10:
>> raw_json = key
>> inData = Storage(json.loads(raw_json))
>> pid = inData.pid[5:]
>> record = db.product[pid]
>> assist_info = inData.body
>> if record:
>> record.update_record(assist_info=assist_info)
>> body = {
>> 'pid': inData.pid,
>> 'body': SPAN(MARKMIN(assist_info),
>> _id=inData.pid,
>> _name='info_panel',
>> _contenteditable='false',
>> data = {'raw': assist_info}
>> ).__str__()
>> }
>> return json.dumps(body)
>> else:
>> pass
>>
>> The section of the view which holds the span and edit buttons.
>> 
>> {{try:}}
>> {{for item in extra_info:}}
>> {{=DIV(
>> SPAN(MARKMIN(item['info']),
>> _id= 'info_{0}'.format(item['pid']),
>> _name= 'info_panel',
>> _contenteditable= 'false',
>> _style="display:block",
>> data= {
>> 'raw':item['info'] if
>> auth.has_membership('assistant_admin') else '',
>> },
>> ),
>> BUTTON(SPAN(_class="glyphicon glyphicon-pencil"),
>> _class='btn btn-sm btn-default',
>> _name='buttonedit')\
>> if auth.has_membership('assistant_admin')
>> else '',
>> BUTTON(SPAN(_class='glyphicon
>> glyphicon-floppy-disk'),
>> _class="btn btn-sm btn-primary",
>> _name="buttonsave",
>> _style="display:none")\
>>  

[web2py] Grid search and clear buttons don't restore request.args. Where can I correct that?

2019-04-29 Thread jcrmatos


Grid search and clear buttons don't restore request.args. Where can I 
correct that?


If using master-child pages, the master grid search works fine (because 
there are no request.args), but the child grid (which has request.args, 
from the master record) doesn't because the search and clear buttons don't 
restore the request.args.


web2py 2.18.5
Python 3.7.1 x86
Firefox 66.0.3 x64
Windows 7 Pro x64 SP1+all upds

-- 
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] Grid search collects all records from all fields on each request. Isn't this bad for performance?

2019-04-29 Thread jcrmatos
Grid search collects all records from all fields on each request. Isn't 
this bad for performance?

Isn't it possible to change this behavior to only load the records when the 
user selects a specific field to do the search?

-- 
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] Grid sorting sorts by id (in case of a FK) instead of shown value (eg. name). Is this normal?

2019-04-29 Thread jcrmatos
Grid sorting sorts by id (in case of a FK) instead of shown value (eg. 
name). Is this normal?

The only way I found to correct this behavior was to change the grid's 
table to a query, where in this query I include all the foreign fields (eg. 
name) directly and remove al the foreign keys.
Is this the correct/only way to solve 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.


[web2py] Re: Grid sorting sorts by id (in case of a FK) instead of shown value (eg. name). Is this normal?

2019-04-29 Thread Anthony
Yes. It shows the values from the foreign table via "recursive selects" 
(i.e., a separate query for each displayed row after the initial set of 
records is fetched from the database), so it is not able to use that 
information for sorting (which would require the initial query to be a join 
with the foreign table).

Anthony

On Monday, April 29, 2019 at 6:26:10 PM UTC-4, jcrma...@gmail.com wrote:
>
> Grid sorting sorts by id (in case of a FK) instead of shown value (eg. 
> name). Is this normal?
>
> The only way I found to correct this behavior was to change the grid's 
> table to a query, where in this query I include all the foreign fields (eg. 
> name) directly and remove al the foreign keys.
> Is this the correct/only way to solve it?
>
>
> web2py 2.18.5
> Python 3.7.1 x86
> Firefox 66.0.3 x64
> Windows 7 Pro x64 SP1+all upds
>

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


[web2py] Re: Grid sorting sorts by id (in case of a FK) instead of shown value (eg. name). Is this normal?

2019-04-29 Thread jcrmatos
So the only way to correct it is the way I used. Thanks Anthony.

segunda-feira, 29 de Abril de 2019 às 23:56:18 UTC+1, Anthony escreveu:
>
> Yes. It shows the values from the foreign table via "recursive selects" 
> (i.e., a separate query for each displayed row after the initial set of 
> records is fetched from the database), so it is not able to use that 
> information for sorting (which would require the initial query to be a join 
> with the foreign table).
>
> Anthony
>
> On Monday, April 29, 2019 at 6:26:10 PM UTC-4, jcrm...@gmail.com 
>  wrote:
>>
>> Grid sorting sorts by id (in case of a FK) instead of shown value (eg. 
>> name). Is this normal?
>>
>> The only way I found to correct this behavior was to change the grid's 
>> table to a query, where in this query I include all the foreign fields (eg. 
>> name) directly and remove al the foreign keys.
>> Is this the correct/only way to solve it?
>>
>>
>> web2py 2.18.5
>> Python 3.7.1 x86
>> Firefox 66.0.3 x64
>> Windows 7 Pro x64 SP1+all upds
>>
>

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


[web2py] Re: Grid search collects all records from all fields on each request. Isn't this bad for performance?

2019-04-29 Thread Anthony
On Monday, April 29, 2019 at 6:22:26 PM UTC-4, jcrma...@gmail.com wrote:
>
> Grid search collects all records from all fields on each request. Isn't 
> this bad for performance?
>

Are you referring to "reference" fields, which result in a select element 
showing associated values from the foreign table? If so, that is the result 
of the default IS_IN_DB validator given to such fields, which results in a 
select element being created when the field appears in forms as well as the 
search menu. You can override this behavior by putting the validator in a 
list:

db.mytable.myreferencefield.requires = [db.mytable.myreferencefield]

However, in that case, forms and the search menu will simply present a 
numeric input field, and you would need to search by the record ID, so 
probably not very useful. Alternatively, you can specify an autocomplete 
widget, but that won't help in the grid search menu.
 

> Isn't it possible to change this behavior to only load the records when 
> the user selects a specific field to do the search?
>

Feel free to submit a pull request. Alternatively, you can specify both a 
custom search menu and a custom search function via the "search_widget" and 
"searchable" arguments, respectively. For ideas on the former, see 
SQLFORM.search_menu, and for the latter, see SQLFORM.build_query.

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: Grid search and clear buttons don't restore request.args. Where can I correct that?

2019-04-29 Thread Anthony
What do you mean by master-child pages? Are you using smartgrid? Can you 
show some code?

On Monday, April 29, 2019 at 6:15:30 PM UTC-4, jcrma...@gmail.com wrote:
>
> Grid search and clear buttons don't restore request.args. Where can I 
> correct that?
>
>
> If using master-child pages, the master grid search works fine (because 
> there are no request.args), but the child grid (which has request.args, 
> from the master record) doesn't because the search and clear buttons don't 
> restore the request.args.
>
>
> web2py 2.18.5
> Python 3.7.1 x86
> Firefox 66.0.3 x64
> Windows 7 Pro x64 SP1+all upds
>

-- 
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 convert my view to pdf

2019-04-29 Thread Paul Ellis
This is really hard to answer because a PDF has a set page size and a HTML 
file (view) does not. 

Plus getting the css used in a HTML file to translate into css is also a 
challenge. Just print the page you are talking about with a pdf printer 
driver to see. You probably won't be happy with the results, and if you 
are. The next person to print this way won't be.

I have PDF output from my webapp but I have put a lot of work into the 
formatting of the output and it is not a direct swap from a html. I 
actually have no HTML input into my PDF view.

On Wednesday, 14 November 2018 11:52:36 UTC+1, mostwanted wrote:
>
> I have been researching this topic alot because i am trying to achieve 
> this, i want to convert my view exactly as it to PDF, i came across some 
> information on web2py-appreport but I don't understand exactly how it 
> works, maybe its my slow mind, i followed the examples in 
> https://github.com/lucasdavila/web2py-appreport/wiki/Docs-and-examples 
> but the results are not what i want.
>
> I wanna have a button on my view which when i click converts that view in 
> to pdf straight away and have it saved. Is this possible and if so how can 
> i achieve it?
>
> (Smiles :) 
>
> Mostwanted.
>
>

-- 
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] pyDAL -> jsDAL?

2019-04-29 Thread Scott Hunter

The direction from web2py to web3py seems to be applications where the 
server is responsible for (relatively) static pages which use Javascript 
for their dynamic aspects & talking to the server via an API, primarily for 
interaction w/ the database.

In the spirit of Progressive Web Apps, one could imagine getting to the 
point where instead of making calls to the server, Javascript functions are 
called instead to interact w/ an SQLite DB under the browser's control. 
 Doing so via something like pyDAL, but replacing Python with Javascript & 
only needing to support SQLite would not only ease the burden of writing 
such code, but make it easier to make a transition between these two DB 
locations.

I'm actually thinking specifically of being able to deploy a pared-down 
version of a "normal" application which could perform most of its 
functionality off-line, and use online access only for transferring 
information in bulk between the local DB and the one in the cloud.  The 
more that those applications can share code, the better.  (I've 
accomplished this goal, somewhat clunkily, by deploying the web2py binary 
w/ a limited version of the app in the cloud; an approach as I've described 
above seems that it wouldn't be nearly as brittle.)

Does this make any sense?  Would something like a jsDAL be prohibitively 
difficult to write, or not really worth the effort?

-- 
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 Windows edition with 3.x Interpreter

2019-04-29 Thread rāma
Hi Nico,

Thanks for your inputs.

I've actually run windows py2.7 binary with modules within site-packages, 
and pip can be leveraged by setting your target folder like this: pip 
install -t site-packages . Just for the benefit of other 
readers. It's just that pandas didn't quite work for me in py2.7 and ported 
my code to python 3.5+.

It is convenient to distribute your app and whole web2py as a binary or as 
a client for desktop users. If we were to package with pynsist with 
webview: https://github.com/takluyver/pynsist/tree/master/examples/pywebview it 
can act *like *a standalone binary app on Windows or Mac masking the local 
web address. I also see a value in this as a way forward to have python 
based program running like a program locally on a client rather in the 
cloud wherever necessary cloud sync can be employed. I have not been 
successful with pynsist though.

Best,
rama

On Monday, 29 April 2019 20:49:49 UTC+8, Nico Zanferrari wrote:
>
> Hi rama,
>
> first of all, note that the shell.py fix will resolve only the 'cosmethic' 
> problem of the help command (and "copyright", "credits" , "license" 
> commands) that doesn't work in the interactive shell. But it will not 
> change the import problem in any way.
>
>
> According to the manual, if you run web2py *from source* you can import 
> from it any python module that is in the PYTHONPATH (sys.path) - which is 
> automatically changed by web2py in order to include also 
> web2py/site-packages (globally) and web2py/application/yourapp/modules 
> (inside yourapp). 
> The last one is preferred if you are planning to distribute the app or you 
> are experimenting with different versions of the same module. It also has 
> higher priority and can even be accessed by other apps as 
> web2py/application/anotherapp/modules.
>
> If you run web2py *from the compiled binary*, any system-wide folder will 
> be ignored - only what's down the web2py folder will be available. Modules 
> can be placed on the folders: web2py, web2py/site-packages (globally for 
> all the apps) and web2py/application/yourapp/modules (inside yourapp). You 
> can check it by yourself with the interactive shell and the simple 
> helloworld.py module.
>
> What's different and problematic in the 'running from binary' is that you 
> cannot use pip (or similar) for installing modules inside. You instead have 
> to pip-install them on a full system (that has python of the same version 
> of the binary one) and manually copy the related files inside the binary 
> folders. For complex module like pandas, you also have to copy all the 
> files for the related pre-requisites - and possibly test them one by one.
>
Unfortunately, this could fail - expecially if the modules have binary 
> files. In this case, the last resort is to try to compile the binary 
> version by yourself from a working web2py source - following the 
> instructions on my repository and specifying your additional needed 
> modules. Maybe PyInstaller will play the module dependency game better than 
> you ;-)
>
>
> I've also copied these advices on this howto page 
>  
> for 
> future reference - feel free to correct me if I was wrong somewhere!
>
>
> Cheers,
> Nico 
>
>
> Il giorno lun 29 apr 2019 alle ore 04:24 rāma  > ha scritto:
>
>> Hi Nico,
>>
>> Thank you for the insights. I am actually importing a number of modules 
>> within the controllers fyi, not only via shell.
>>
>> Would patching shell.py fix the behaviour application wide?
>>
>> Do you suggest I pip install into site-packages again instead of copying 
>> from my source version? I suspect that it's not going to fix it.
>>
>> Folder structure:
>> web2py
>>|_site-packages <- here's where my modules are
>>
>> I am trying to package and bundle the whole web2py for work as an app 
>> solution and for test release soon.
>> Your experimental binaries would definitely help me to do early test with 
>> users while waiting for the official binaries. I could do some quick 
>> patches on web2py if required too, please advise how.
>>
>> Best,
>> rama
>>
>> On Monday, 29 April 2019 05:30:55 UTC+8, Nico Zanferrari wrote:
>>>
>>> I've found why the help command (and "copyright", "credits" , 
>>> "license")  it's missing. It's due to the fact that PyInstaller replaces 
>>> the original python module 'site'  with a fake one 
>>> 
>>>  
>>> that contains this comment:
>>>
>>>
>>> "This is a fake 'site' module available in default Python Library.
>>>
>>> The real 'site' does some magic to find paths to other possible
>>> Python modules. We do not want this behaviour for frozen applications.
>>>
>>> Fake 'site' makes PyInstaller to work with distutils and to work inside
>>> virtualenv environment."
>>>
>>> It's possible to change this behaviour on gluon/shell.py by adding the 
>>> missing code - I'm setting

[web2py] Add recoCrud form into modal

2019-04-29 Thread Cristina Sig


Hello everyone,


I have a button to add records. What I am trying to do is when I click on 
it I want to display a modal that contains a Crud form to create/add a new 
record. 

Something like this Example 


Any suggestions to do that?
This is my try


Controller

def Person():
person= db(db.Person.id>0).select()
return dict(formListar=person)


View


 $('#add').click(function(e) {
 e.preventDefault();
 btn = $(this);
 thisHref = btn.attr('href');
 $('#myModalAdd').modal('show')
 .one('click', '#warning', function(e) {
window.location = thisHref;});
 });



 Add Person



  

  
   Add Person
  
  
   
   {{=formListar}}
   
  
  
  
 

  





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