Commit Graph

89 Commits

Author SHA1 Message Date
Aymeric Augustin fc10418fba Fixed #18963 -- Used a subclass-friendly pattern
for Python 2 object model compatibility methods.
2012-11-03 22:07:35 +01:00
Preston Holmes e7723683dc Fixed #9279 -- Added ignorenonexistent option to loaddata
Thanks to Roman Gladkov for the initial patch and Simon Charette for review.
2012-09-30 23:40:27 -07:00
Claude Paroz ebc773ada3 Replaced many smart_bytes by force_bytes
In all those occurrences, we didn't care about preserving the
lazy status of the strings, but we really wanted to obtain a
real bytestring.
2012-08-29 11:20:32 +02:00
Claude Paroz f2fe7a3e36 [py3] Fixed serializers tests 2012-08-14 19:54:53 +02:00
Claude Paroz 7d0f883192 [py3] Fixed JSON deserialization 2012-08-11 23:23:31 +02:00
Aymeric Augustin 5c09c59bc7 [py3] Renamed `next` to `__next__` in iterators.
See PEP 3114. `next` is retained as an alias for Python 2.
2012-08-09 14:36:05 +02:00
Claude Paroz db729266d6 [py3] Fixed 'iterable but non string' detection
In Python 3, the str type has an __iter__ attribute. Therefore, the
presence of an __iter__ attribute is not sufficient to distinguish
'standard' iterables (list, tuple) from strings.
2012-08-08 18:02:25 +02:00
Alex Gaynor 4c97101b1f remove a bunch of unnescesarry iterkeys() calls 2012-08-08 07:33:15 -07:00
Aymeric Augustin c5ef65bcf3 [py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under
  Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
  and smart_bytes under Python 2 (which is backwards compatible).
  Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
  want a str.
2012-08-07 12:00:22 +02:00
Aymeric Augustin ee191715ea [py3] Fixed access to dict keys/values/items. 2012-08-07 12:00:22 +02:00
Aymeric Augustin 3cb2457f46 [py3] Replaced basestring by six.string_types. 2012-07-22 09:29:54 +02:00
Claude Paroz 26cb227cfe Fixed #15197 -- Fixed yaml serialization into HttpResponse
Thanks fourga38 for the report and hirokiky at gmail.com for the
initial patch.
2012-06-28 16:29:29 +02:00
Claude Paroz 5bdd0d6b6a Favored text (StringIO) over binary content for deserialization
This is also more Python 3 compatible, as the json module in
Python 3 is expecting text. Thanks Vinay Sajip for noticing it.
2012-06-15 14:49:19 +02:00
Claude Paroz 1a10a06b9f Fixed #18457 -- Fixed encoding error in yaml deserializer
Thanks jpaugh64 for the report.
2012-06-10 19:56:16 +02:00
Claude Paroz 4a103086d5 Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and
Jannis Leidel for the review.
2012-06-07 18:08:47 +02:00
Claude Paroz 3b5083bee5 Fixed #5423 -- Made dumpdata output one row at a time.
This should prevent storing all rows in memory when big sets of
data are dumped.
See ticket for heroic contributors.
2012-05-26 11:43:37 +02:00
Claude Paroz d7dfab59ea Replaced cStringIO.StringIO by io.BytesIO.
Also replaced StringIO.StringIO by BytesIO in some other appropriate
places. StringIO is not available in Python 3.
2012-05-05 21:41:44 +02:00
Claude Paroz 3904b74a3f Fixed #18013 -- Use the new 'as' syntax for exceptions.
Thanks Clueless for the initial patch.
Note that unittest has been purposely left out (external package only used by Python 2.6).
2012-04-29 20:57:15 +02:00
Aymeric Augustin cec6bd5a59 Fixed #18023 -- Removed bundled simplejson.
And started the deprecation path for django.utils.simplejson.

Thanks Alex Ogier, Clueless, and other contributors for their
work on the patch.
2012-04-29 19:58:00 +02:00
Karen Tracey 20c69c5e51 Fix #17879: Corrected regression in python (inherited by yaml and json) serializer that prevented serializing model instances with null FK ref to a model when serializing with natural keys. Thanks danfairs and tmitchell.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17685 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-12 19:41:31 +00:00
Jannis Leidel dd441701ce Fixed #17717 (again) -- Used the new API for concrete models added in r17573. Many thanks to Simon Charette and Anssi Kääriäinen.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17643 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-03 21:34:51 +00:00
Jannis Leidel dc49e6143a Fixed #17717 -- Fixed serialization of proxy models. Thanks, Anssi Kääriäinen.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17640 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-03 17:50:18 +00:00
Jannis Leidel 7019123d21 Fixed the exception handling when deserializing via generators on Python 2.5 that was introduced in r17469. Also only test the YAML serializer if PyYAML is installed.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17487 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-10 01:13:38 +00:00
Jannis Leidel 49288f8388 Fixed #11970 -- Wrapped the exception happening during deserialization in DeserializationError exceptions. Thanks, Claude Paroz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17469 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-09 18:56:58 +00:00
Jannis Leidel 62efdcb037 Fixed #17602 -- Stopped the XML serializer from doing unneeded queries. Thanks, gnosek.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17439 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-04 18:27:07 +00:00
Ramiro Morales 5003df3659 Tweaked changes from r17228 to cater for older simplejson versions.
dump() started accepting the `use_decimal` argument in 2.1.3.

Refs #16850.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17229 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-17 23:00:41 +00:00
Ramiro Morales b5d9ad982d Fixed #16850 -- Made sure we always represent Decimal instances with JS strings when serializing.
We force this when calling simplejson dump() to isolate us from changes of
default behavior to encode them with JavaScript numbers instead that could
introduce loss of precision when decoding back from JSON to Python.

Thanks Raphael Hertzog for the report and Bob Ippolito for his help.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-17 22:10:37 +00:00
Aymeric Augustin 9b1cb755a2 Added support for time zones. Thanks Luke Plant for the review. Fixed #2626.
For more information on this project, see this thread:
http://groups.google.com/group/django-developers/browse_thread/thread/cf0423bbb85b1bbf



git-svn-id: http://code.djangoproject.com/svn/django/trunk@17106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-18 13:01:06 +00:00
Aymeric Augustin d71b4309ca Used yaml.safe_load instead of yaml.load, because safety should be the default.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17062 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-01 20:07:42 +00:00
Aymeric Augustin 38999f7e00 Fixed #16923 -- Removed unused method in the serialization code.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16979 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-13 19:39:46 +00:00
Jannis Leidel 24f4764a48 Fixed #16225 -- Removed unused imports. Many thanks to Aymeric Augustin for the work on the patch and Alex for reviewing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-07-13 09:35:51 +00:00
Alex Gaynor 930371e91b Fixed #15889 -- when trying to access to access a serializer that doesn't exist, raise a new SerializerDoesNotExist exception. Thanks to Mathieu Agopian for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-04-26 16:49:32 +00:00
Russell Keith-Magee 4a3ea263ef Fixed #14823 -- Corrected bootstrapping problems with register_serializers. Thanks to miker985@uw.edu for the report and draft patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15336 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-27 02:29:17 +00:00
Andrew Godwin 614672d365 Fixed #14888 -- Removing duplicated code in serialisers. Thanks to eric.fortin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-08 15:07:45 +00:00
Russell Keith-Magee e299ac0cae Reverting r14994 (at request of SmileyChris) because of some backwards compatibility issues that need to be resolved.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14995 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-21 06:05:40 +00:00
Chris Beaven b60d5df072 Fixes #13252 -- Use the natural key instead of the primary key when serializing
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14994 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-21 04:40:08 +00:00
Russell Keith-Magee f964a3b1ee Fixed #14819 -- Corrected typo in serializer docstring. Thanks to stringify for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14789 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-04 04:27:05 +00:00
Russell Keith-Magee 11aee35a9f Fixed #11486 -- Corrected the XML serializer to allow for the serialization of objects with a null PK value. Also includes migration of doctests to unittests (we have always been at war with doctests). Thanks to zdmytriv for the report, and Niall Kelly for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13862 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-09-19 14:04:34 +00:00
Russell Keith-Magee 5211f48ae3 Fixed #12164 -- Removed the Python 2.3 compatibility imports and workarounds. Thanks to timo and claudep for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-04 14:00:30 +00:00
Russell Keith-Magee 10de2a837f Fixed #13030 -- Corrected natural key deserialization to subclasses. Thanks to yishaibeeri for the report and test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-18 15:22:15 +00:00
Russell Keith-Magee ff60c5f9de Fixed #1142 -- Added multiple database support.
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project.
Congratulations to Alex for a job well done.

Big thanks also go to:
 * Justin Bronn for keeping GIS in line with the changes,
 * Karen Tracey and Jani Tiainen for their help testing Oracle support
 * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback.
 * Malcolm Treddinick for his guidance during the GSoC submission process.
 * Simon Willison for driving the original design process
 * Cal Henderson for complaining about ponies he wanted.

... and everyone else too numerous to mention that helped to bring this feature into fruition.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-22 15:18:51 +00:00
Russell Keith-Magee 35cc439228 Fixed #7052 -- Added support for natural keys in serialization.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11863 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-14 12:39:20 +00:00
Russell Keith-Magee 585b7acaa3 Fixed #10109 -- Removed the use of raw SQL in many-to-many fields by introducing an autogenerated through model.
This is the first part of Alex Gaynor's GSoC project to add Multi-db support to Django.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11710 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-03 14:02:49 +00:00
Russell Keith-Magee cb43898d49 Fixed #9522 -- Modified handling of values in base serializer so that field subclasses can define their own value_to_string() method for serialization. Thanks to Alex Koshelev for the report and initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10554 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-13 12:35:49 +00:00
Jacob Kaplan-Moss c485e236bd Fixed #8193: all dynamic imports in Django are now done correctly. I know this because Brett Cannon borrowed the time machine and brought Python 2.7's '`importlib` back for inclusion in Django. Thanks for the patch-from-the-future, Brett!
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10088 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-18 16:55:59 +00:00
Brian Rosner e4e964510c Fixed #10240 -- Restored YAML serialization with Decimal objects that broke with r9823. Thanks Alex Gaynor for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9825 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-02-12 02:54:39 +00:00
Jacob Kaplan-Moss 9f59fc5560 Fixed #8651: correctly deserialize objects with 0 for pk/fk.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8676 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-28 19:38:56 +00:00
Gary Wilson Jr c2ba59fc1d Removed oldforms, validators, and related code:
* Removed `Manipulator`, `AutomaticManipulator`, and related classes.
 * Removed oldforms specific bits from model fields:
   * Removed `validator_list` and `core` arguments from constructors.
   * Removed the methods:
     * `get_manipulator_field_names`
     * `get_manipulator_field_objs`
     * `get_manipulator_fields`
     * `get_manipulator_new_data`
     * `prepare_field_objs_and_params`
     * `get_follow`
   * Renamed `flatten_data` method to `value_to_string` for better alignment with its use by the serialization framework, which was the only remaining code using `flatten_data`.
 * Removed oldforms methods from `django.db.models.Options` class: `get_followed_related_objects`, `get_data_holders`, `get_follow`, and `has_field_type`.
 * Removed oldforms-admin specific options from `django.db.models.fields.related` classes: `num_in_admin`, `min_num_in_admin`, `max_num_in_admin`, `num_extra_on_change`, and `edit_inline`.
 * Serialization framework
   * `Serializer.get_string_value` now calls the model fields' renamed `value_to_string` methods.
   * Removed a special-casing of `models.DateTimeField` in `core.serializers.base.Serializer.get_string_value` that's handled by `django.db.models.fields.DateTimeField.value_to_string`.
 * Removed `django.core.validators`:
   * Moved `ValidationError` exception to `django.core.exceptions`.
   * For the couple places that were using validators, brought over the necessary code to maintain the same functionality.
 * Introduced a SlugField form field for validation and to compliment the SlugField model field (refs #8040).
 * Removed an oldforms-style model creation hack (refs #2160).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8616 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-27 07:19:44 +00:00
Russell Keith-Magee 0c115f12d7 Fixed #7676 -- Modified serializer registration to be thread safe. Thanks to mrts for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8370 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-15 11:53:49 +00:00
Russell Keith-Magee 63ea57642d Fixed #8134 -- Corrected serialization of m2m fields with intermediate models. Thanks to Rock Howard for the report, and kire for the test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8321 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-12 12:58:33 +00:00