Hi Andy,
I suggest to do the override in the model or business model layer, not 
dbic::api itself.
This ensures that no other code deletes a row.

Cheers, Alex

On 2014-08-08 10:16, Andy Holyer wrote:
I'm working on a Catalyst application which mainly uses 
Catalyst::Controller::DBIC:API::REST to provide CRUD (Create, Read, Update, 
Delete) access to a MySQL database.

A feature the customer requires is that database records are non-destructive, 
in order to provide an additional level of security (the application is 
financial, so it's important that users cannot remove records from the actual 
database). The number of records which will be in the final system is 
relatively low, in the thousands, so the presence of defunct records will not 
slow down database operations).

To implement this I have added a flag, "defunct" to all database tables, and I 
now need to overload the delete and update methods as follows:

delete -> set defunct to true

update -> delete (see above) existing record, write updated record to the 
database.

What I can't work out at the moment is where in the inheritance hierarchy of 
classes are the methods I should overload. It doesn't look as though 
Catalyst::DBIC::API is the correct place, since there seem to be a number of 
similar but related methods to perform deletion and updating. The individual 
record methods as far as I can see are implemented at the bottom level of 
Moose, but I'm not sufficiently comfortable with Moose internals to work out 
exactly what to overload. I'm continuing with research on the matter, but thsi 
must be a behaviour which has been done before, and any advice or pointers to 
online documentation or tutorials would be very handy.

Thanks in advance for any help, I will summarize results to the list if need be.

Andy Holyer, Brighton, UK.





_______________________________________________
List: Catalyst@lists.scsys.co.uk<mailto:Catalyst@lists.scsys.co.uk>
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/




*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to