ebu / OSCIED

Open Source Cloud Infrastructure for Encoding and Distribution
Other
16 stars 2 forks source link

Orchestra : Replace low-level pyMongo by Ming ODM #72

Closed davidfischer-ch closed 11 years ago

davidfischer-ch commented 11 years ago

Using MongoDB through a ODM is the best way to enforce database consistency, simplify our code and make it more robust at the cost of a performance overhead.

Ming makes possible some interesting features, such as :

This task as is does not add much features to OSCIED, it improve the quality of the code and this is better to make it as soon as possible.

davidfischer-ch commented 11 years ago

I was replacing the low-level pyMongo by Ming and I understand that it is not possible (at least without tweaking Ming) to store 2 foreign id fields pointing to the same kind of Document (here a Media).

Testing TransformJob with doctest
OK
<TransformJob user_id='6582a84b-115f-41e0-b43d-545610a7e9fb'
  media_in_id='8c6ce5a0-37b2-45fc-873b-563211b6c2df'
  profile_id='43960bcd-8933-49c5-9f87-19cb1b889902'
  statistic=I{}
  media_out_id='8c6ce5a0-37b2-45fc-873b-563211b6c2df'
  _id='86ee5908-d1f1-4825-9c43-6d3e25b002a2' revoked=None>
Traceback (most recent call last):
  File "/home/famille/David/git/OSCIED/charms/oscied_lib/TransformJob.py", line 105, in <module>
    pprint(TRANSFORM_JOB_TEST.media_in)
  File "/usr/local/lib/python2.7/dist-packages/ming/odm/property.py", line 209, in __get__
    result = st.extra_state[self] = self.join.load(instance)
  File "/usr/local/lib/python2.7/dist-packages/ming/utils.py", line 18, in __get__
    result = obj.__dict__[self.__name__] = self._func(obj)
  File "/usr/local/lib/python2.7/dist-packages/ming/odm/property.py", line 192, in join
    [ p.name for p in own_props + rel_props ])
ming.odm.property.AmbiguousJoin: Ambiguous join, satisfying keys are ['media_in_id', 'media_out_id']