Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

poet::manual::subclassing(3pm) [debian man page]

Poet::Manual::Subclassing(3pm)				User Contributed Perl Documentation			    Poet::Manual::Subclassing(3pm)

NAME
Poet::Manual::Subclassing - Customizing Poet with subclasses DESCRIPTION
You can subclass the following Poet classes for your application: Poet::Cache Poet::Conf Poet::Log Poet::Mason Poet::Import and arrange things so that Poet always uses your subclass instead of its default class. Place Poet subclasses under "lib/MyApp/Class.pm" in your environment, where "MyApp" is your app name and "Class" is the class you are subclassing minus the "Poet" prefix. A few of these subclasses are generated for you by "poet new". For example, to subclass "Poet::Cache": package MyApp::Cache; use Poet::Moose; extends 'Poet::Cache'; # put your modifications here 1; (Note: Poet::Moose is Moose plus a few Poet standards. You could also use plain "Moose" here.) Poet will automatically detect, load and use any such subclasses. Internally it uses the app_class environment method whenever it needs a classname, e.g. # Do something with MyApp::Cache or Poet::Cache $poet->app_class('Cache')->... Subclassing Mason As long as you have even a bare-bones "Poet::Mason" subclass, e.g. package MyApp::Mason; use Poet::Moose; extends 'Poet::Mason'; 1; then your Mason subclasses will be autodetected as well, e.g. package MyApp::Mason::Interp; use Moose; extends 'Mason::Interp'; # put your modifications here 1; "poet new" will create the bare-bones subclass for you; it is otherwise harmless. See Mason::Manual::Subclasses for more information. EXAMPLES
Use INI instead of YAML for config files package MyApp::Conf; use Config::INI; use Moose; extends 'Poet::Conf'; override 'read_conf_file' => sub { my ($self, $file) = @_; return Config::INI::Reader->read_file($file); }; Perform tasks before and after each Mason request package MyApp::Mason::Request; use Moose; extends 'Mason::Request'; override 'run' => sub { my $self = shift; # Perform tasks before request my $result = super(); # Perform tasks after request return $result; }; Add Perl code to the top of every compiled component package MyApp::Mason::Compilation; use Moose; extends 'Mason::Compilation'; override 'output_class_header' => sub { return join(" ", super(), 'use Foo;', 'use Bar qw(baz);'); }; Use Log::Dispatch instead of Log4perl for logging package MyApp::Log; use Log::Any::Adapter; use Log::Dispatch; use Moose; extends 'Poet::Log'; override 'initialize_logging' => sub { my $log = Log::Dispatch->new( ... ); Log::Any::Adapter->set('Dispatch', dispatcher => $log); }; Add your own $dbh quick var package MyApp::Import use DBI; use Poet::Moose; extends 'Poet::Import'; method provide_dbh ($caller, $poet) { $dbh = DBI->connect(...); } SEE ALSO
Poet AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-05 Poet::Manual::Subclassing(3pm)

Check Out this Related Man Page

Poet::Manual::Configuring(3pm)				User Contributed Perl Documentation			    Poet::Manual::Configuring(3pm)

NAME
Poet::Manual::Configuring - Built-in Poet configuration options DESCRIPTION
This is a list of configuration keys used by Poet itself. These may be placed in any Poet conf file, e.g. "local.cfg" or "conf/global/*.cfg". Entries like "foo.bar" can be listed either in dot notation foo.bar: 5 or as part of a hash: foo: bar: 5 See Dot notation for details. cache The entire hash under this entry will be passed to Poet::Cache->config(). See Poet::Cache for examples. e.g. cache: defaults: expires_variance: 0.2 storage: file: driver: File root_dir: ${root}/data/cache memcached: driver: Memcached servers: ["10.0.0.15:11211", "10.0.0.15:11212"] compress_threshold: 4096 namespace: /some/component: { storage: file, expires_in: 5min } /some/other/component: { storage: memcached, expires_in: 1h } Some::Library: { storage: memcached, expires_in: 10min } env.bin_dir, env.comps_dir, etc. These entries affect what is returned from "$poet->bin_dir", "$poet->bin_path", "$poet->comps_dir", etc., and thus where various Poet resources are kept. See Poet::Environment. For example, to move data and logs into external directories outside the environment: env: data_dir: /some/external/data/dir logs_dir: /some/external/logs/dir log.defaults, log.category Specify the log level, output location, and layout string for logging, in the default case and for particular categories respectively. See Poet::Log for examples. e.g. log: defaults: level: info output: poet.log layout: "%d{dd/MMM/yyyy:HH:mm:ss.SS} [%p] %c - %m - %F:%L - %P%n" category: CHI: level: debug output: chi.log layout: "%d{dd/MMM/yyyy:HH:mm:ss.SS} %m - %P%n" MyApp::Foo: output: stdout log.log4perl_conf Bypass Poet's simplified logging configuration and specify a log4perl conf file directly. e.g. log: log4perl_conf: /path/to/log4perl.conf mason The hash under this entry will be treated as options that are passed to "Mason->new" for the main Mason instance, overriding any default options. See Poet::Mason. e.g. mason: static_source: 1 static_source_touch_file: ${root}/data/purge.dat server.default_content_type Content type for requests that don't explicitly set one. Defaults to "text/html". server.host The IP address to listen on. server.load_modules A list of modules to load on server startup, e.g. server.load_modules: - DBI - List::Util - MyApp::Foo - MyApp::Bar server.port The port to listen on. SEE ALSO
Poet AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-05 Poet::Manual::Configuring(3pm)
Man Page