[Catalyst] Subject: Simple question: setting pre-set fields/creation actions in Catalyst::Controller::DBIC::API::REST

Andy Holyer andyh.enable at gmail.com
Fri Jun 6 08:12:02 GMT 2014


Yes, all of that is understood and working fine. So, for example, I have a
controller PaymentOut.pm, which allows the database table payment_out to be
accessed, updated, etc., using normal CRUD operations.

What I now want to do is add in some procedural code so that:
a) payment_out.state is set to "new"
b) following saving a new record, the method process_record() is run on the
new record.

That has to be a simple thing to do, right?

Thanks in advance for any advice.



On Thu, Jun 5, 2014 at 10:44 PM, Hernan Lopes <hernanlopes at gmail.com> wrote:

> first things first. In a restful environment, a client might create a
> request with json content and a header that specifys the content type which
> is being sent to the web server. The web server will receive that request
> containing XYZ-content then it will look up the request header
> "Content-Type" which must indicate that content being sent is
> "application/json". Then, it can correctly parse that XYZ-content into the
> proper content type and transform it into a perl structure that you can
> store or do something else. Then, you will process that content and
> generate a response for the requesting client. If your app will respond to
> the client with a json content you must specify that into the response
> header: content-type: "application/json". That way when the client receives
> that response it will know the content is a json and correctly understand
> it.
>
> So you should get that working and understood before you can proceed.
> Check if you are receiving some content in the correct controller.
> Try do Dump the contents of $c->req and make sure you are getting the
> correct contents with the respective content types.
>
> cheers,
>
> Hernan Lopes
>
>
>
>
> On Thu, Jun 5, 2014 at 7:27 AM, Andy Holyer <andyh.enable at gmail.com>
> wrote:
>
>> I've been coding in Perl for years, but I'm still pretty new to Catalyst,
>> so please excuse the newbie question.
>>
>> I'm putting together a Catalyst application which uses
>> Calalyst::Controller::DBIC::API::REST to interface with the database.
>>
>> So, in lib/MyApp/Controller/ there are a bunch of files of the form
>> {Table}.pm, which each consists of basically a __PACKAGE__->config() call
>> setting various things, including create_requires, create_allows and so on.
>>
>> Simple question: Several of these tables require status etc. to be set
>> heardwired in code, and several of the others have some business logic
>> which needs to take place on e.g. creation.
>>
>> What's the canonical way to do this? I'm guessing it means defining a
>> begin method, but I'd really like to know the "proper" way to do this.
>> Can't see this anywhere in the docs (unless I'm looking in the wrong
>> place), but it's such a common occurrence it *must* be a FAQ.
>>
>> Thanks in Advance.
>>
>> Andy Holyer, Brighton, UK
>>
>> _______________________________________________
>> List: Catalyst at 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/
>>
>>
>
> _______________________________________________
> List: Catalyst at 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/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20140606/a1d92da6/attachment.htm>


More information about the Catalyst mailing list