From: Siddhartha B. <bi...@gm...> - 2010-10-30 03:21:36
|
Hi Bob, On Wed, 27 Oct 2010, Bob MacCallum wrote: > Mostly for Rob... > > I have been playing a bit with introspection on BCS objects (while > figuring out how to serialize them (to JSON) including one or more > levels of related objects). Just wondering how you are approaching for BCS -> JSON conversion. One of them could be using the HashRefInflator. As far as m2m goes here is a interesting discussion from dbic mailing list .... http://dbix-class.35028.n2.nabble.com/RecursiveUpdate-and-many-to-many-tt1122619.html#none IMHO, if you need m2m introspection for getting JSON and willing to give up the accessor name generated by many_to_many method, the relationship can be easily infered by looking through has_many <-> belongs_to <-> has_many bridge. So far i have done it the other way for my modware project, that is inflating my object to perl hashes to feed the create(multicreate) method of bcs/dbic. Going from resultset to json might be also useful for web apps also. If it sounds overlapping let me know, we might help out each other. thanks, -siddhartha > > You can get a list of relationships with this > @rels = $feature->relationships > but it doesn't tell you about many_to_many relationships, such as > parent_features and child_features (which are added manually; I am > going to be adding all the many_to_many relationships for NatDiv and > related classes soon - stay tuned to > http://github.com/bobular/Bio-Chado-Schema). > > There's a plugin which does it though, it's called > DBIx::Class::IntrospectableM2M > > We just need to add this before the first many_to_many definition. > __PACKAGE__->load_components(qw/IntrospectableM2M/); > > and then the m2m relationships and their get/set/add/remove method > names can be obtained, not through $object->relationships, but another > method, but it works. > > So the question is, should I add this extra dependency (to a module > that may not continue to be compatible) and complexity for one > potential very specialised use case (that could probably be done > another way...any ideas...)? > > cheers, > Bob. > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > Gmod-schema mailing list > Gmo...@li... > https://lists.sourceforge.net/lists/listinfo/gmod-schema |