jkondo's Journal
http://use.perl.org/~jkondo/journal/
jkondo's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:44:19+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00jkondo's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~jkondo/journal/
Moved to VOX
http://use.perl.org/~jkondo/journal/32849?from=rss
<p>I've moved this journal to VOX.com. See you at<br>http://jkondo.vox.com/</p>jkondo2007-03-30T21:14:39+00:00journalDBIx::MoCo 0.07 released
http://use.perl.org/~jkondo/journal/32637?from=rss
<tt>I uploaded DBIx::MoCo 0.07 today.<br><br>Changes from 0.06 are as follows.<br><br>0.07 Fri Mar 9 2007<br> - Added DBIx::MoCo::Schema for schema definition<br> - Added count method to DBIx::MoCo<br> - Removed keys method and added unique_keys method to MoCo<br> - Changed primary_keys, unique_keys to get info automatically<br> - Added cache_status method to DBIx::MoCo<br> - Added DBIx::MoCo::Column and URI plugin for inflating columns<br> - Added DBIx::MoCo::Join for joined classes<br> - Added DBIx::MoCo::Readonly for read only classes.<br> - Fixed problem new session will start when save_changed is called.<br> - Added retrieve_by_a_or_b handler into DBIx::MoCo<br> - Added descriptions to MoCo's pod.<br> - Added retrieve_keys to MoCo<br><br>Enjoy!</tt>jkondo2007-03-09T23:30:08+00:00cpanText::Hatena 0.20 released.
http://use.perl.org/~jkondo/journal/32524?from=rss
<tt>I uploaded Text::Hatena 0.20. It's quite new version of Text::Hatena.<br><br>I rewrote the whole code using Parse::RecDescent and Regexp::Assemble. Number of modules were reduced to 2 from 47 files. Line of codes where changed from 2600 lines to 600 lines. My benchmark marked 300-400% higher performance than ver.0.16.<br><br>I also removed some syntaxes which were specific to Hatena Diary.<br><br>Now, API for parsing text were changed too. Please be careful to upgrade your<br>Text::Hatena to version 0.20+.<br><br>You can use Text::Hatena simply as below.<br><br>my $html = Text::Hatena->parse($text);<br><br>And, you can extend your parser like this. You can easily make your original parser which can handle some other format.<br><br>package MyParser;<br>use strict;<br>use warnings;<br>use base qw(Text::Hatena);<br><br>__PACKAGE__->syntax(q|<br> h3 : "\n*" timestamp(?) inline(s)<br> timestamp :<nobr> <wbr></nobr>/\d{9,10}/ '*'<br>|);<br><br>sub h3 {<br> my $class = shift;<br> my $items = shift->{items};<br> my $title = $class->expand($items->[2]);<br> return if $title =~<nobr> <wbr></nobr>/^\*/;<br> my $ret = "<h3>$title";<br> if (my $time = $items->[1]->[0]) {<br> $ret<nobr> <wbr></nobr>.= qq|<span class="timestamp">$time</span>|;<br> }<br> $ret<nobr> <wbr></nobr>.= "</h3>\n";<br>}<br><br>sub timestamp {<br> my $class = shift;<br> my $items = shift->{items};<br> return $items->[0];<br>}<br><br>1;<br><br>You can also extend inline elements like this.<br><br>Text::Hatena::AutoLink->syntax({<br> 'id:([\w-]+)' => sub {<br> my $mvar = shift;<br> my $name = $mvar->[1];<br> return qq|<a href="/$name/">id:$name</a>|;<br> },<br> 'd:id:([\w-]+)' => sub {<br> my $mvar = shift;<br> my $name = $mvar->[1];<br> return qq|<a href="http://d.hatena.ne.jp/$name/">d:id:$name</a>|;<br> },<br>});<br><br>I'd like to get your feedback.</tt>jkondo2007-02-27T21:58:42+00:00cpanI changed the name of my model class to DBIx::MoCo again.
http://use.perl.org/~jkondo/journal/32380?from=rss
<tt>I changed the name of my model class to DBIx::MoCo again. I uploaded DBIx::MoCo ver. 0.06 and removed MoCo* files just now.<br>Thanks for suggesting me to change the name.<br><br>I also implemented cache_connection attribute in DBIx::MoCo::DataBase.<br><br>If its set to 0, DBIx::MoCo::DataBase uses DBI->connect instead of<br>DBI->connect_cached.<br><br> DBIx::MoCo::DataBase->cache_connection(0);<br></tt>jkondo2007-02-12T20:17:33+00:00cpanI fixed bug in MoCo and added keys accessor.
http://use.perl.org/~jkondo/journal/32316?from=rss
<p>I uploaded MoCo ver 0.05 today.<br>I fixed a bug that cached objects are not flushed correctly when they're stored without primary keys.<br>I added keys accessor to MoCo and changed flush mechanism.</p><p>If you define Entry.pm like this,</p><p>package Entry;<br>__PACKAGE__->primary_keys(['entry_id']);<br>__PACKAGE__->keys(['uri']);</p><p>and, retrieve an entry from uri,</p><p>my $e = Entry->retrieve_by_uri('http://123');</p><p>and, create a new entry.</p><p>my $e2 = Entry->create(uri => 'http://123');</p><p>The first cache, $e is flushed correctly.</p><p>(I'm still considering about the name.)</p>jkondo2007-02-04T01:31:45+00:00cpanI changed the name to MoCo and released ver 0.04.
http://use.perl.org/~jkondo/journal/32290?from=rss
<p>I changed the name of my model class to MoCo.pm<br>It's light & fast Model Component.<br>http://search.cpan.org/dist/MoCo/ (it's processing now)</p><p>Also, I implemented session features today.<br>You can delay your update/create operation using MoCo's session.</p><p>If you call MoCo->start_session once, a session will be started and update/create queries will be delayed until the session will be ended or save method will be called expressly.</p><p># in your web server etc..<br>MoCo->start_session;</p><p># in your scripts<br>my $user = Blog::User->retrieve(123);<br>$user->name('jkondo'); # not saved now. changed in cache.<br>print $user->name; # 'jkondo'<br>$user->save; # update db<br>print Blog::User->retrieve(123)->name; # 'jkondo'</p><p># Or, update queries will be thrown automatically after ending session.<br>$user->name('jkontan');<br>Moco->end_session;<br>print Blog::User->retrieve(123)->name; # 'jkontan'</p>jkondo2007-01-31T21:00:22+00:00cpanClass::Moco
http://use.perl.org/~jkondo/journal/32283?from=rss
<p>I uploaded Class::Moco 0.03 today.</p><p>Class::Moco is easy to cache model component.<br>It provides the way to create models like Class::DBI and store objects in cache easily.<br>http://search.cpan.org/dist/Class-Moco/</p><p>I'd like to get feedbacks.</p><p>Here is the SYNOPSIS of Class::Moco.</p><p>
# First, set up your db.<br>
package Blog::DataBase;<br>
use base qw(Class::Moco::DataBase);</p><p>
__PACKAGE__->dsn('dbi:mysql:dbname=blog');<br>
__PACKAGE__->username('test');<br>
__PACKAGE__->password('test');</p><p>
1;</p><p>
# Second, create a base class for all models.<br>
package Blog::TableObject;<br>
use base qw 'Class::Moco'; # Inherit Class::Moco</p><p>
__PACKAGE__->db_object('Blog::DataBase');</p><p>
1;</p><p>
# Third, create your models.<br>
package Blog::User;<br>
use base qw 'Blog::TableObject';</p><p>
__PACKAGE__->table('user');<br>
__PACKAGE__->primary_keys(['user_id']);<br>
__PACKAGE__->has_many(<br>
entries => 'Blog::Entry',<br>
{ key => 'user_id' }<br>
);<br>
__PACKAGE__->has_many(<br>
bookmarks => 'Blog::Bookmark',<br>
{ key => 'user_id' }<br>
);</p><p>
1;</p><p>
package Blog::Entry;<br>
use base qw 'Blog::TableObject';</p><p>
__PACKAGE__->table('entry');<br>
__PACKAGE__->primary_keys(['entry_id']);<br>
__PACKAGE__->has_a(<br>
user => 'Blog::User',<br>
{ key => 'user_id' }<br>
);<br>
__PACKAGE__->has_many(<br>
bookmarks => 'Blog::Bookmark',<br>
{ key => 'entry_id' }<br>
);</p><p>
1;</p><p>
package Blog::Bookmark;<br>
use base qw 'Blog::TableObject';</p><p>
__PACKAGE__->table('bookmark');<br>
__PACKAGE__->primary_keys(['user_id','entry_id']);<br>
__PACKAGE__->has_a(<br>
user => 'Blog::User',<br>
{ key => 'user_id' }<br>
);<br>
__PACKAGE__->has_a(<br>
entry => 'Blog::Entry',<br>
{ key => 'entry_id' }<br>
);</p><p>
1;</p><p>
# Now, You can use some methods same as in Class::DBI.<br>
# And, all objects are stored in cache automatically.<br>
my $user = Blog::User->retrieve(user_id => 123);<br>
print $user->name;<br>
$user->name('jkontan'); # update db immediately<br>
print $user->name; # jkontan</p><p>
my $user2 = Blog::User->retrieve(user_id => 123);<br>
# $user is same as $user2!</p><p>
# You can easily get has_many objects array.<br>
my $entries = $user->entries;<br>
my $entries2 = $user->entries;<br>
# $entries is same reference as $entries2!<br>
my $entry = $entries->first; # isa Blog::Entry<br>
print $entry->title; # you can use methods in Entry class.</p><p>
Blog::Entry->create(<br>
user_id => 123,<br>
title => 'new entry!',<br>
);<br>
# $user->entries will be flushed automatically.<br>
my $entries3 = $user->entries;<br>
# $entries3 isnt $entries!</p><p>
print ($posts1->[-1] eq $posts2->[-1]); # 1<br>
print ($posts1->[-1] eq $posts3->[-1]); # 1<br>
# It's same instance!</p>jkondo2007-01-30T22:33:19+00:00cpanHello Perl
http://use.perl.org/~jkondo/journal/32278?from=rss
It's my first journal.jkondo2007-01-30T05:32:53+00:00journal