Hi all,

I need to create a Model class that returns an object that is mostly build 
during component initialization time, but also has access to the current 
request. The API will look like this:

  sub my_action {
        my ($self, $c) = @_;
        my $formfu = $c->model('FormFu');
        my $book_form = $formfu->form('book');
        # do stuff with $book_form
  }

The main $formfu object is built during app initialization time - it reads 
configuration files, builds a bunch of forms and does onther expensive tasks. 
When $c->model('FormFu') is invoked, I want to add to $formfu information about 
any query parameters from the current request before returning it, so that I 
can use it with the forms that are accessed afterwards. I tried something like 
the following:

  package Catalyst::Model::FormFu;

  use parent 'Catalyst::Model';

  sub COMPONENT {
        # get configuration options for this component,
        # build and cache all forms,
        # and put them into $self
  }

  sub ACCEPT_CONTEXT {
        # get query parameters, add them to $self
        # and return it
  }

  sub form {
        # get the requsted form from the cache, 
        # add info about the current query and return it
  }

However, if there is a 'COMPONENT' or 'new' sub, 'ACCEPT_CONTEXT' never gets 
called. 

What is the right way to address this problem?

Cheers,

--
Peter


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to