Hi everyone and couchdb pros,

I have a mapping setup like such:

class Product(BaseModel):
  name= mapping.TextField()
  returned = mapping.DictField(mapping.Mapping.build(
    reason = mapping.TextField(),
    put_back = mapping.BooleanField()
  ))

I have a function called getById that takes an id and returns a product via:

return Product.load(db, id)

I have a problem: When I load a particular product, and try to set the returned dictionary like such:

product = Product.getById("123")
product.returned
>>> {}
product.returned['reason'] = "Test"
product.returned
>>> {}

NOTE: I only recently modified the model to have the "returned" key. Old product objects which are obtained using getById, does not have the "returned" key in them. Would this make a difference? It shouldn't right, after all this is a document DB and it should be flexible right?

Why does product.returned still return me an empty dictionary after setting the "reason" attribute?

I did some debugging and realized that the product variable is of the form:

<Product u'f90173026e859c65cfa08496115bf7bf'@u'11-3ea1135ceb6361631cbb08471d15df1e' {u'name': u'Printer', u'subProducts': [], u'company': {u'id': u'HP', u'name': u'Hewlett-Packard'}, u'productType':.......>

What kind of result is this? Is it a view result or is it a document?

Any help is greatly appreciated thanks!

Thanks.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top