You will need to serialize your matrix. How you should serialize the data depends on whether you intend to query the data based on the data in the matrix.
If you are not going to request, just use JSON (or something similar).
from django.utils import simplejson as json
class Matrix(db.Model):
values = db.StringProperty(indexed=False)
matrix = Matrix()
matrix.values = json.dumps([[1,0],[0,1]])
matrix.put()
matrix_values = json.loads(matrix.values)
If you try to execute a query for matrices containing an "exact row", you can do something like:
class Matrix(db.Model):
values = db.ListProperty()
matrix = Matrix()
values = [[1,0],[0,1]]
matrix.values = [':'.join([str(col) for col in row]) for row in values]
matrix.put()
matrix_values = [[int(col) for col in row.split(':')] for row in matrix.values]
source
share