[Sugar-devel] Journal Implementation Help

Walter Bender walter.bender at gmail.com
Tue Jun 15 12:42:39 EDT 2010


On Tue, Jun 15, 2010 at 12:37 PM, Quoc-Bao Vuong <vqbao at lv5.org> wrote:
> I'm a student from Arlington and am spending full-time this week and next
> working on the IRC Activity. I'm trying to implement this feature:
> http://bugs.sugarlabs.org/ticket/581 - which is to have the IRC Activity
> recover some information from the Journal when a saved instance is resumed
> (namely, the server, nickname, channels, and scrollback history - so you're
> back in the place you last left your conversation).
> I'm stuck, and haven't been able to find what to do next from either
> googling around the wiki or asking on IRC, or blogging about it
> (https://sites.google.com/a/lv5.org/bvworks/home/working-with-sugarlabs/journalimplementationtoxoirc).
> Here's what I've done so far (also summarized on the ticket) and the
> questions I think I need answered - any help would be appreciated.
> To get started, I looked up on how the journal interacts with a Sugar
> Activity, which is through the write_file() and read_file() methods. The
> write_file() method of the activity will save the data given from it and
> will be used later from the journal using the read_file() method. Nicknames
> are stored in Network.nicks in irc.py. Channels are stored in Core.channels
> in core.py. The server is stored in Network.server in irc.py. I haven't
> found out where all the messages go at the moment.
> When making the write_file(), I was able to read in the current nickname,
> server, and channels. When I try putting them back in when opening the
> latest journal, I just get the default settings. Default nickname, default
> server, and default channels. The server makes sense, because
> irc.freenode.net was written in the code when opening up. The channels and
> nicknames were also written in the code as well, but I thought running
> add_channel() or run_command("/nick myname") would overwrite those settings.
> For channels, when I ran the command "/join," it did not actually add the
> channel into the the Core.channels list. It only works if  I put the line
> "add_channel(#example)" into the code.
> so now I have some questions hoping to be answered:
>     * How can I overwrite the settings wanted?
>     * Where can I find the text for the history scrollback?
>     * Do the commands /nick and /join actually store the information to
> their respected lists
>     * What is the proper way to write the write_file() and read_file()
> methods for a sugar activity. I've seen two ways (using metadata and
> writing/reading into files), but I'm not sure what works best for this type
> of situation.
> Any help would be appreciated. I'm nhacbv in #sugar and am usually online
> during the US workday.
>
> --- Bao Vuong
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
Ben was too quick.

read_file and write_file are for data retrieval/storage, but simple
paramters such as nick, color, channel, etc. could just as easily be
stored in metadata. Try:

self.metadata['your key'] == value

value = self.metadata['your key']

See the abacus activity as an example.

-walter



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list