What I do looks like this:
#!/usr/bin/env perl
use lib '../Jifty/lib';
use lib 'lib';
use Jifty::Everything;
use BTDT::CurrentUser;
use BTDT::Model::User;
use Getopt::Long;
Jifty->new();
my $email;
my $type = 'guest';
GetOptions('email=s' => \$email, 'type=s' => \$type);
my $u = BTDT::Model::User->new(current_user => BTDT::CurrentUser-
>superuser);
my ($id,$msg) = $u->create(name => 'admin', email => $email, password
=> 'password', email_confirmed => 1, access_level => $type);
print $msg unless ($id);
1;
On Dec 9, 2006, at 6:28 AM, Agent Zhang wrote:
Hello,
I've found that It's often desired to reuse Jifty Models in off-
line database importing/exporting scripts. Currently I'm using the
following piece of code in my Qooqle project's off-line scripts:
use UNIVERSAL::require;
use Jifty::Config;
use Jifty::ClassLoader;
BEGIN {
Jifty::ClassLoader->new(base => 'Qooqle')->require;
}
my $config = Jifty::Config->new;
$config->load;
my $db_config = $config->framework('Database');
use Jifty::DBI::Handle;
my $handle = Jifty::DBI::Handle->new();
$handle->connect(
driver => $db_config->{Driver},
database => $db_config->{Database},
user => $db_config->{User},
password => $db_config->{Password},
);
Jifty->new( handle => $handle );
Yes, it's ugly, but I can't make it shorter. What's the best
practice for doing this in the Jifty world?
Thanks!
Agent
_______________________________________________
jifty-devel mailing list
[email protected]
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
_______________________________________________
jifty-devel mailing list
[email protected]
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel