ming nested subdocument using imperative mapping

조회수 26회
읽지 않은 첫 메시지로 건너뛰기

Rafael Ribeiro

읽지 않음,
2020. 12. 21. 오전 9:33:1120. 12. 21.
받는사람 TurboGears
Hi all,

 I am porting an application from mongoengine to ming and I wished to map a nested document. I've seen another post mentioning the subdocument feature but since I am not using the declarative approach to mapping I'd like to know whether it is possible to do it using the imperative mapping approach ( https://ming.readthedocs.io/en/latest/baselevel.html#ming-baselevel ).
 Is it possible to load an object and have another class nested inside?

best regards,
Rafael

Vincenzo Castiglia

읽지 않음,
2020. 12. 22. 오전 6:27:1920. 12. 22.
받는사람 turbo...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/turbogears/9e80790c-5260-4485-a8cc-ddbbddfdfd4dn%40googlegroups.com.

Rafael Ribeiro

읽지 않음,
2020. 12. 22. 오전 8:54:1620. 12. 22.
받는사람 turbo...@googlegroups.com
Not exactly since it'll convert back to a ming.base.Object as per the documentation. I was looking for something that would be able to convert back to an arbitrary class from my code.

You received this message because you are subscribed to a topic in the Google Groups "TurboGears" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/turbogears/i2K3aaIe8GQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to turbogears+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/turbogears/CABFU5vsmWAdzrR_ASBd3kafL-Ru4WiqViaVbbywCOb3o8y7JKg%40mail.gmail.com.

Vincenzo Castiglia

읽지 않음,
2020. 12. 22. 오전 9:12:2520. 12. 22.
받는사람 turbo...@googlegroups.com
ok, then what about subclassing like this
```
class MyConverter(schema.Object):
    def _validate(self, d, allow_extra=False, strip_extra=False):
        return MyClass(super()._validate(d, allow_extra=allow_extra, strip_extra=strip_extra))
```
assuming your class have a __init__ that takes a dict or is a subclass of collections.UserDict

Rafael Ribeiro

읽지 않음,
2020. 12. 22. 오전 9:16:2920. 12. 22.
받는사람 turbo...@googlegroups.com
Looks promising ... but how should I register this converter and is it possible to have more than one converter registered for schema.Object? In case I have two or more places in which I have nested objects like this. I have the impression that ming lacks the properties parameter in the mapper function and also lacks a relationship function just like SQLAlchemy does on this scenario.

전체답장
작성자에게 답글
전달
새 메시지 0개