[Dbix-class] load_namespaces with extra resultset base class, without defining each one?

Oleg Kostyuk cub.uanic at gmail.com
Mon Nov 1 11:51:36 GMT 2010


Hello,

Base classes for your schema is out of scope of load_namespaces()
tasks. Just implement needed for you hierarchy, with base classes out
of your Result and ResultSet namespaces, and that's all. Something
like this:

My::Schema::Base::Result (descendant of DBIx::Class::Core)
 |-My::Schema::Result::Books
  \My::Schema::Result::Authors
My::Schema::Base::ResultSet (descendant of DBIx::Class::ResultSet)
 |-My::Schema::ResultSet::Books
  \My::Schema::ResultSet::Authors

Seems this is what you want, but I think this is not what you need. If
you want to write to audit log, then you should look to
DBIx::Class::Journal or DBIx::Class::QueryLog.

HTH


2010/11/1 Mark Hedges <hedges at formdata.biz>:
>
> Is there a way to call My::Schema->load_namespaces() to add
> a base class to every ResultSet, without having to spell out
> each ResultSet package just to do 'use base'?
>
> I overloaded delete(), insert() and update() in my Row base
> class to also insert an audit log entry for a handful of
> tables that need it.
>
> However, delete() in ResultSet does not call the Row
> methods, and it is pretty complicated for subclassing to
> figure out audit entries... basically my subclass would
> have to replicate all the logic in ResultSet::delete() to
> figure out what to audit.
>
> So, what I want to do is throw an exception from
> ResultSet::delete() if $self->result_source->table is one of
> the small number of audited tables.
>
> Is there a way to add a base class to every ResultSet in the
> first place?  If not, it would be nice.
>
> Thanks for the info.
>
> Mark
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



-- 
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)



More information about the DBIx-Class mailing list