X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole.pm;h=6656b9b20a2bb741dff627e4fbbed325345e1187;hb=9359c5412f34be76c0672fe320729d60f96a2c3e;hp=03205a61486545dde470811213440cfc9e09adb6;hpb=8d3f7b6c5612270c10042d8e0a9e52ad4ad54a46;p=maypole.git diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 03205a6..6656b9b 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -1,4 +1,5 @@ package Maypole; +use Class::C3; use base qw(Class::Accessor::Fast Class::Data::Inheritable); use UNIVERSAL::require; use strict; @@ -12,7 +13,7 @@ use URI::QueryParam; use NEXT; use File::MMagic::XS qw(:compat); -our $VERSION = '2.11_pre4'; +our $VERSION = '2.12'; our $mmagic = File::MMagic::XS->new(); # proposed privacy conventions: @@ -35,6 +36,9 @@ The canonical example used in the Maypole documentation is the beer database: # choose a frontend, initialise the config object, and load a plugin use Maypole::Application qw/Relationship/; + + # set everything up + __PACKAGE__->setup("dbi:SQLite:t/beerdb.db"); # get the empty config object created by Maypole::Application my $config = __PACKAGE__->config; @@ -62,8 +66,8 @@ The canonical example used in the Maypole documentation is the beer database: date => [ qw/date/], ); - # set everything up - __PACKAGE__->setup("dbi:SQLite:t/beerdb.db"); + # note : set up model before calling this method + BeerDB::Beer->required_columns([qw/name/]); 1; @@ -296,14 +300,10 @@ sub setup_model { # among other things, this populates $config->classes $config->model->setup_database($config, $class, @_); - foreach my $subclass ( @{ $config->classes } ) { - next if $subclass->isa("Maypole::Model::Base"); - no strict 'refs'; - unshift @{ $subclass . "::ISA" }, $config->model; - } + $config->model->add_model_superclass($config); # Load custom model code, if it exists - nb this must happen after the - # unshift, to allow code attributes to work, but before adopt(), + # adding the model superclass, to allow code attributes to work, but before adopt(), # in case adopt() calls overridden methods on $subclass foreach my $subclass ( @{ $config->classes } ) { $class->load_model_subclass($subclass) unless ($class->model_classes_loaded()); @@ -1151,6 +1151,11 @@ sub object { Get/set a hash of template variables. +Maypole reserved words for template variables will over-ride values in template_variables. + +Reserved words are : r, request, object, objects, base, config and errors, as well as the +current class or object name. + =item stash A place to put custom application data. Not used by Maypole itself.