Hi.
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:
user_array[‘updated’] = str(user_array[‘updated’])
Regards.
--
Join the free software foundation and become free as in freedom
On 13 April 2014 at 17:40:28, R Pish ([email protected]) wrote:
Thanks Oscar!
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-.
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:
'updated': datetime.datetime(2014, 4, 13, 10, 24, 28) (which is not json
serializable)
but if I access user.updated I will get: '2014-04-13 10:24:28' (which is json
serializable)
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?
Thanks again.
Kind regards.
2014-04-13 10:12 GMT-06:00 Oscar Campos <[email protected]>:
Hi.
Let’s say that you have an User model:
user = store.find(User, User.email == ‘[email protected]’).one()
user_array = dict([(p.name, getattr(user, (p.name))) for p in
user._storm_columns.values()])
Take into consideration that the former will work for simple properties,
meaning that no references will be convert and returned as dictionary.
Regards
--
Join the free software foundation and become free as in freedom
On 13 April 2014 at 07:37:08, R Pish ([email protected]) wrote:
Hi,
What is the recommended way to convert a resultset produced by a call like:
store.find(User, User.id == myvarid).one() ?
Thanks in advance
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm