Thanks. It works now. In case anyone else wants to do this, here's what I ended up with:
def open_url(self, url): """Ask the journal to open an URL for us.""" from sugar import profile from shutil import rmtree from sugar.datastore import datastore from sugar.activity.activity import show_object_in_journal from tempfile import mkdtemp tmpfolder = mkdtemp('.tmp', 'url', os.path.join(self.get_activity_root(), 'instance')) tmpfilepath = os.path.join(tmpfolder, 'url') try: tmpfile = open(tmpfilepath, 'w') tmpfile.write(url) tmpfile.close() os.chmod(tmpfolder, 0755) os.chmod(tmpfilepath, 0755) jobject = datastore.create() metadata = { 'title': url, 'title_set_by_user': '1', 'buddies': '', 'preview': '', 'icon-color': profile.get_color().to_string(), 'mime_type': 'text/uri-list', } for k, v in metadata.items(): jobject.metadata[k] = v # the dict.update method is missing =( jobject.file_path = tmpfilepath datastore.write(jobject) show_object_in_journal(jobject.object_id) jobject.destroy() finally: rmtree(tmpfilepath, ignore_errors=True) # clean up! -josh On Mar 9, 2008, at 3:27 PM, C. Scott Ananian wrote: > On Sun, Mar 9, 2008 at 1:18 PM, Joshua Minor <[EMAIL PROTECTED]> wrote: >> I made an activity wrapper for the interactive fiction interpreter >> Frotz. I want to have a button in the toolbar called "Get More >> Games" >> that opens a web page where you can download z-machine files. >> >> It looks like Chat lets you copy links to the clipboard and you can >> open them from there. I'll try that for now. > > You can also ask the journal to open a link for you. Look at how > Pippy/Browse handle the 'show source' key. > > For security reasons, we don't let activities directly invoke other > activities. Mediating the interaction with the journal ensures that > the child's interaction is involved. > --scott > > -- > ( http://cscott.net/ ) _______________________________________________ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel