Discussion:
[Openinteract-dev] Better documentation for get_security()
Andrew Hanenkamp
2005-02-14 17:12:19 UTC
Permalink
The docs state that a class that wants a custom security model should
redefine the get_security() method to return access levels based upon
that state of the object. This doesn't work for fetch() unless the
only record state you must have is the ID.

Now, for efficiency's sake, this is good, or at least mostly good.
However, for the guy who wants a custom security model (namely me),
this is not so good. I have access to none of the other state. Of
course, that's not strictly true, as I can do something like this:

sub get_security {
my ($self, $p) = @_;

my $item;
if ($p->{id}) { # I'm assuming that this indicates the object's
state isn't yet loaded
$item = $self->fetch($id, { security_level => SEC_LEVEL_READ,
skip_security => 1 });
} else {
$item = $self;
}

# run my checks against $item
}

With the record cache, this should be relatively efficient and thus
prevent a double-select, but I could be wrong. Caching is one of the
features I haven't really fully investigated at this point.

Anyway, I think better documentation might be in order to note this
issue.

Cheers,
Sterling

--
<>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><>
Andrew Sterling Hanenkamp
Systems Coordinator
Computing and Information Sciences
Kansas State University
***@cis.ksu.edu
http://www.cis.ksu.edu/~sterling/

Please send all requests for help to ***@cis.ksu.edu. My Inbox is too
perilous a place.

Loading...