[web2py] Re: redirecting domain

2019-06-20 Thread Dave S


On Thursday, June 20, 2019 at 12:44:49 PM UTC-7, Vlad wrote:
>
> what's the most efficient way to redirect domain to another domain 
> entirely on a level of web2py?
>

That depends on which efficiency you are after.

Do you want the move to be in the browser history?  Then use the 
redirect(call).

If you don't need the move to be in the browser history, and want the 
fastest response,
call the other domain's functions from your current domain's app.
(You could probably still make back- and forwards- history work with 
javascript,
which I think some SPAs make use of.)

If you didn't need the current domain to do anything with the request, then 
the global (er, top-level) routes.py may be able to help.

/dps

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


[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 &
cd
git clone https://github.com/web2py/web3py
cd web3py
pip3 install pytest mechanize twine
pip3 install -U -r requirements.txt
make test
python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
mkdir apps/_scaffold/databases
mkdir apps/examples/databases
touch apps/__init__.py
./web3py-start -p password.txt -a 0.0.0.0:8000 apps

*note :*
- test put the steps above in Dockerfile and build it, not work due to 
/bin/sh: git not found, still find the solution
- test python base image (just pull the base image), seems heavier than 
ubuntu or debian or alpine
- if test using ngrok in alpine consider using 386 version, amd64 not work 
in alpine, ngrok amd64 tested work in ubuntu n debian

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a32cddba-7279-4a2f-90eb-9e24a4eb1c4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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/9a361343-728e-40f0-8b17-40b80abe3747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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!
> 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 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 PM Val K  wrote:
>>
>>> 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 wrote:

 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
 rather as a part of the js code so it breaks.

 How do I encode / convert that field's value so that it wouldn't affect
 html/js on the output?

>>> --
>>> 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/fSTMUW9ObVU/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/254be43e-4d76-4b33-ab2b-7434eaad85b8%40googlegroups.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/fSTMUW9ObVU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/98cd6c0e-d7c2-4e48-bfa1-5316be115b94%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCCgfAaKYGsh7fR4Aw7ayDDArPktOdGwVATDTx53_GRidQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[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 send_application(msg,entrant_XML):
> #Letter for operator
> try:
> oper = mail.send('oper...@domen.ru ','Theme','Letter 
> text...',attachments = files)
> except Exception:
> oper = False
>
> #Letter for entrant
> try:
> abit = mail.send(session.abit_email,'Theme','Letter text...')
> except Exception:
> abit = False
>
> if ((oper==True) & (abit==True)):
> return ('My message',True)
> elif ((oper==True) & (abit==False)):
> return ('My message',False)
> elif ((oper==False) & (abit==True)):
> return ('My message',False)
> Here I don't have that:
> else ((False) & (False)):
> return ('My message',False)
> Now I get return ('My message',True) in 25 percent of the time. How can I 
> improve that result? Maybe I need take several attemts, but without sending 
> two the same letter on one email. We have own mail server.
>
>
>

-- 
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/210e523e-0978-4d83-9418-1ddde4ff5dc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 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 PM Val K > 
> wrote:
>
>> 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 wrote:
>>>
>>> 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 
>>> rather as a part of the js code so it breaks. 
>>>
>>> How do I encode / convert that field's value so that it wouldn't affect 
>>> html/js on the output? 
>>>
>> -- 
>> 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/fSTMUW9ObVU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/254be43e-4d76-4b33-ab2b-7434eaad85b8%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/98cd6c0e-d7c2-4e48-bfa1-5316be115b94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 PM Val K  wrote:

> 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 wrote:
>>
>> 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
>> rather as a part of the js code so it breaks.
>>
>> How do I encode / convert that field's value so that it wouldn't affect
>> html/js on the output?
>>
> --
> 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/fSTMUW9ObVU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/254be43e-4d76-4b33-ab2b-7434eaad85b8%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCCBLBGB44xtNO0OCFLGXPoSy9wd3183pdkmUQM63DFR0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[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 wrote:
>
> 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 
> rather as a part of the js code so it breaks. 
>
> How do I encode / convert that field's value so that it wouldn't affect 
> html/js on the output? 
>

-- 
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/254be43e-4d76-4b33-ab2b-7434eaad85b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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
> return html
> return emailer
> return inner
>
> @with_email_to('j...@google.com')
> def foo():
> ...
>
>
>
>
> On Thursday, June 20, 2019 at 8:39:45 PM UTC+3, Val K wrote:
>>
>> 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 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 to yield rendered view from controller just by
 'return rendered_response'. If controller returns string (not dict) it will
 be sent as is

>>>
>
>
> On Thursday, June 20, 2019 at 8:48:58 PM UTC+3, Vlad wrote:
>>
>> 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
>>> 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 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 to yield rendered view from controller just by
> 'return rendered_response'. If controller returns string (not dict) it 
> will
> be sent as is
>
 --
>>> 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/kb42uKUVs6E/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.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/kb42uKUVs6E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/833e8180-b48e-44de-80db-78e91a15a4a5%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCCsS%2BjJU-5si60Dbdc3Bq9LDWZD_xazaJfk-N8-2_A1nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


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 foo():
...




On Thursday, June 20, 2019 at 8:39:45 PM UTC+3, Val K wrote:
>
> 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 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 to yield rendered view from controller just by 
>>> 'return rendered_response'. If controller returns string (not dict) it will 
>>> be sent as is
>>>
>>


On Thursday, June 20, 2019 at 8:48:58 PM UTC+3, Vlad wrote:
>
> 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
>> 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 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 to yield rendered view from controller just by 
 'return rendered_response'. If controller returns string (not dict) it 
 will 
 be sent as is

>>> -- 
>> 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/kb42uKUVs6E/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/833e8180-b48e-44de-80db-78e91a15a4a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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
> 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 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 to yield rendered view from controller just by
>>> 'return rendered_response'. If controller returns string (not dict) it will
>>> be sent as is
>>>
>> --
> 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/kb42uKUVs6E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCB1S_oWaxvHQs3urUocDxLfdgeCOz%2BJPyo5PcvXHbo6xQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[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 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 to yield rendered view from controller just by 
>> 'return rendered_response'. If controller returns string (not dict) it will 
>> be sent as is
>>
>

-- 
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/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 
rather as a part of the js code so it breaks. 

How do I encode / convert that field's value so that it wouldn't affect 
html/js on the output? 

-- 
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/6bba47cd-aa85-4839-9efd-4ebcc3f45597%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 = False

#Letter for entrant
try:
abit = mail.send(session.abit_email,'Theme','Letter text...')
except Exception:
abit = False

if ((oper==True) & (abit==True)):
return ('My message',True)
elif ((oper==True) & (abit==False)):
return ('My message',False)
elif ((oper==False) & (abit==True)):
return ('My message',False)
Here I don't have that:
else ((False) & (False)):
return ('My message',False)
Now I get return ('My message',True) in 25 percent of the time. How can I 
improve that result? Maybe I need take several attemts, but without sending 
two the same letter on one email. We have own mail server.


-- 
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/7c083f22-d1f5-45c5-8f8d-94629eceecca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 to yield rendered view from controller just by 'return 
> rendered_response'. If controller returns string (not dict) it will be sent 
> as is
>

-- 
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/f5c3795e-b9fa-45dd-af81-a853248af0d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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)
- 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/2bceab32-9c85-4dcc-ab7d-96fa12cc3be8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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)
- 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/4f886637-5029-4f2d-a494-31bc4fd686f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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/fb19afb6-8072-400f-bf04-fdf3678d65fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 (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/30914fd0-2a53-4f9d-92b7-90456850caa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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:
- 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/8befe82a-87d0-4466-83ee-ed61e3149a5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 = len(*a.get('fac'))*

AttributeError('str' object has no attribute 'get')

*Variavles*
a : 'data={"fo":["очная","очная","очная"],"fac":["Мех...йство и 
водопользование"],"bud":["Да","Да","Да"]}'
json : I think you 
take me good advice about js object, but now it is python string, not dict.

-- 
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/84ba580c-32e2-4cc1-8ec2-4a2506520bc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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)
- 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/56f22ded-81d1-4462-bf0c-ea01ffdef91d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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/e1b4e938-ec1c-43d0-91cb-773e623fbb4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 non-iterable NoneType objectВерсия
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
Python Python 3.7.3: C:\Python\python.exe (prefix: C:\Python)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File ".\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:\inetpub\wwwroot\applications\application\controllers/bak.py", line 
2101, in 
  File ".\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:\inetpub\wwwroot\applications\application\controllers/bak.py", line 
1625, in send_app
res,flag=send_application(msg,entrant_XML)
TypeError: cannot unpack non-iterable NoneType object

Error snapshot [image: help] 


TypeError(cannot unpack non-iterable NoneType object)

inspect attributes
Frames
   
   - 
   
   *File C:\inetpub\wwwroot\gluon\restricted.py in restricted at line 219* 
   код аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\applications\application\controllers\bak.py in 
at line 2101* код аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\gluon\globals.py in  at line 421* код 
   аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\applications\application\controllers\bak.py in 
   send_app at line 1625* код аргументы переменные
   Function argument list
   
   ()
   Code listing
   
   1620.
   1621.
   1622.
   1623.
   1624.
   1625.
   1626.
   1627.
   1628.
   1629.
   
   )
   )
   if form.process(formname='form',onvalidation=check_agreement).accepted:
   msg=create_application(rectorRank,rectorName,vuzName)
   entrant_XML=create_XML_entrant(form.vars.abit_pass)
   res,flag=send_application(msg,entrant_XML)
   if flag:
   heading = ''
   statement = ''
   clear_abit_app()
   
   Variables
   res undefined
   flag undefined
   global send_application 
   msg 'My text'
   entrant_XML '\n \n 
   \n \n '
   

-- 
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/783569fd-af3d-47fa-b75c-704b551f1de2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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":["Мелиорации, водного хозяйства 
и строительства имени А.Н.Костякова","Мелиорации, водного хозяйства и 
строительства имени А.Н.Костякова","Механики и энергетики имени 
В.П.Горячкина"],"dir":["Строительство","Гидромелиорация","Агроинженерия"],
"cg_id":["6","32","29"],"comp_group":["Строительство","Гидромелиорация","Агроинженерия.
 
Тех. системы в агробизнесе; Тех. сервис в АПК; Машины и оборудование для 
хран. и перераб. с.-х. продукции"],"bud":["Да","Да","Да"]}
If I do it:
jQuery.ajax({
type: "POST",
url: "{{=URL('useCalc','sess')}}",
data: 
'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)+']}',
cache: false
});
Controller:
import json
a = json.loads(request.vars.data)
I have error:
Ticket ID

91.210.96.2.2019-06-20.09-46-31.de5115b4-e6fb-4b0f-92dd-22ce59c495da
 Unterminated string starting at: 
line 1 column 440 (char 439)Версия
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
Python Python 3.7.3: C:\Python\python.exe (prefix: C:\Python)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File ".\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:\inetpub\wwwroot\applications\application\controllers/useCalc.py", 
line 663, in 
  File ".\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:\inetpub\wwwroot\applications\application\controllers/useCalc.py", 
line 642, in sess
a = json.loads(request.vars.data)
  File "C:\Python\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
  File "C:\Python\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python\lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 
440 (char 439)

Error snapshot [image: help] 


JSONDecodeError(Unterminated string starting at: line 1 column 440 (char 
439))

inspect attributes
Frames
   
   - 
   
   *File C:\inetpub\wwwroot\gluon\restricted.py in restricted at line 219* 
   код аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\applications\application\controllers\useCalc.py 
   in  at line 663* код аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\gluon\globals.py in  at line 421* код 
   аргументы переменные
   - 
   
   *File C:\inetpub\wwwroot\applications\application\controllers\useCalc.py 
   in sess at line 642* код аргументы переменные
   - 
   
   *File C:\Python\lib\json\__init__.py in loads at line 348* код аргументы 
   переменные
   - 
   
   *File C:\Python\lib\json\decoder.py in decode at line 337* код аргументы 
   переменные
   - 
   
   *File C:\Python\lib\json\decoder.py in raw_decode at line 353* код 
   аргументы переменные
   Function argument list
   
   (self=, 
   s='{"fo":["очная","очная","очная"],"fac":["Мелиорац...ексов","Агроинженерия. 
   Тех. системы в агробизнесе', idx=0)
   Code listing
   
   347.
   348.
   349.
   350.
   351.
   352.
   353.
   354.
   355.
   356.
   
   
   This can be used to decode a JSON document from a string that may
   have extraneous data at the end.
   
   """
   try:
   obj, end = self.scan_once(s, idx)
   except StopIteration as err:
   raise JSONDecodeError("Expecting value", s, err.value) from None
   return obj, end
   
   Variables
   obj undefined
   end undefined
   self 
   self.scan_once <_json.Scanner object>
   s '{"fo":["очная","очная","очная"],"fac":["Мелиорац...ексов","Агроинженерия. 
   Тех. системы в агробизнесе'
   idx 0
   

-- 
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/d33d1a31-d794-42fa-b6a3-0ae0ac2220dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.