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":["Мелиорации, водно
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-
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 subscrib
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.g
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
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:
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 (S
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 sub
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.co
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 compan
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
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 = Fa
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
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 wok
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
>
#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()
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
>
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 wro
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 P
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 e
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,e
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
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
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 &
c
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
25 matches
Mail list logo