Nicholas Perez > Catalyst-Controller-DBIC-API-2.001003 > Catalyst::Controller::DBIC::API::RequestArguments

Download:
Catalyst-Controller-DBIC-API-2.001003.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
Stalled  1
View/Report Bugs
Module Version: 2.001003   Source   Latest Release: Catalyst-Controller-DBIC-API-2.006002

NAME ^

Catalyst::Controller::DBIC::API::RequestArguments - Provides Request argument validation

VERSION ^

version 2.001003

DESCRIPTION ^

RequestArguments embodies those arguments that are provided as part of a request or effect validation on request arguments. This Role can be consumed in one of two ways. As this is a parameterized Role, it accepts a single argument at composition time: 'static'. This indicates that those parameters should be stored statically and used as a fallback when the current request doesn't provide them.

PUBLIC_ATTRIBUTES ^

count is: ro, isa: Int

count is the number of rows to be returned during paging

page is: ro, isa: Int

page is what page to return while paging

offset is ro, isa: Int

offset specifies where to start the paged result (think SQL LIMIT)

ordered_by is: ro, isa: "OrderedBy" in Catalyst::Controller::DBIC::API::Types

ordered_by is passed to ->search to determine sorting

groupd_by is: ro, isa: "GroupedBy" in Catalyst::Controller::DBIC::API::Types

grouped_by is passed to ->search to determine aggregate results

prefetch is: ro, isa: "Prefetch" in Catalyst::Controller::DBIC::API::Types

prefetch is passed to ->search to optimize the number of database fetches for joins

prefetch_allows is: ro, isa: ArrayRef[ArrayRef|Str|HashRef]

prefetch_allows limits what relations may be prefetched when executing searches with joins. This is necessary to avoid denial of service attacks in form of queries which would return a large number of data and unwanted disclosure of data.

Like the synopsis in DBIC::API shows, you can declare a "template" of what is allowed (by using an '*'). Each element passed in, will be converted into a Data::DPath and added to the validator.

    prefetch_allows => [ 'cds', { cds => tracks }, { cds => producers } ] # to be explicit
    prefetch_allows => [ 'cds', { cds => '*' } ] # wildcard means the same thing

search_exposes is: ro, isa: ArrayRef[Str|HashRef]

search_exposes limits what can actually be searched. If a certain column isn't indexed or perhaps a BLOB, you can explicitly say which columns can be search and exclude that one.

Like the synopsis in DBIC::API shows, you can declare a "template" of what is allowed (by using an '*'). Each element passed in, will be converted into a Data::DPath and added to the validator.

search is: ro, isa: "SearchParameters" in Catalyst::Controller::DBIC::API::Types

search contains the raw search parameters. Upon setting, a trigger will fire to format them, set search_parameters, and set search_attributes.

Please see "generate_parameters_attributes" for details on how the format works.

search_parameters is:ro, isa: "SearchParameters" in Catalyst::Controller::DBIC::API::Types

search_parameters stores the formatted search parameters that will be passed to ->search

search_attributes is:ro, isa: HashRef

search_attributes stores the formatted search attributes that will be passed to ->search

search_total_entries is: ro, isa: Int

search_total_entries stores the total number of entries in a paged search result

select_exposes is: ro, isa: ArrayRef[Str|HashRef]

select_exposes limits what can actually be selected. Use this to whitelist database functions (such as COUNT).

Like the synopsis in DBIC::API shows, you can declare a "template" of what is allowed (by using an '*'). Each element passed in, will be converted into a Data::DPath and added to the validator.

select is: ro, isa: "SelectColumns" in Catalyst::Controller::DBIC::API::Types

select is the search attribute that allows you to both limit what is returned in the result set, and also make use of database functions like COUNT.

Please see "select" in DBIx::Class::ResultSet for more details.

as is: ro, isa: "AsAliases" in Catalyst::Controller::DBIC::API::Types

as is the search attribute compliment to "select" that allows you to label columns for object inflaction and actually reference database functions like COUNT.

Please see "as" in DBIx::Class::ResultSet for more details.

joins is: ro, isa "JoinBuilder" in Catalyst::Controller::DBIC::API::Types

joins holds the top level JoinBuilder object used to keep track of joins automagically while formatting complex search parameters.

Provides a single handle which returns the 'join' attribute for search_attributes:

    build_joins => 'joins'

request_data is: ro, isa: HashRef

request_data holds the raw (but deserialized) data for ths request

PRIVATE_ATTRIBUTES ^

search_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate search parameters

select_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate select parameters

prefetch_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate prefetch parameters

PROTECTED_METHODS ^

format_search_parameters

format_search_parameters iterates through the provided params ArrayRef, calling generate_column_parameters on each one

generate_column_parameters

generate_column_parameters recursively generates properly aliased parameters for search, building a new JoinBuilder each layer of recursion

generate_parameters_attributes

generate_parameters_attributes takes the raw search arguments and formats the parameters by calling format_search_parameters. Then builds the related attributes, preferring request-provided arguments for things like grouped_by over statically configured options. Finally tacking on the appropriate joins. Returns both formatted search parameters and the search attributes.

_build_search_attributes

This builder method generates the search attributes

AUTHORS ^

  Nicholas Perez <nperez@cpan.org>
  Luke Saunders <luke.saunders@gmail.com>
  Alexander Hartmaier <abraxxa@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2010 by Luke Saunders, Nicholas Perez, et al..

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: