Search the web
Sign In
New User? Sign Up
mt-dev · Movable Type Developers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
now he tells us! ;)   Message List  
Reply | Forward Message #883 of 2112 |
For those not on or closely monitoring ProNet, Byrne posted this
handy piece of code below. Where was this when I needed it!? ;) I
really wanted to do something like this, but simply didn't have the
bandwidth to make sense of that code without documentation. This will
be quite useful to my future work. It's simple things like this that
make me happy. <tim/>

---
Archived at: http://www.sixapart.com/mailman/private/pronet/2006-
January/003754.html

# CREDIT GOES TO BRAD CHOATE who wrote the repair_class method for me. I
can't wait to use this in Media Manager!!!!

sub initialize_plugin {
my $app = shift;
my $tmpl = $app->init_tmpl('init.tmpl');
$tmpl->param('blog_id' => $app->{query}->param('blog_id'));

require MTAmazon3::Item;
my $diff = $app->repair_class("MTAmazon3::Item");

$tmpl->param('diff' => $diff);

$app->add_breadcrumb("Main Menu",$app->{mtscript_url});
$app->add_breadcrumb("MTAmazon Initialization");

$app->{breadcrumbs}[-1]{is_last} = 1;
$tmpl->param(breadcrumbs => $app->{breadcrumbs});
$tmpl->param(plugin_version => $MT::Plugin::MTAmazon3::VERSION);

$app->l10n_filter($tmpl->output);
}

sub repair_class {
my $app = shift;
my ($class) = @_;
require MT::Upgrade;
my $driver = MT::Object->driver;
my $diff = MT::Upgrade->class_diff($class);
print STDERR "diff=$diff\n";
if ($diff) {
my @stmt;
if ($diff->{fix}) {
@stmt = $driver->fix_class($class);
} else {
if ($diff->{add}) {
push @stmt, $driver->add_column($class, $_->{name})
foreach @{$diff->{add}};
}
if ($diff->{alter}) {
push @stmt, $driver->alter_column($class, $_->{name})
foreach @{$diff->{alter}};
}
if ($diff->{drop}) {
push @stmt, $driver->drop_column($class, $_->{name})
foreach @{$diff->{drop}};
}
}
if (@stmt) {
$driver->sql(\@stmt) or return $app->error($driver-
>errstr);
}
}
return $diff;
}



Fri Jan 13, 2006 5:11 pm

tappnel
Offline Offline
Send Email Send Email

Forward
Message #883 of 2112 |
Expand Messages Author Sort by Date

For those not on or closely monitoring ProNet, Byrne posted this handy piece of code below. Where was this when I needed it!? ;) I really wanted to do...
Timothy Appnel
tappnel
Offline Send Email
Jan 13, 2006
5:11 pm

In the ProNet post Byrne made on using the new upgrade features in MT ... Perhaps I'm misunderstanding something. Where am I supposed to have have the...
Timothy Appnel
tappnel
Offline Send Email
Jan 24, 2006
1:59 am

Sorry - I should have been more explicit: There is no "initialize_plugin" method - that is my own fabrication. I just wrap it in a subroutine for easier...
Byrne Reese
byrnereese
Online Now Send Email
Jan 25, 2006
8:13 pm

So in other words, use init_request. That method checks a configuration param or some other piece of data to check what version of the object schema was last...
Timothy Appnel
tappnel
Offline Send Email
Jan 25, 2006
8:20 pm

Based on how you implemented you need a MT::App in your package that is presumably run before any part of the plugin is run. Is that correct? If so, I take it...
Timothy Appnel
tappnel
Offline Send Email
Jan 25, 2006
8:37 pm

... Can you tell us much more about this?...
David Jacobs
pdx_davidj
Offline Send Email
Jan 25, 2006
8:56 pm

Let me see if I can probe Brad to give us an overview of this feature. To be honest, I have not cracked open 3.3 yet - I am still hacking on 3.2. :-D <nudging...
Byrne Reese
byrnereese
Online Now Send Email
Jan 25, 2006
10:20 pm

New keys you will be able to register with your plugin: schema_version and object_classes. MT->add_plugin(new MT::Plugin({ # stuff ... schema_version => 1.0, ...
Brad Choate
bschoate
Offline Send Email
Jan 27, 2006
7:06 am

... I take it PluginTableA, B are in the MT database space? ... Where is this version declared? MT_PluginData? Thanks Brad, this looks cool....
David Jacobs
pdx_davidj
Offline Send Email
Jan 29, 2006
2:35 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help