From: Vsevolod (S. I. <si...@cs...> - 2004-11-01 01:32:25
|
Ray, Chris, and others, My current progress - code pretty much finalized, and a .t file with 64 tests (I'll have to add a few more tests to cover all combinations of features). I'd like to do some more internal testing before I send the official patch, but if anyone has time to play with the new features (yeah, right :), I'd be happy to share it. It's completely backwards compatible. > Just curious, at what level are you implementing this cache? Is it > *always* used for all SPOPS objects? Only for DBI? Only for DBI when you > are using the new functionality? It's only for DBI. > Do you have a documentation detailing the new syntax for the > functionality you are adding? Actually, possibly the simplest thing (and > probably the most helpful thing for me) would be to just take the > examples at the end of my proposal and modify them to your syntax so I > could see an example of what each case looks like. See below. > I forgot, did you implement any lazy loading features or is it just > manual and auto? I actually did not implement manual loading - I just can't see where it can be used (and a bit fuzzy on how it would work). So there is only auto and lazy loading. Autosaving is always off by default, to preserve compatibility. OTOH, there are three types of removes - 'auto', 'manual' and 'forget'. 'Auto' means complete removal of dependent objects, 'forget' - nullifying id fields pointing to the removed objects, and 'manual' - no action. The default should logically be 'forget', but it may conflict with no autosaving, so I'll have to set it to 'manual'. > If I understand correctly, one of the fundamental differences between > your implementation and my proposal is that for has_many and links_to > relationships the definition of the relationship is no longer specified > in the class containing the linking field, but rather in a class that is > linked to. I'm a bit concerned that with the way I use SPOPS (not to > create classes but simply to define the relationships and persistence of > traditionally defined *.pm-file classes, where linking classes have not > only extra fields, but also extra functionality), some of the > functionality I need which was present in my proposal will be missing > from your redesign ... but I guess I won't know until I see the details. As I mentioned, I am flexible on the matter of has_many. If you want, I can create an additional config option (you call it 'auto_by' etc, I think) and put it into the other class. Links_to is harder, because to preserve backward compatibility it has to stay in one of the edge classes. But if you want to add more variables to the linking class, you'll have to define it for SPOPS anyway, and there I can probably also implement your suggestion as an option. Below is the usage example that you posted originally, and after *** - my syntax. $CONF = { X_alias => { class => "X", field => [ qw/ x_id x_data myA myB / ], has_a => { myA => { class => "A", fetch => { type => "manual|auto|lazy|manual_by|auto_by|lazy_by", name => "someA", list_field => "list_of_Xs", }, link => { type => "manual|auto|lazy", field => "myB" name => "someB", list_field => "linked_Bs", }, remove => { type => "manual|auto|manual_by|auto_by|manual_null|auto_null" name => "removeSomeA", list_field => "list_of_Xs", } }, myB => { class => "B", fetch => { type => "manual|auto|lazy|auto_by|lazy_by", name => "someB", list_field => "linked_Bs", }, link => { type => "manual|auto|lazy", field => "myA" name => "someA", list_field => "list_of_As", }, remove => { type => "manual|auto|manual_by|auto_by|manual_null|auto_null" name => "removeSomeB", list_field => "list_of_Xs", } }, } }, A_alias => { class => "A", field => [ qw/ a_id a_data / ], list_field => { X => ["list_of_Xs"], B => ["linked_Bs"] } }, B_alias => { class => "B", field => [ qw/ b_id b_data / ], }, } *** $CONF = { X_alias => { class => "X", field => [ qw/ x_id x_data myA myB / ], has_a => { {A => {alias => "mya", fetch => { type => 'auto|lazy', save =>1 }, remove => { type => 'auto|manual' } reverse_remove => {type => 'manual|forget' } } }, has_many => { B => { fetch => { type => 'auto|lazy', save => 1, alias => 'list_of_Xs', reverse_alias => 'myx'}, remove => { type => 'auto|manual|forget' } } }, links_to => { 'D' => { table => 'spops_x_d', alias => 'list_of_Ds', link_class => 'Membership', link_class_alias => 'memberships', } } .. }, Membership_alias => { class => 'Membership', field => ['id, 'x_id', 'd_id', 'start_date', 'end_date'], ... } Simon -- Simon (Vsevolod ILyushchenko) si...@cs... http://www.simonf.com Terrorism is a tactic and so to declare war on terrorism is equivalent to Roosevelt's declaring war on blitzkrieg. Zbigniew Brzezinski, U.S. national security advisor, 1977-81 |