From: Allen Day Date: Wed, 13 Oct 2004 22:24:49 +0000 (+0000) Subject: almost working. there is a package name mangling problem where the X-Git-Tag: v0.11008~613 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=919a167049d6a56de01c8696e0cb7b19b669d16c;p=dbsrgits%2FSQL-Translator.git almost working. there is a package name mangling problem where the upcasing doesn't happen properly... i think it's the lack of callback calling in the right places, or an erroneous callback. --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index 884fd86..364af7e 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.58 2004-09-22 23:46:53 boconnor Exp $ +# $Id: Turnkey.pm,v 1.59 2004-10-13 22:24:49 allenday Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -22,7 +22,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.59 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -57,6 +57,7 @@ sub produce { local $DEBUG = $t->debug; my %meta = ( +concat => $args->{'concat'} || '', format_fk => $t->format_fk_name, format_package => $t->format_package_name, format_table => $t->format_table_name, @@ -179,6 +180,8 @@ sub translateForm { $template->process(\$tt2, $meta, \$result) || die $template->error(); } + #warn $result if $type eq 'dbi'; + return($result); } @@ -218,7 +221,7 @@ sub template { return <<'EOF'; [% MACRO printPackage(node) BLOCK %] -########[% node.name | replace('Turnkey::Model::', '') %]######## +########[% node.table.name | ucfirst #node.name | replace("Turnkey${concat}::Model::", '') %]######## package [% node.name %]; use base '[% node.base %]'; @@ -360,13 +363,13 @@ sub [% h.vianode.table.name %]_[% format_fk(h.vianode,h.thisviafield_index(i).na [% MACRO printList(array) BLOCK %][% FOREACH item = array %][% item %] [% END %][% END %] ########AutoDBI######## -use Turnkey::Model::DBI; +use Turnkey[% concat %]::Model::DBI; [% FOREACH node = nodes %] use [% node.value.name %]; [% END %] 1; -########[% baseclass | replace('Turnkey::Model::', '') %]######## +########DBI######## package [% baseclass %]; # Created by SQL::Translator::Producer::Turnkey @@ -427,13 +430,13 @@ use [% node.value.name %]; [% FOREACH node = nodes %] [% IF !node.value.is_trivial_link %] -########[% node.value.name | replace('Turnkey::Model::', '') %]######## +########[% node.value.name | replace('.+::', '') %]######## -package Turnkey::Atom::[% node.value.name FILTER replace "Turnkey::Model::", "" %]; +package Turnkey[% concat %]::Atom::[% node.value.name FILTER replace '.+::', '' %]; -[% pname = node.value.name FILTER replace "Turnkey::Model::", "" %] +[% pname = node.value.name FILTER replace '.+::', '' %] -use base qw(Turnkey::Atom); +use base qw(Turnkey[% concat %]::Atom); use Data::Dumper; sub can_render { @@ -446,7 +449,7 @@ sub render { # Assumption here that if it's not rendering on it's own dbobject # then it's a list. This will be updated when AtomLists are implemented -boconnor - if(ref($dbobject) eq 'Turnkey::Model::[% pname %]') { + if(ref($dbobject) eq 'Turnkey[% concat %]::Model::[% pname %]') { $self->focus('yes'); return(_render_record($dbobject)); } @@ -578,23 +581,23 @@ EOF [%- END %] [% END %] - - + + - + - + - - - + + + @@ -604,9 +607,9 @@ EOF [%- END -%] [% END %] - - - + + + @@ -640,7 +643,7 @@ EOF
[% IF name %] [% linkname = ref(p.containers[0]) %] -
[% atom.name | replace('Turnkey::Atom::', '') %]
+
[% atom.name | replace("Turnkey${concat}::Atom::", '') %]
[% END %]