[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re[2]: [coldsync-hackers] Writing conduits that read more then one DB.



On Friday 06 June 2003 20:05, Izzy Blacklock wrote:

> if !defined $HEADERS{ DBpath }
> 	{
> 	( $HEADERS{ DBpath } = $HEADERS{ InputDB }  ) =~  !(.*)/.*$!$1!;
> 	}
>
> This is what I'm doing now.  I'd still like to be able to load it as a
> default value in the hash above before the headers are processed though. 
> If anyone has suggestions of how this could be done, I'd love to here
> them! ;)

That's what I was thinking while following the thread.

$HEADERS{InputDB} isn't set until StartConduit/ConduitMain runs, so anything 
you do before that is just wishful thinking. But StartConduit/ConduitMain 
rely on sane defaults in %HEADERS and you want DBpath mentioned so the 
-config command line works, so you want something useful as a default. 
Circular dependency, right?

What I'm wondering is why you'd even want to allow the user to define the 
path of the .pdb's? If they aren't all in the same location as InputDB, 
you're basically syncing Palm databases from somewhere that coldsync 
doesn't know anything about. That... doesn't seem right.

If you assume that all the databases are where InputDB is, then there's no 
reason why you need to fuss with trying to get the path into %HEADERS at 
all. $HEADERS{InputDB} will be set for you and that's all you need, right? 
Okay, maybe the database _names_ could be defined there, but the user has 
already configured that path in the "palm" section of the configuration...

Er... which is also where $HEADER{PDA-Directory} is derived from, isn't it? 
Which would mean that the databases are all supposed to be in 
"$HEADER{PDA-Directory}/backup"?

So all $HEADER{InputDB} is useful for is as a database that has conveniently 
been opened for you by StartConduit:
------------------------------------------------------------------------------------------
%HEADERS = (
         File            =>      "./TitraxTestOutput.txt",
);

StartConduit('dump');

my %pdbs;

foreach( qw(Datebookdb TitraxNoteDB TitraxDataDB TitraxNameDB) ) {
	($pdbs{$_} = $PDB and next) if $PDB->{name} eq $_;

	$pdsb{$_} = new Palm::PDB;
	$pdbs{$_}->Load(  $HEADER{PDA-Directory} . "/backup/" . $_ . ".pdb" );
}

------------------------------------------------------------------------------------------

I suppose you could allow the user to specify the names of all the databases 
in the config in which case you'd need to map your internal names to 
whatever the user specifies.

But the gist of all that is you end up with four open databases each 
accessible as $pdbs{<dbname>}.

If you want to write at the end of the conduit, you do need something like:
------------------------------------------------------------------------------------------
foreach( values %pdbs ) {
	$_->Write( $HEADER{PDA-Directory} . "/backup/" . $_->{name} . ".pdb" );
}
------------------------------------------------------------------------------------------

Anyhow, my two cents. I'm pretty new to this conduit thing myself.

c.

-- 
This message was sent through the coldsync-hackers mailing list.  To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body.  For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.