And now the inevitable question:
In addition to the unicode field type is there a string one?
I've l read the docs but can't seem to find the answer.
My code is becoming peppered with u'...' and unicode(...) noise and I'm always
forgetting the conversion and getting validation exceptions. I know that MongoDB
stores Unicode but PyMongo seems to handle strings transparently.
Cheers, Stuart
On Sun, Mar 27, 2011 at 9:01 AM, Stuart Rackham <srac...@gmail.com> wrote:
> A big thank you for MongoKit!
Thank you :)
> And now the inevitable question:
> In addition to the unicode field type is there a string one?
> I've l read the docs but can't seem to find the answer.
I recently add the basestring type in authorized types. You can find
it in the devel branch of Mongokit.
https://github.com/namlook/mongokit/commit/0ebc115e850c23d34ce59104c50a9599379691b3
You can add it yourself in your code like this:
class MyDoc(Document):
authorized_types = Document.authorized_types+[basestring]
structure = {...}
> My code is becoming peppered with u'...' and unicode(...) noise and I'm
> always forgetting the conversion and getting validation exceptions. I know
> that MongoDB stores Unicode but PyMongo seems to handle strings
> transparently.
The reason I initialy made Mongokit to accept only unicode strings was
to be sure that strings are correctly encoded and to prevent some
surprises at runtime. But I understand that it could be annoying some
time. Next version will fix that.
N.
On 28/03/11 07:14, Nicolas Clairon wrote:
> Hi,
>
> On Sun, Mar 27, 2011 at 9:01 AM, Stuart Rackham<srac...@gmail.com> wrote:
>> A big thank you for MongoKit!
>
> Thank you :)
>
>> And now the inevitable question:
>> In addition to the unicode field type is there a string one?
>> I've l read the docs but can't seem to find the answer.
>
> I recently add the basestring type in authorized types. You can find
> it in the devel branch of Mongokit.
>
> https://github.com/namlook/mongokit/commit/0ebc115e850c23d34ce59104c50a9599379691b3
>
> You can add it yourself in your code like this:
>
> class MyDoc(Document):
> authorized_types = Document.authorized_types+[basestring]
> structure = {...}
Thanks for such a prompt reply, I switched to the devel branch and it works like
a charm!
Stuart
--
---
You received this message because you are subscribed to the Google Groups "MongoKit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongokit+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.