I'm playing with django.core.serializers... so far with few success :(

With JSON i get the Error: "ContentType matching query does not exist."

If i use the "python" format, i get from serializers.serialize() a list. 
How should I to store these list in a file? With pickle, repr() or 
unicode()???

With pickle, i got the Error: "can't pickle array objects"

if i use "python" and store the result with repr() or unicode() in a 
file... I got an error, if i load the file and deserialize it:
------------------------------------------------------------------------
   File ".\django\core\serializers\python.py", line 59, in Deserializer
     Model = _get_model(d["model"])
TypeError: string indices must be integers
------------------------------------------------------------------------


If i use the "xml" format, i get an Error if i deserialize the 
serialized string:
------------------------------------------------------------------------
   File "serializers_test.py", line 77, in test_xml
     for object in objects2:
   File ".\django\core\serializers\xml_serializer.py", line 115, in next
     return self._handle_object(node)
   File ".\django\core\serializers\xml_serializer.py", line 155, in 
_handle_object
     value = 
field.to_python(getInnerText(field_node).strip().encode(self.encoding))
   File ".\django\db\models\fields\__init__.py", line 525, in to_python
     raise validators.ValidationError, gettext('Enter a valid date/time 
in YYYY-MM-DD HH:MM format.')
django.core.validators.ValidationError: ['Enter a valid date/time in 
YYYY-MM-DD HH:MM format.']
------------------------------------------------------------------------

I examined this. The XML file is correct. In the DB (the source) i have 
datetime fields with a NULL value.


XML file cutout:
------------------------------------------------------------------------
<object pk="1" model="PyLucid.group">
   <field type="IntegerField" name="pluginID">0</field>
   <field type="CharField" name="name">managePages</field>
   <field type="CharField" name="section">core</field>
   <field type="CharField" name="description">blabla</field>
   <field type="DateTimeField" name="lastupdatetime"></field>
   <field type="IntegerField" name="lastupdateby">None</field>
   <field type="DateTimeField" name="createtime"></field>
</object>
------------------------------------------------------------------------


The Traceback is interesting (cutout):

.\django\core\serializers\xml_serializer.py in _handle_object line 155:
------------------------------------------------------------------------
Model: <class 'PyLucid.models.Group'>

data: {'description': 'This group is able to add/edit/delete pages.', 
'id': u'1', 'name': 'managePages', 'pluginID': '0', 'section': 'core'}

field: <django.db.models.fields.DateTimeField object at 0x01477570>
field_name: u'lastupdatetime'
field_node: <DOM Element: field at 0x16568a0>
m2m_data: {}
node: <DOM Element: object at 0x1659990>
pk: u'1'
self:<django.core.serializers.xml_serializer.Deserializer object at 
0x016A7190>
value: 'blabla'
------------------------------------------------------------------------

In 'data' i missing the keys 'lastupdatetime' and 'createtime'.
I find field_name == 'lastupdatetime', but value == 'blabla' also 
amusing. Because you can see from above: 'blabla' is the value for the 
key 'description' and not from 'lastupdatetime'

-- 
Mfg.

Jens Diemer


----
CMS in pure Python CGI: http://www.pylucid.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to