Greetings.

I have some strange behavior when saving to my DB.

Here is my DB schemer:

db.define_table('messages',
    Field <https://apps00.cs.lldns.net:8000/examples/global/vars/Field>('uid', 
'string'),
    Field 
<https://apps00.cs.lldns.net:8000/examples/global/vars/Field>('message', 
'text'),
    Field 
<https://apps00.cs.lldns.net:8000/examples/global/vars/Field>('status', 
'string', default='unsent'),
    Field 
<https://apps00.cs.lldns.net:8000/examples/global/vars/Field>('added', 
'datetime', default=request 
<https://apps00.cs.lldns.net:8000/examples/global/vars/request>.now),
    Field 
<https://apps00.cs.lldns.net:8000/examples/global/vars/Field>('modified', 
'datetime', default=request 
<https://apps00.cs.lldns.net:8000/examples/global/vars/request>.now))


My Controller:

@service.jsonrpc

def savemessage(message, uid):
    db.messages.insert(message=message, uid=uid)
    db.commit()
    
    message = {"status":"saved"}

    return message


Curl script to send message via jsonrpc:

message=$1
uid=$2

url = someURL.com
curl -v -k -X POST -H "Content-Type: application/json" -d "{\"id\": 1, 
\"method\": \"savemessage\", \"params\": { \"${message}\": \"mymessage\", 
\"${uid}\" : \"myemail@localhost\"}}" $url


Command line command:

./send_irc_message.sh "This is my message" [email protected]


So the first thing to note is that for the params, the value of ${message} 
is being saved rather than mymessage. Similarly the value for ${uid} is 
being saved instead of myemail@localhost

Have I got the script syntax correct?

At a push I could live with this except sporadically, even the value of 
${message} gets saved as the uid in the DB and visa versa. I can't seem to 
consistently replicate this behavior. It just does it from time to time.

When I print out $message and $uid from my curl script, the values are 
correct at this point so it has to be the curl script. Can anyone see 
something I clearly cannot?

Thanks in advance.

-Mike

-- 



Reply via email to