<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Hi.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">That is just a common datetime python standard library object, you can convert it to something that can be JSON serialisable just casting it to a string, for example:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><span class="Apple-tab-span" style="white-space:pre"> </span>user_array[‘updated’] = str(user_array[‘updated’])</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Regards.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1397407532157442048" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- </div><div style="font-family:helvetica,arial;font-size:13px">Join the free software foundation and become free as in freedom<br></div></div> <br><p style="color:#000;">On 13 April 2014 at 17:40:28, R Pish (<a href="mailto:rpishcr@gmail.com">rpishcr@gmail.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>


<title></title>


<div dir="ltr">Thanks Oscar!
<div><br></div>
<div>Your example worked perfectly. Now I am thinking on making a
method in the User model called something like "asdictionary()"
which I would call to get the dictionary version of a particular
User object -of course without the references, I would have to
investigate how to get the references and push them into the
dictionary-.</div>
<div><br></div>
<div>So, another question came up; there is a datetime column
called "updated" in the User model, with this code, if I access
user_array["updated"] I get this:</div>
<div><br></div>
<div>'updated': datetime.datetime(2014, 4, 13, 10, 24, 28)
 (which is not json serializable)<br></div>
<div><br></div>
<div>but if I access user.updated I will get: '2014-04-13 10:24:28'
(which is json serializable)</div>
<div><br></div>
<div>Certainly I would have to convert the "dict" version to its
corresponding datetime string representation to make it json
serializable, but I wanted to know if there is something inside
Storm that I would use to make this conversion?</div>
<div><br></div>
<div>Thanks again.</div>
<div>Kind regards.</div>
<div><br></div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-04-13 10:12 GMT-06:00 Oscar Campos
<span dir="ltr"><<a href="mailto:oscar.campos@member.fsf.org" target="_blank">oscar.campos@member.fsf.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
Hi.</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
Let’s say that you have an User model:</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
user = store.find(User, User.email == ‘<a href="mailto:rpishcr@gmail.com" target="_blank">rpishcr@gmail.com</a>’).one()</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
user_array = dict([(<a href="http://p.name" target="_blank">p.name</a>, getattr(user, (<a href="http://p.name" target="_blank">p.name</a>))) for p in
user._storm_columns.values()])</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
Take into consideration that the former will work for simple
properties, meaning that no references will be convert and returned
as dictionary.</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
Regards</div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<br></div>
<div>
<div style="font-family:helvetica,arial;font-size:13px">
-- </div>
<div style="font-family:helvetica,arial;font-size:13px">Join the
free software foundation and become free as in freedom<br></div>
</div>
<div>
<div class="h5"><br>
<p style="">On 13 April 2014 at 07:37:08, R Pish (<a href="mailto:rpishcr@gmail.com" target="_blank">rpishcr@gmail.com</a>)
wrote:</p>
</div>
</div>
<blockquote type="cite">
<div>
<div>
<div>
<div class="h5">
<div dir="ltr"><span>Hi,</span>
<div><span><br></span></div>
<div><span>What is the recommended way to convert a resultset
produced by a call like: store.find(User, User.id == myvarid).one()
?</span></div>
<div><span><br></span></div>
<div><span>Thanks in advance</span></div>
</div>
</div>
</div>
<span><span class="HOEnZb"><font color="#888888">--<br>
storm mailing list<br>
<a href="mailto:storm@lists.canonical.com" target="_blank">storm@lists.canonical.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/storm" target="_blank">https://lists.ubuntu.com/mailman/listinfo/storm</a><br></font></span></span></div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br></div>


</div></div></span></blockquote></body></html>