[web2py] Re: Web3py

2019-06-20 Thread 黄祥
as question on github, here another alternative works without using ubuntu or debian image base file (which posted on prev msg) docker pull alpine docker run -it --privileged alpine /bin/sh apk add --no-cache git py3-pip memcached gcc python3-dev musl-dev make /usr/bin/memcached -u memcached &

[web2py] redirecting domain

2019-06-20 Thread Vlad
what's the most efficient way to redirect domain to another domain entirely on a level of web2py? -- 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

Re: [web2py] Re: form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Eliezer (Vlad) Tseytkin
Oops! this is brilliant! Thank you!! I just had to introduce one extra step due to the way how json dumps strings: if string.startswith('"') and string.endswith('"'): string = string[1:-1] On Thu, Jun 20, 2019 at 3:09 PM Val K wrote: > Enter code here... > > Eureka! there is json! >

[web2py] Re: Error in app: cannot unpack non-iterable NoneType object

2019-06-20 Thread Val K
1. & - is bitwise operator (just in case) 2. why not just return ('My message', oper and abit) On Thursday, June 20, 2019 at 8:30:30 PM UTC+3, Константин Комков wrote: > > I need add more information. Can error may be caused if my function don't > have one condition: > def

Re: [web2py] Re: form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Val K
Enter code here... Eureka! there is json! safe_js_str = json.dumps(string_with_any_bad_char) now you can insert it in js code as 'var s = %s' % safe_js_str # it is already quoted On Thursday, June 20, 2019 at 9:54:43 PM UTC+3, Vlad wrote: > > the problem is that I don't know what they may

Re: [web2py] Re: form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Eliezer (Vlad) Tseytkin
the problem is that I don't know what they may enter, it could be anything. I just need to feed back whatever they entered in the middle of some js action. the objective is that whatever they enter - any characters - should simply be taken as a string by the browser On Thu, Jun 20, 2019 at 2:52

[web2py] Re: form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Val K
I think there is no universal way because js is just a string in python context, you have to escape quotes with backslash (replace " with \") where it is required to prevent crumbling strings in js-code What is the second char? dot? On Thursday, June 20, 2019 at 8:32:08 PM UTC+3, Vlad

Re: [web2py] Re: emailing the content of the current page

2019-06-20 Thread Eliezer (Vlad) Tseytkin
this is simply awesome! thank you ! On Thu, Jun 20, 2019 at 2:07 PM Val K wrote: > #pretty decorator > def with_email_to(addr): > def inner(f): > def emailer(): > ret = f() > html = response.render(ret) > ... # send html to addr by email >

Re: [web2py] Re: emailing the content of the current page

2019-06-20 Thread Val K
#pretty decorator def with_email_to(addr): def inner(f): def emailer(): ret = f() html = response.render(ret) ... # send html to addr by email return html return emailer return inner @with_email_to('j...@google.com') def

Re: [web2py] Re: emailing the content of the current page

2019-06-20 Thread Eliezer (Vlad) Tseytkin
oops got it! changing it right now! simple and brilliant, as always :) On Thu, Jun 20, 2019 at 1:39 PM Val K wrote: > I mean the following logic: > def foo(): > ... > ret = dict(...) > if email_required: > html = response.render(ret) > ... # send html by email >

[web2py] Re: emailing the content of the current page

2019-06-20 Thread Val K
I mean the following logic: def foo(): ... ret = dict(...) if email_required: html = response.render(ret) ... # send html by email return html return ret On Thursday, June 20, 2019 at 8:26:33 PM UTC+3, Vlad wrote: > > I couldn't figure out how this

[web2py] form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Vlad
I have a form with an input text field. The form is submitted via POST. The vars value is read and passed over into response.js to run some action. All works perfect until that field has special characters, like " and the like. Javascript does't like it. It doesn't see that as a string, but

[web2py] Re: Error in app: cannot unpack non-iterable NoneType object

2019-06-20 Thread Константин Комков
I need add more information. Can error may be caused if my function don't have one condition: def send_application(msg,entrant_XML): #Letter for operator try: oper = mail.send('opera...@domen.ru','Theme','Letter text...',attachments = files) except Exception: oper =

[web2py] Re: emailing the content of the current page

2019-06-20 Thread Vlad
I couldn't figure out how this woks, so just rendered it again. Not a big deal - just a matter of convenience. The email requests come occasionally, so this extra render doesn't cause trouble. Thank you, Val! On Thursday, June 20, 2019 at 6:23:55 AM UTC-4, Val K wrote: > > I think you can try

[web2py] Re: Colleagues, how can I generate an identification code automatically?

2019-06-20 Thread Val K
define_table('company') define_table('client', Field('id', 'reference company'), primarykey=['id']) define_table('supplier', Field('id', 'reference company'), primarykey=['id']) On Thursday, June 20, 2019 at 7:02:31 PM UTC+3, Paul Arsenio Blanco Reyes wrote: > > It turns out that I have a

[web2py] Colleagues, how can I generate an identification code automatically?

2019-06-20 Thread Paul Arsenio Blanco Reyes
It turns out that I have a company table, in turn, the company can be classified as a client, as a supplier or both together. How to assign a consecutive to the company according to its classification? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] emailing the content of the current page

2019-06-20 Thread Val K
Also you can hack wsgihandler.py to catch rendered response -- 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

[web2py] Re: Error in json.loads

2019-06-20 Thread Val K
You should pass object to JSON.stringify not string, I mean fill the object with required data and then convert it to string by JSON.stringify, don't build json strings by your hand -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py

[web2py] Re: Error in json.loads

2019-06-20 Thread Константин Комков
P.S. *Val K*, If I do like that in controller and in js as you told all work. *Thank you!* But I don't understant why I need use json.loads twice... > > >- > > import json a = json.loads(request.vars.data) a = json.loads(a) cgCount = len(a.get('fac')) -- Resources:

[web2py] Re: Error in json.loads

2019-06-20 Thread Константин Комков
If i do like that: jQuery.ajax({ type: "POST", url: "{{=URL('useCalc','sess')}}", data: {data: myStrJson}, cache: false }); I have error in controller: import json a = json.loads(request.vars.data) cgCount =

[web2py] emailing the content of the current page

2019-06-20 Thread Val K
I think you can try yield rendered view from controller just by 'return rendered_response'. If controller returns string (not dict) it will be sended as is -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Error in json.loads

2019-06-20 Thread Val K
Try data:{data: JSON.stringify(your_js_object_to_send)} -- 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

[web2py] Error in app: cannot unpack non-iterable NoneType object

2019-06-20 Thread Константин Комков
I have that string in controller: res,flag=send_application(msg,entrant_XML) and send_application function: def send_application(msg,entrant_XML): #my code return('My message',False) I get error: Ticket ID 46.73.180.207.2019-06-20.10-47-49.e820b49a-8731-495f-9156-0d75ad265046 cannot unpack

[web2py] Error in json.loads

2019-06-20 Thread Константин Комков
JS console.log('data={'+fo.slice(0,-1)+'],'+fac.slice(0,-1)+'],'+dir.slice(0,-1 )+'],'+cg_id.slice(0,-1)+'],'+comp_group.slice(0,-1)+'],'+bud.slice(0,-1)+ ']}'); I get that json string: JSON string (from console.log(); in google chrome) data={"fo":["очная","очная","очная"],"fac":["Мелиорации,