~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/core/serializers/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
_serializers = {}
37
37
 
38
38
def register_serializer(format, serializer_module, serializers=None):
39
 
    """"Register a new serializer. 
40
 
    
 
39
    """"Register a new serializer.
 
40
 
41
41
    ``serializer_module`` should be the fully qualified module name
42
42
    for the serializer.
43
 
    
 
43
 
44
44
    If ``serializers`` is provided, the registration will be added
45
45
    to the provided dictionary.
46
 
    
 
46
 
47
47
    If ``serializers`` is not provided, the registration will be made
48
48
    directly into the global register of serializers. Adding serializers
49
49
    directly is not a thread-safe operation.
53
53
        _serializers[format] = module
54
54
    else:
55
55
        serializers[format] = module
56
 
        
 
56
 
57
57
def unregister_serializer(format):
58
58
    "Unregister a given serializer. This is not a thread-safe operation."
59
59
    del _serializers[format]
87
87
    s.serialize(queryset, **options)
88
88
    return s.getvalue()
89
89
 
90
 
def deserialize(format, stream_or_string):
 
90
def deserialize(format, stream_or_string, **options):
91
91
    """
92
92
    Deserialize a stream or a string. Returns an iterator that yields ``(obj,
93
93
    m2m_relation_dict)``, where ``obj`` is a instantiated -- but *unsaved* --
95
95
    list_of_related_objects}``.
96
96
    """
97
97
    d = get_deserializer(format)
98
 
    return d(stream_or_string)
 
98
    return d(stream_or_string, **options)
99
99
 
100
100
def _load_serializers():
101
101
    """