[Pulp-list] [dev] create custom mongoengine field for datetime?
mhrivnak at redhat.com
Mon Nov 23 17:04:31 UTC 2015
Following up on this: https://github.com/pulp/pulp/pull/2067/files
... the problem seems to be that mongoengine's DateTimeField does not
attach a timezone to the datetime objects it pulls out of the DB, but some
(most? all?) parts of pulp expect to compare datetimes that DO have a
timezone. I've already seen the same error show up in additional places,
particularly in plugins.
Of course all datetimes stored in the DB are supposed to be in UTC.
We could create a UTCDateTimeField that just overrides the to_python()
method and calls the above-referenced ensure_tz() function on the value.
Without doing much digging, it seems like this would be the quickest path
to consistency. The other option is to standardize on NOT having timezones
on datetime objects, and assuming UTC. That seems marginally riskier, but
not greatly so. It would probably require more work.
Continuing to sprinkle calls to ensure_tz() all over the code base seems
like a messy way to address the issue.
Thoughts? Perhaps those who have been heavily involved in the mongoengine
conversion already have considered this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pulp-list