From: Chris W. <ch...@cw...> - 2003-04-06 17:24:07
|
David C. Reed wrote: > I am having a problem with SPOPS. I have two objects that share a > "links_to" relationship. When I try to instantiate either I get the > following error message: > > Can't locate object method "CONFIG" via package "My::PackageName" (perhaps > you forgot to load "My::PackageName"?) at lib/SPOPS/ClassFactory/DBI.pm line > 304. > > I have used the structure for creating objects given in the "eg/My" > examples, and require'd the linked objects. If I comment out the > "links_to" line in the config of one of the objects, that object > instantiates fine and the "links_to" relationship partially works, but not > fully. You need to be sure to instantiate both at the same time since a class needs to do some introspection on its related class (to find the ID field and such). The best way to do this is read all your configurations into a single hashref and process them all at once. For instance, the following should work assuming that 'read_config()' returns a single hashref with the configuration for a single object. my $config_package_a = read_config( 'conf/package_a.perl' ); my $config_package_b = read_config( 'conf/package_b.perl' ); SPOPS::Initialize->process( { config => { a => $config_package_a, b => $config_package_b } } ); Hope this helps, Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |