예제 #1
0
파일: bulkimport.py 프로젝트: Chad90b/nav
 def _create_objects_from_row(self, row):
     raise_if_exists(Room, id=row['roomid'])
     location = get_object_or_fail(Location, id=row['locationid'])
     attributes = dict([attr.split('=', 1) for attr in row.get('attr', [])])
     room = Room(id=row['roomid'],
                 location=location,
                 description=row['descr'],
                 data=attributes)
     try:
         room.position = PointField().to_python(row['position'])
     except (ValidationError, ValueError):
         raise InvalidValue(row['position'])
     return [room]
예제 #2
0
 def get_db_prep_value(self):
     expected_db_string = "(7.1,5.12)"
     point = (Decimal("7.1"), Decimal("5.12"))
     field = PointField()
     db_string = field.get_db_prep_value(point)
     self.assertEquals(expected_db_string, db_string)
예제 #3
0
 def test_to_python_from_string(self):
     expected_point = (Decimal("1.2"), Decimal("3.4"))
     point_string = "(1.2, 3.4)"
     field = PointField()
     point = field.to_python(point_string)
     self.assertEquals(expected_point, point)