Changeset 2513

Show
Ignore:
Timestamp:
01/29/10 08:58:23 (6 weeks ago)
Author:
JensDiemer
Message:
  • Bugfix: Write fixture file in UTF-8.
  • Change fixture filename to "pylucid.json"
  • TODO: add FIXTURE_FILENAME and FIXTURE_PATH to BaseCommand?.option_list
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid_admin/management/commands/create_initialdata.py

    r2345 r2513  
    66    The serialized data must be sorted by topology.  
    77    Otherwise the dump can't insert back into the database. 
     8     
     9    TODO: add FIXTURE_FILENAME and FIXTURE_PATH to BaseCommand.option_list 
    810""" 
    911import os 
     12import codecs 
    1013import pprint 
    1114from optparse import make_option 
     
    4851] 
    4952 
    50 FIXTURE_FILENAME = "initial_data.json" 
     53FIXTURE_FILENAME = "pylucid.json" 
    5154 
    5255FIXTURE_PATH = os.path.join(settings.PYLUCID_PROJECT_ROOT, "apps", "pylucid_admin", "fixtures") 
     
    130133        print "Serialize data and save it into %r..." % FIXTURE_FILENAME 
    131134        try: 
    132             with open(file_path, "w") as out: 
     135            with codecs.open(file_path, "w", encoding="utf-8") as out: 
    133136                json_serializer.serialize(objects, indent=options['indent'], stream=out, 
    134137                    ensure_ascii=False # http://docs.djangoproject.com/en/dev/topics/serialization/#notes-for-specific-serialization-formats