Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: frontend/afe/model_logic.py

Issue 6181003: Add support for an --image flag to atest. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 """ 1 """
2 Extensions to Django's model logic. 2 Extensions to Django's model logic.
3 """ 3 """
4 4
5 import re 5 import re
6 import django.core.exceptions 6 import django.core.exceptions
7 from django.db import models as dbmodels, backend, connection 7 from django.db import models as dbmodels, backend, connection
8 from django.db.models.sql import query 8 from django.db.models.sql import query
9 import django.db.models.sql.where 9 import django.db.models.sql.where
10 from django.utils import datastructures 10 from django.utils import datastructures
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 else: 670 else:
671 to_val, from_val = choice_data 671 to_val, from_val = choice_data
672 if from_val == data[field_name]: 672 if from_val == data[field_name]:
673 data[field_name] = to_val 673 data[field_name] = to_val
674 break 674 break
675 # convert foreign key values 675 # convert foreign key values
676 elif field_obj.rel: 676 elif field_obj.rel:
677 dest_obj = field_obj.rel.to.smart_get(data[field_name], 677 dest_obj = field_obj.rel.to.smart_get(data[field_name],
678 valid_only=False) 678 valid_only=False)
679 if to_human_readable: 679 if to_human_readable:
680 if dest_obj.name_field is not None: 680 # parameterized_jobs do not have a name_field
681 if (field_name != 'parameterized_job' and
682 dest_obj.name_field is not None):
681 data[field_name] = getattr(dest_obj, 683 data[field_name] = getattr(dest_obj,
682 dest_obj.name_field) 684 dest_obj.name_field)
683 else: 685 else:
684 data[field_name] = dest_obj 686 data[field_name] = dest_obj
685 687
686 688
687 @classmethod 689 @classmethod
688 def validate_field_names(cls, data): 690 def validate_field_names(cls, data):
689 'Checks for extraneous fields in data.' 691 'Checks for extraneous fields in data.'
690 errors = {} 692 errors = {}
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1175
1174 The exception is that save(force_insert=True) will be allowed, since 1176 The exception is that save(force_insert=True) will be allowed, since
1175 that creates a new row. However, the preferred way to make instances of 1177 that creates a new row. However, the preferred way to make instances of
1176 these models is through the get_or_create() method. 1178 these models is through the get_or_create() method.
1177 """ 1179 """
1178 if not force_insert: 1180 if not force_insert:
1179 # Allow a forced insert to happen; if it's a duplicate, the unique 1181 # Allow a forced insert to happen; if it's a duplicate, the unique
1180 # constraint will catch it later anyways 1182 # constraint will catch it later anyways
1181 raise Exception('ModelWithHash is immutable') 1183 raise Exception('ModelWithHash is immutable')
1182 super(ModelWithHash, self).save(force_insert=force_insert, **kwargs) 1184 super(ModelWithHash, self).save(force_insert=force_insert, **kwargs)
OLDNEW
« no previous file with comments | « cli/job.py ('k') | frontend/afe/models.py » ('j') | frontend/afe/models.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698