in reply to Re: Re: New scratchpads
in thread New scratchpads

I'm not familiar with the PM code, but in my work application I can mark a field 'defer', in which case normal fetches of the object won't fetch that field, and the accessor knows to do the extra fetch for deferred fields if the hash key doesn't exist. It looks something like this:

if ($field->defer) { no strict 'refs'; *{"${class}::$method"} = sub { use strict 'refs'; my $self = shift; $self->load_deferred if !$self->{_blank} && !exists($self->{$met +hod}); return $self->{$method}; }; }

That is to say: we need to load deferred fields if this is a real object (!$self->{_blank}) and the field hasn't been loaded (!exists($self->{$method})).

I don't know how applicable this approach might be to PM, but it works fine for me. :)

Hugo

Replies are listed 'Best First'.
Re^4: New scratchpads
by demerphq (Chancellor) on Jun 08, 2004 at 17:12 UTC

    Actually i had considered something like this before castaway did her patches. I wanted to intorduce the concept of a deferred table. Basically every node on pm has a nodetype (which is itself a node). Nodetype nodes store the tables used to create a given node. So if the tablelist is 'node,document,user' when a node of that type is fetched or inserted it will insert a record into each of those tables (joining on ${table1}_id==${table2}_id). What i wanted to do was have a special marker (i was thinking '!') that would flag that the table is deferred. The table would NOT be fetched unless specifically requested, but it would be inserted/deleted or updated if the object was new or the required fields were present.

    I still think this is probably a useful idea, but its low priority as its a pretty intrusive change. Also with the design that castaway took we can support multiple pads for a user.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi