From: Chris W. <ch...@cw...> - 2004-01-06 00:53:56
|
On Jan 5, 2004, at 5:52 PM, Vsevolod (Simon) Ilyushchenko wrote: > At the risk of being a pain, I'll repost my two previous questions > about links_to: I have a current project which is stalled because of > them. Hope I'll be able to help. > This refers to the solution that you suggested when I do this: > > SPOPS class: SPOPS_Books > Your class: MyBooks isa SPOPS_Books > SPOPS class: SPOPS_Publisher > Your class: MyPublisher isa SPOPS_Publisher > > Then declare in your publisher configuration: > > links_to => { MyBooks => 'link_table' } Okay, I've got a test script + classes that has this setup with strict field checking and field autodiscovery. It all works ok with: Book isa Book_Persist Book linksto Publisher Publisher isa Publisher_Persist Publisher linksto Book Files are attached in book_sample.tar.gz > 1. My classes have a superclass. Let's call it MyObject. So I inherit > MyBooks from SPOPS_Books and MyObject. I have to double-dispatch the > new() method, but I can live with it. This might be a problem. How are you dispatching new()? > Obviously, I can turn strict fields checking off, but I'd like to > retain that. The alternative is to somehow keep autodiscovery, but add > in the config hash of SPOPS_Books additional fields which correspond > to "instance variables" of MyObject. I am not sure how to do it, but > even if I could, it's messy because I'll have to repeat it in every > SPOPS_* class. This can be made a little less messy if I do not > inherit from MyObject, but store a reference to it, but this one > reference still has to be mentioned in SPOPS config. As an aside: you can also use the kludge of storing it in a field named 'tmp_foo' -- anything that starts with 'tmp_' is ignored by the tie implementation. (Did I mention that I hate tie? :-) > 2. I am trying to use objects that refer to each other, and I use > links_to in both configuration. (I call them Job and Task, but they > are similar in their relationship to Publisher and Book). > > I attach the four class files and the script that tries to use them. > I inherit Job from SPOPS_Job and Task from SPOPS_Task. The SPOPS > configuration refers to Common.pm, which would be different in your > case. One thing I noticed is that you have a 'require SPOPS_Job' in Job and a corresponding one for Task. Get rid of that, you don't need it and might be causing the problem: > The error message is: > Cannot run behavior in [links_to] [SPOPS_Job]: Failed to retrieve > configuration from Compilation failed in require at Job.pm line 5. Let me know about the 'new()' dispatch and whether the sample works for you and if it's different than your setup in any way other than the common inherited class. (It uses SQLite like before) Chris -- Chris Winters Creating enterprise-capable snack systems since 1988 |