Re: Anyone set up a client/server application using stream tubes?
Thanks, I'll check out Etoys further to see how it is done there. I've looked through Read already and have already documented a similar pattern in the Almanac. I was hoping to document some more advanced uses of stream tubes where users can share binary or large-sized data on demand (rather than just at startup for initializing an activity, which is what is done in Read). I've been finding it epecially challenging to use the stream tubes in conjunction with threads, which would allow such repeated sharing to occur without blocking the larger functionality of the activity. Best, Faisal On Mon, Oct 27, 2008 at 7:22 AM, Bert Freudenberg [EMAIL PROTECTED]wrote: Am 27.10.2008 um 11:23 schrieb Guillaume Desmottes [EMAIL PROTECTED]: Le vendredi 24 octobre 2008 à 14:18 +, Faisal Anwar a écrit : Hi All, I'm trying to document some more stuff related to Stream Tubes for the sugar almanac (http://wiki.laptop.org/go/Sugar_Almanac) and wanted to set up some examples related to the different types of client/server arrangments that can be supported by the sugar.network package. However, I've been having some trouble getting a client/server application up an running on a stream tube through threading. Has anyone else tried this and could you point me to some example code? One example of what I would like to be able to do: create a continuously running http server on one XO that can send files to requests from a client XO. I have created a server that can do this once, but when I try to get it to repeatedly listen for client requests, I am not able to get things working. Any help would be greatly appreciated! Hi, AFAIK, Read is currently the only OLPC activity using stream tubes Etoys uses stream tubes, too. - Bert - ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Anyone set up a client/server application using stream tubes?
Hi All, I'm trying to document some more stuff related to Stream Tubes for the sugar almanac (http://wiki.laptop.org/go/Sugar_Almanac) and wanted to set up some examples related to the different types of client/server arrangments that can be supported by the sugar.network package. However, I've been having some trouble getting a client/server application up an running on a stream tube through threading. Has anyone else tried this and could you point me to some example code? One example of what I would like to be able to do: create a continuously running http server on one XO that can send files to requests from a client XO. I have created a server that can do this once, but when I try to get it to repeatedly listen for client requests, I am not able to get things working. Any help would be greatly appreciated! Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Anyone seen this error when using sugar-launch?
Thanks Michael ... I'm trying that out. Faisal On Fri, Aug 8, 2008 at 5:41 PM, Michael Stone [EMAIL PROTECTED] wrote: Here's the relevant part: File /usr/share/sugar/services/shell/activityregistryservice.py, line 90, in FindActivity if name.find(key) != -1 or bundle_id.find(key) != -1: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128) The code in question is not unicode-safe or the locale is not set properly. Check out the use of the string encode() method in other parts of Sugar to properly convert unicode objects to string objects. Michael ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Anyone seen this error when using sugar-launch?
Hi, I just installed build 708 on an XO and also installed the standard set of activities using the script provided at http://wiki.laptop.org/go/Bert%27s_script. I can launch activities using their UI icons, but when I try to launch activities from the terminal using sugar-launch, I get the error below. Does anyone know why this is happening and how to fix it (couldn't find anything online that illuminated things :( ). [EMAIL PROTECTED] ~]$ sugar-launch read Traceback (most recent call last): File /usr/bin/sugar-launch, line 38, in module activities = registry.find_activity(args[0]) File /usr/lib/python2.5/site-packages/sugar/activity/registry.py, line 121, in find_activity info_list = self._registry.FindActivity(name) File /usr/lib/python2.5/site-packages/dbus/proxies.py, line 64, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/python2.5/site-packages/dbus/proxies.py, line 136, in __call__ **keywords) File /usr/lib/python2.5/site-packages/dbus/connection.py, line 607, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Python.UnicodeDecodeError: Traceback (most recent call last): File /usr/lib/python2.5/site-packages/dbus/service.py, line 692, in _message_cb retval = candidate_method(self, *args, **keywords) File /usr/share/sugar/services/shell/activityregistryservice.py, line 90, in FindActivity if name.find(key) != -1 or bundle_id.find(key) != -1: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128) Thanks, Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: [sugar] Question about clipboard service
I think if the gtk clipboard has the functionality, then I'll just document some examples for that and reference to the larger body of work available online. I guess there is less direct relevance for the sugar clipboardservice api right now when it comes to sharing stuff between activities (from the perspective of someone developing an activity). Thanks so much for the clarification. Faisal On Sat, Jul 19, 2008 at 3:14 PM, Tomeu Vizoso [EMAIL PROTECTED] wrote: Well, we can add some sugar API around the gtk clipboard stuff, but I'm not sure there's a lot of value in there, as the gtk+ API is already quite high level. The problem here is how do we extend the existing X specs to deliver the experience we aim for. Last we talked about it, Marco was opposed to use the X selection targets to pass titles and icons around. Eben, now is a good moment to start talking about it, can you summarize what is missing from the clipboard and try to list all that we want to do but the current spec doesn't allow to? Thanks, Tomeu On Sat, Jul 19, 2008 at 5:01 PM, Eben Eliason [EMAIL PROTECTED] wrote: I can't tell from your wording if you are implying that we will or will not be creating some custom wrappers for the clipboard service. I think we absolutely need them to accomplish several critical clipboard issues (among them, specifying icons, colors, titles, and previews for clippings). In fact, getting this API working effectively is high on my list of priorities for 9.1 - Eben On Sat, Jul 19, 2008 at 4:19 AM, Tomeu Vizoso [EMAIL PROTECTED] wrote: On Fri, Jul 18, 2008 at 10:29 PM, Faisal Anwar [EMAIL PROTECTED] wrote: Hi, I'm playing around with the clipboard package on sugar and had a quick question. So, the clipboardservice.py file shows some basic api for getting and setting objects on the clipboard through the dbus. However, the add_object and get_object methods (and their variants) rely on knowing an object_id in order to retrieve something from the clipboard. Typically, a clipboard has some stack like structure where you can automatically retrieve the last thing copied to the clipboard without necessarily knowing its internal id. This would seem especially important fo passing things to other activities, which can't reasonably figure out the object_id created when something is saved to the clipboard by another activity. Does anyone know how to just retrieve the last item saved to the clipboard and also get a list of the last N items saved to the clipboard? Also, the gtk.Clipboard framework allows access to several different clipboards that have slightly different purposes. Is there similar functionality available through sugar/dbus or would one go directly to the gtk implementation? Hi Faisal, we haven't reached any agreement yet about exposing a different clipboard API than the one in gtk+ (that wraps around the different clipboard-related specs used in X). In other words, nobody other than the shell should directly use the clipboard service and this will probably disappear in the future. Activity authors should the use the clipboard functionality as exposed by their toolkits (gtk+) or implement themselves those specs (as etoys has done). Can you add this note somewhere in the almanac? Thanks, Tomeu ___ Sugar mailing list [EMAIL PROTECTED] http://lists.laptop.org/listinfo/sugar ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Sugar Almanac Update - Using Pango, Internationalization
Hello All, I've put up some sample code and instructions on using Pango to render fonts in your sugar activities. I've also written up an updated set of steps to internationalize your activity based on the instructions at http://wiki.laptop.org/go/Python_i18n and my own experience getting text to translate. For those of you working on Pootle and other elements of internationalization, please feel free to update and change any parts of the Almanac to reflect where things are right now. You can visit the Almanac at http://wiki.laptop.org/go/Sugar_Almanac. As always, please send any feedback or comments. Also, feel free to add any new code snippets or alternative ways of doing things that are documented in the almanac. Best, Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: [sugar] Question about internationalization on sugar-jhbuild
Hi Tomeu, I'm starting up sugar-jhbuild with the command 'LANG=es ./sugar-jhbuild run'. Then I open up a terminal and do 'sugar-launch annotate'. I tried it with other activities and they seem to work just fine with translation. Faisal On Thu, Jul 3, 2008 at 8:38 AM, Tomeu Vizoso [EMAIL PROTECTED] wrote: Hi, from that strace log, seems like gettext thinks you are in the en locale, right? How are you running your activity? Regards, Tomeu On Wed, Jul 2, 2008 at 11:50 PM, Faisal Anwar [EMAIL PROTECTED] wrote: Hello All, I'm trying to set up some simple internationalization on a sugar activity but am running in to problems. I am specifically using sugar-jhbuild and launching it with 'LANG=es ./sugar-jhbuild run' command when I want to test my internationalization out. Here are the steps I have followed (I used http://wiki.laptop.org/go/Python_i18n and http://wiki.laptop.org/go/Localization/Testing to guide me): 1. First, I created a directory within my activity (a simple shell fo an activity which I have called Annotate.activity) called 'po' and I went in to that directory. 2. In Annotate.activity/po, I created a POTFILES.in file and put the following text: encoding: UTF-8 annotateactivity.py 3. I launched sugar-jhbuild and went in to the terminal, where I ran 'python setup.py genpot' from the Annotate.activity directory. This generated an 'Annotate.pot' file. I went in to Annotate.pot and added some translations for strings that I knew would need translating in my program (one specific one was a from a print statement where the string is wrapped in _()). 4. Still in sugar-jhbuild's terminal, I ran 'msginit -l es' which generated a file called 'es.po'. 5. finally, I did 'msgfmt -o ../locale/es/LC_MESSAGES/org.laptop.AnnotateActivity.mo es.po' to generate the mo file and place it within the right directory for spanish (the directory path is similar to the one I found for Web.activity, whose translations are working fine). After doing all this, I restarted sugar-jhbuild by using 'LANG=es ./sugar-jhbuild run' . I can see other activities have text translated, but my activity is not translating the text that I wrapped in _() and was printing out. I checked the source file and I am using gettext (importing it as _ and then using the wrapper in the print statement I want translated). Someone suggested trying to do an strace to see what was happening. I did this and found the following in the portion of the log where it has any reference to the string I want translated: stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) write(1, hello world should be translated..., 33hello world should be translated ) = 33 1 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 2 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 3 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 4 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 5 write(1, hello world should be translated..., 33hello world should be translated 6 ) = 33 1 2 3 4 5 6 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file
Question about internationalization on sugar-jhbuild
Hello All, I'm trying to set up some simple internationalization on a sugar activity but am running in to problems. I am specifically using sugar-jhbuild and launching it with 'LANG=es ./sugar-jhbuild run' command when I want to test my internationalization out. Here are the steps I have followed (I used http://wiki.laptop.org/go/Python_i18n and http://wiki.laptop.org/go/Localization/Testing to guide me): 1. First, I created a directory within my activity (a simple shell fo an activity which I have called Annotate.activity) called 'po' and I went in to that directory. 2. In Annotate.activity/po, I created a POTFILES.in file and put the following text: encoding: UTF-8 annotateactivity.py 3. I launched sugar-jhbuild and went in to the terminal, where I ran 'python setup.py genpot' from the Annotate.activity directory. This generated an 'Annotate.pot' file. I went in to Annotate.pot and added some translations for strings that I knew would need translating in my program (one specific one was a from a print statement where the string is wrapped in _()). 4. Still in sugar-jhbuild's terminal, I ran 'msginit -l es' which generated a file called 'es.po'. 5. finally, I did 'msgfmt -o ../locale/es/LC_MESSAGES/ org.laptop.AnnotateActivity.mo es.po' to generate the mo file and place it within the right directory for spanish (the directory path is similar to the one I found for Web.activity, whose translations are working fine). After doing all this, I restarted sugar-jhbuild by using 'LANG=es ./sugar-jhbuild run' . I can see other activities have text translated, but my activity is not translating the text that I wrapped in _() and was printing out. I checked the source file and I am using gettext (importing it as _ and then using the wrapper in the print statement I want translated). Someone suggested trying to do an strace to see what was happening. I did this and found the following in the portion of the log where it has any reference to the string I want translated: 1. stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 2. stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 3. stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 4. stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 5. write(1, hello world should be translated..., 33hello world should be translated 6. ) = 33 1 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 2 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 3 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 4 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) 5 write(1, hello world should be translated..., 33hello world should be translated 6 ) = 33 1 2 3 4 5 6 stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en_US/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en.UTF8/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) stat(/home/fanwar/sugar-jhbuild/sugar-jhbuild/install/share/sugar/activities/Annotate.activity/locale/en/LC_MESSAGES/ org.laptop.AnnotateActivity.mo, 0x7fffa41f75d0) = -1 ENOENT (No such file or directory) write(1, hello world should be translated..., 33hello world should be translated ) = 33 1.
Re: Recent Updates to Sugar Almanac
Hi Tomeu, No problem about the late reply ... I am documenting improvements as I document the current state of the system. So I'll try to suggest some more coherent api as well. Let's keep in touch about this. Faisal On Tue, Jul 1, 2008 at 4:49 AM, Tomeu Vizoso [EMAIL PROTECTED] wrote: Hi Faisal, sorry to get to this so late, are there any outstanding doubts? The DS is right now a big mess due to long-standing bugs and basic features still unimplemented. I hope that during the next release significant resources will be allocated to this, if in the meantime you could suggest better APIs (both high and low level), that would be awesome. Thanks, Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Updates This Week to the Sugar Almanac - Using the Datastore and More
Hi Tomeu, Thanks so much for the clarifications. I understand now the abstraction intended for metadata accessed through DSMetadata and DSObject and will try to write that up a little more forcefully. I guess the main thing I was concerned about was having a consistent and lasting interface to the datastore (which can certainly be implemented in the form of a dictionary if that is most appropriate). I hope this abstraction will hold moving forward so that activity developers are confident that their hooks in to datastore will work with the same behavior over time (this is part of the purpose of the documentation I'm working on). With regards to the lower level DBus calls in datastore and elsewhere, what I'm really looking out for is what levels of the tech stack an activity developer will need to learn to build a fairly robust and complex activity. Of course, for some things lower level Dbus calls may be unavoidable, but I'm assuming that there should be a substantive interface in python that abstracts away the Dbus functionality for most developers. As I go through more of the code in datastore, presence, and elsewhere, I'll try to identify cases where perhaps a low-level Dbus call could be abstracted to some standard python calls. Faisal On Wed, Jun 25, 2008 at 4:28 AM, Tomeu Vizoso [EMAIL PROTECTED] wrote: Hi Faisal, some answers below: 2008/6/24 Faisal Anwar [EMAIL PROTECTED]: ?? Is there a specific reason why there isn't a set() method in the datastore.DSMetadata class? Shouldn't people be given standard accessors and mutators to work with this code. This is especially confusing because it seems there is presently a get() method, but the set() method does not exist (so the abstraction is completely different based on whether you are getting or setting data). d That class is to be used in the same way as dictionaries in python, so the API mimics that. By implementing __getitem__, __setitem__ and get(), the user can do the following: obj.metadata['my-property'] = 'blah blah' print obj.metadata['my-property'] print obj.metadata.get('my-property', 'N/A') ?? Several things that are currently documented at http://wiki.laptop.org/go/Low-level_Activity_API#Keeping_and_Resumingare outdated. Specifically, it says datastore.create() returns the object_id. That's wrong, it returns the actual DSObject. Furthermore, it says there are methods called datastore.update and datastore.get_properties, but they don't exists. That page documents the low level API that can be used by all activities, no matter in which language are written. sugar.datastore is a higher level API only available to python activities. See here for the D-Bus API of the datastore: http://dev.laptop.org/git?p=projects/datastore;a=blob;f=src/olpc/datastore/datastore.py ?? The deletion/destruction of datastore activities seems to be a little confusing. In particular, there is a datastore.delete() method and there is also a DSObject.destroy() method. Why doesn't datastore.delete() simply call the destroy() method in its code so that any files associated with the deleted datastore object are also removed. Given that a warning is thrown telling the developer that an object is deleted without directly calling DSObject.destroy() (it is called indirectly through the __del__ method, but why not have things more explicit?), I'm not sure why this isn't just done programmatically. Is there ever a reason why one woul perform a delete() on an object without doing the functionality in DSObject.destroy() and are any of these reasons compelling enough that we should keep the delete() and destroy() methods as they are now? Well, datastore.delete() instructs the datastore to delete the object from its persistent storage. DSObject.destroy() is intended to be called when the user stops needing the transient instance that represents the persistent object. This is similar to DB programming with SQL in procedural languages, deleting the resultset object is not the same as deleting the rows that are contained in that resultset. Other questions may come up as people work more on this documentation. In the meantime, I'd greatly appreciate any feedback on the existing work and also any answers to the questions above. Nice work, more questions welcome. Regards, Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Updates This Week to the Sugar Almanac - Using the Datastore and More
Hello All, First off, thanks to everyone who has been contributing to the almanac ( http://wiki.laptop.org/go/Sugar-api-doc) directly or giving me feedback on things that need to be added or improved for accuracy. Please keep the feedback coming. Among many other additions, the Sugar Almanac now has a section on using the datastore. It includes a basic overview of the architecture as well as a bunch of entries on how to do different useful tasks with the datastore: - 2 Datastore Helper Functionshttp://wiki.laptop.org/go/Sugar.datastore.datastore#Datastore_Helper_Functions - 2.1 How do I create a new datastore object?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_create_a_new_datastore_object.3F - 2.2 How do I provide a query to the datastore.find() method so that I can find datastore objects with a particular property?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_provide_a_query_to_the_datastore.find.28.29_method_so_that_I_can_find_datastore_objects_with_a_particular_property.3F - 2.3 How do I delete datastore entries with a particular property?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_delete_datastore_entries_with_a_particular_property.3F - 2.4 How do I get all the unique values that are mapped to a particular key in the datastore?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_get_all_the_unique_values_that_are_mapped_to_a_particular_key_in_the_datastore.3F - 2.5 How do I get command line access to the files in my DataStore?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_get_command_line_access_to_the_files_in_my_DataStore.3F - 2.6 How do I identify the different mount points available through the datastore api?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_identify_the_different_mount_points_available_through_the_datastore_api.3F - 3 Class: DSObjecthttp://wiki.laptop.org/go/Sugar.datastore.datastore#Class:_DSObject - 3.1 How do I create new metadata entries or reassign metadata for a datastore object that has been created?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_create_new_metadata_entries_or_reassign_metadata_for_a_datastore_object_that_has_been_created.3F - 3.2 How do I save a simple text file to the datastore?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_save_a_simple_text_file_to_the_datastore.3F - 3.3 How do I resume an activity from the datastore programmatically?http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_resume_an_activity_from_the_datastore_programmatically.3F Also, for those who are experienced with writing the actual datastore code, I had the following questions that came up while trying to understand how this module works: ?? Is there a specific reason why there isn't a set() method in the datastore.DSMetadata class? Shouldn't people be given standard accessors and mutators to work with this code. This is especially confusing because it seems there is presently a get() method, but the set() method does not exist (so the abstraction is completely different based on whether you are getting or setting data). d ?? Several things that are currently documented at http://wiki.laptop.org/go/Low-level_Activity_API#Keeping_and_Resuming are outdated. Specifically, it says datastore.create() returns the object_id. That's wrong, it returns the actual DSObject. Furthermore, it says there are methods called datastore.update and datastore.get_properties, but they don't exists. ?? The deletion/destruction of datastore activities seems to be a little confusing. In particular, there is a datastore.delete() method and there is also a DSObject.destroy() method. Why doesn't datastore.delete() simply call the destroy() method in its code so that any files associated with the deleted datastore object are also removed. Given that a warning is thrown telling the developer that an object is deleted without directly calling DSObject.destroy() (it is called indirectly through the __del__ method, but why not have things more explicit?), I'm not sure why this isn't just done programmatically. Is there ever a reason why one woul perform a delete() on an object without doing the functionality in DSObject.destroy() and are any of these reasons compelling enough that we should keep the delete() and destroy() methods as they are now? Other questions may come up as people work more on this documentation. In the meantime, I'd greatly appreciate any feedback on the existing work and also any answers to the questions above. Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Recent Updates to Sugar Almanac
Hi James, Thanks for the feedback. I had two follow up questions for you or others who are in the know with datastore: 1. You said: 'However, if your application is like Read, Read Etexts, or View Slides, which are always resumed from existing Journal entries, there is no need to write a file. You can still save metadata, even if you don't write a file.' I've written the following sample code: def write_file(self, file_path): logging.debug('WRITING FILE ...') self.metadata['current_page'] = '3' #f = open(file_path, 'w') #try: #f.write(Hello World) #finally: #f.close() Now, when the part about writing to a file is commented out, I get the following error when I run my activity in the terminal: 1213618380.556841 DEBUG root: Error saving activity object to datastore: org.freedesktop.DBus.Python.IOError: Traceback (most recent call last): File /usr/lib/python2.5/site-packages/dbus/service.py, line 655, in _message_cb retval = candidate_method(self, *args, **keywords) File /home/fanwar/sugar-jhbuild/sugar-jhbuild/install/lib/python2.5/site-packages/olpc/datastore/datastore.py, line 475, in update completion=lambda *args: self._update_completion_cb(async_cb, async_err_cb, content, *args)) File /home/fanwar/sugar-jhbuild/sugar-jhbuild/install/lib/python2.5/site-packages/olpc/datastore/backingstore.py, line 583, in update_async filelike = open(filelike, r) IOError: [Errno 2] No such file or directory: dbus.String(u'/home/fanwar/.sugar/default/org.laptop.AnnotateActivity/instance/1213618380') So I guess the question is how do you just save metadata without writing to a file? It seems that sugar errors out when I try to do that. Do you have some sample code I could try out? 2. What exactly is the behavior (or at least the intended behavior) of metadata and files in the datastore? What are the rules for persisting metadata - is it a bug that it does not persist through reboots, or is this intended functionality? Is the metadata-file model one where you always have a single file in the datastore that maps to a specific activity instance and metadata is always attached to this file? Or is there some other model for how the metadata, files and activitities interact? I guess at a fundamental level, I am wondering how the conception of journal activities outlined at http://wiki.laptop.org/go/OLPC_Human_Interface_Guidelines/The_Laptop_Experience/The_Journal#The_Journaltranslates to some technical model for how stuff is stored. My understanding (from talking to other sugar developers and looking at what you've written at Beyond Hello World) has been that datastore has files and metadata for each activity- but it seems that if everything is supposed to be abstracted as an activity, then there should be some data structure that represents this and then the files and metadata are there to give additional information about the activity itself. This would avoid confusion as to whether there must be a file or metadata or some other ancillary information to save an activity. Faisal On Mon, Jun 16, 2008 at 10:13 AM, James Simmons [EMAIL PROTECTED] wrote: Faisal, What you wrote looks good, but I did see a possible error in it. You say: The following simple write_file() method shows how both metadata and files are written. Currently, write_file() will throw an error unless somewhere you actually write an actual file to the file_path that is passed to write_file. The code below writes a dummy file within the body of write_file itself (you can do this elsewhere as long as you have a handle on the file_path variable used by write_file). I think this is not always true. Now if you're creating a new Journal entry for your app and have implemented write_file it *might* be true. However, if your application is like Read, Read Etexts, or View Slides, which are always resumed from existing Journal entries, there is no need to write a file. You can still save metadata, even if you don't write a file. Another thing worth pointing out is that metadata doesn't work very well right now. If I was in the position where I needed to write a file but didn't have anything that needed to go into it I wouldn't use metadata at all. Instead I would put any saved options, etc. in the file, because *that* would persist across reboots but metadata currently does not. I think several activities already do this. I wrote a wiki page titled Beyond Hello World that covers much the same ground as yours, but I like yours better. Thanks, James Simmons Date: Fri, 13 Jun 2008 17:34:43 -0400 From: Faisal Anwar [EMAIL PROTECTED] Subject: Recent Updates to Sugar Almanac To: devel@lists.laptop.org, [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 Hello All, As many of you know, I'm writing up a sugar almanac to help new sugar/python developers get up and running
Question about logging behavior
Hi, I'm trying to do simple logging for an activity, but am finding some strange behavior with logging that I'm hoping someone can clarify for me. In particular, I've written code similar to the following: import logging _logger = logging.getLogger('Annotate') class MyActivity(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) _logger.debug('starting myactivity') Now, when I start my activity up, I don't find any logs that are written to with the logging message. However, when I resume the activity from the journal, I do see the logging message that I have written in my code. Does anyone know why logging seems to only happen when you resume an activity from the journal and doesn't when you start an activity from scratch (I start the activity using the sugar-launch command in the terminal). Thanks Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Recent Updates to Sugar Almanac
Hi James, Based on your feedback, I've changed to wording for the write_file() entry to the following: *The following simple write_file() method shows how both metadata and files are written. write_file() must point to a physical file. This file reference can be created in several ways: * 1. * Your program can explicitly create a file in write_file() and write to it. * 2. * You can download or save a file to a particular location and then change the self._jobject.file_path variable (as the Read activity does).* However, I still am hesitant about writing metadata to a physical file if the activity doesn't use a physical file for anything else. At a conceptual level, this approach (to me) seems like it would confuse what is metadata and what is actual file data and puts unnecessary burden on a developer to keep track. Ideally, I'm wondering if there should just be an abstraction to an activity as having both metadata and file data and it is the prerogative of the developer to put stuff where it is appropriate (without the two necessarily interacting, as is now the case where you have to put metadata about an activity in a physical file if none exists). If I were to write a wrapper for datastore to build this abstraction, it would look something like: class ActivityInstanceInDatastore: def write_metadata_entry(self, key, value) def read_metadata_entry(self, key) def write_file(self, file_path, stuff_to_write) def read_file(self, file_path) These exist already to some extent in datastore, but it seems from this thread that the functional behavior doesn't yet follow a strict pattern of behavior. Also, there is the issue of activities having multiple data files (eg. for a file diff activity) which I believe is dealt with by setting special metadata mappings to keep track of all the files (correct me if I'm wrong). Practically, I understand there will be many cases where the current setup won't be a huge deal. However, it will be a big problem when people develop activities that may or may not be associated with a data file at different times. For example, I could envision a music activity that has specific preset music settings (such as frequency settings, volume, etc.) as well as optional files that are being manipulated by the activity. If the user doesn't have a data file open, then you would just want to save metadata, but then later if the user does open an audio file, then you will want to have both metadata and physical data. Rather than keeping track of what state you are in, it seems more coherent and natural that the developer only worries about specific calls to write metadata when he wants to write metadata (like volume and playback settings) and only worries about file-specific calls when he wants to manipulate files. Thanks Faisal On Mon, Jun 16, 2008 at 1:35 PM, James Simmons [EMAIL PROTECTED] wrote: Faisal, Look at the code for the Read activity. It never creates a Journal entry itself. What it does is to resume from a directory entry created by downloading a PDF through the Browse activity or perhaps one copied from a USB key using the Journal activity. So there *is* a file in the Journal entry, but there is no desire to update that file. If you have that situation you can save metadata without writing a file, just like Read does. No special code is needed. Metadata not being preserved across a reboot is a known bug. Metadata not being preserved for entries on SD cards and USB keys is a *feature*. These devices are not considered part of the Journal proper, although the current UI makes them *look* like they should be. There are good reasons to treat files on USB devices differently from Journal entries. I understand that the USB and SD parts of the Journal may be given a different look to avoid this kind of confusion. I don't know when this will happen. The developers who could do this have a lot on their plates. If you have no data file, it would be a good idea to use a file to store persistent information about options, etc. The only time you wouldn't do that is when you have a file in the datastore that must not be modified, as in the Read activity. James Simmons Faisal Anwar wrote: Hi James, Thanks for the feedback. I had two follow up questions for you or others who are in the know with datastore: 1. You said: 'However, if your application is like Read, Read Etexts, or View Slides, which are always resumed from existing Journal entries, there is no need to write a file. You can still save metadata, even if you don't write a file.' ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: [sugar] Recent Updates to Sugar Almanac
Thanks! I'll make an effort to include these in the almanac. Faisal On Fri, Jun 13, 2008 at 10:31 PM, Martin Sevior [EMAIL PROTECTED] wrote: Hi Faisal, You might want to gather together the documentation we wrote for abiwidget which explains how to embed the collaborative Rich Text widget (as used by write) in python programs. The links are on our wiki here: http://www.abisource.com/wiki/AbiWidget http://www.abisource.com/wiki/PyAbiWord Cheers Martin On Fri, 2008-06-13 at 17:34 -0400, Faisal Anwar wrote: Hello All, As many of you know, I'm writing up a sugar almanac to help new sugar/python developers get up and running with creating useful activities. I will try to send frequent updates in terms of what has been added. In addition to using the documentation, I'd appreciate it if people familiar with the different modules I am writing can send any better or alternative code examples to the ones that I have written. Review and feedback is ALWAYS appreciated. This week, I have updated the section on how to do many of the basic activity creation tasks (see http://wiki.laptop.org/go/Sugar.activity.activity). In addition, I've provided some basic examples of how to read and write your activity to the datastore so that it can be resumed later from the journal. Below is a list of the different how to's contained in this section of the almanac. Hope some of these ring a bell in terms of what you all are trying to get done! * 1 Helper Functions in sugar.activity.activity * 1.1 How do I get the file path for my activity bundle? * 1.2 How do I get the file path where I can write files programmatically? * 1.3 How do I get the name of my activity? * 2 Class: Activity * 2.1 How do I set the canvas (main work area) of my activity to a specific UI widget? * 2.2 What are activity id's? How do I obtain the activity id for an instance of my activity? * 2.3 How do I create a new activity that is derived from the base Activity class? * 2.4 How do I implement a write_file method for my activity in order to persist my activity in the journal? * 2.5 How do I implement a read_file method for my activity so that I can resume activities from the sugar journal? * 3 Class: ActivityToolbox (Toolbox) * 3.1 What is the standard toolbox needed in most activities and how do I create it? * 3.2 How do I get a handle on the standard activity toolbar given an ActivityToolbox object? * 4 Class: ActivityToolbar (gtk.Toolbar) * 5 Class: EditToolbar (gtk.Toolbar) * 5.1 How do I add a standard edit toolbar to my activity? * 5.2 How do I hide a button in the edit toolbar that is not needed in my activity? * 5.3 How do I disable and enable a button on the edit toolbar? You can also find the homepage for the documentation at http://wiki.laptop.org/go/Sugar-api-doc. Best, Faisal ___ Sugar mailing list [EMAIL PROTECTED] http://lists.laptop.org/listinfo/sugar ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Recent Updates to Sugar Almanac
Hello All, As many of you know, I'm writing up a sugar almanac to help new sugar/python developers get up and running with creating useful activities. I will try to send frequent updates in terms of what has been added. In addition to using the documentation, I'd appreciate it if people familiar with the different modules I am writing can send any better or alternative code examples to the ones that I have written. Review and feedback is ALWAYS appreciated. This week, I have updated the section on how to do many of the basic activity creation tasks (see http://wiki.laptop.org/go/Sugar.activity.activity). In addition, I've provided some basic examples of how to read and write your activity to the datastore so that it can be resumed later from the journal. Below is a list of the different how to's contained in this section of the almanac. Hope some of these ring a bell in terms of what you all are trying to get done! - 1 Helper Functions in sugar.activity.activityhttp://wiki.laptop.org/go/Sugar.activity.activity#Helper_Functions_in_sugar.activity.activity - 1.1 How do I get the file path for my activity bundle?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_get_the_file_path_for_my_activity_bundle.3F - 1.2 How do I get the file path where I can write files programmatically?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_get_the_file_path_where_I_can_write_files_programmatically.3F - 1.3 How do I get the name of my activity?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_get_the_name_of_my_activity.3F - 2 Class: Activityhttp://wiki.laptop.org/go/Sugar.activity.activity#Class:_Activity - 2.1 How do I set the canvas (main work area) of my activity to a specific UI widget?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_set_the_canvas_.28main_work_area.29_of_my_activity_to_a_specific_UI_widget.3F - 2.2 What are activity id's? How do I obtain the activity id for an instance of my activity?http://wiki.laptop.org/go/Sugar.activity.activity#What_are_activity_id.27s.3F_How_do_I_obtain_the_activity_id_for_an_instance_of_my_activity.3F - 2.3 How do I create a new activity that is derived from the base Activity class?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_create_a_new_activity_that_is_derived_from_the_base_Activity_class.3F - 2.4 How do I implement a write_file method for my activity in order to persist my activity in the journal?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_implement_a_write_file_method_for_my_activity_in_order_to_persist_my_activity_in_the_journal.3F - 2.5 How do I implement a read_file method for my activity so that I can resume activities from the sugar journal?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_implement_a_read_file_method_for_my_activity_so_that_I_can_resume_activities_from_the_sugar_journal.3F - 3 Class: ActivityToolbox (Toolbox)http://wiki.laptop.org/go/Sugar.activity.activity#Class:_ActivityToolbox_.28Toolbox.29 - 3.1 What is the standard toolbox needed in most activities and how do I create it?http://wiki.laptop.org/go/Sugar.activity.activity#What_is_the_standard_toolbox_needed_in_most_activities_and_how_do_I_create_it.3F - 3.2 How do I get a handle on the standard activity toolbar given an ActivityToolbox object?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_get_a_handle_on_the_standard_activity_toolbar_given_an_ActivityToolbox_object.3F - 4 Class: ActivityToolbar (gtk.Toolbar)http://wiki.laptop.org/go/Sugar.activity.activity#Class:_ActivityToolbar_.28gtk.Toolbar.29 - 5 Class: EditToolbar (gtk.Toolbar)http://wiki.laptop.org/go/Sugar.activity.activity#Class:_EditToolbar_.28gtk.Toolbar.29 - 5.1 How do I add a standard edit toolbar to my activity?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_add_a_standard_edit_toolbar_to_my_activity.3F - 5.2 How do I hide a button in the edit toolbar that is not needed in my activity?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_hide_a_button_in_the_edit_toolbar_that_is_not_needed_in_my_activity.3F - 5.3 How do I disable and enable a button on the edit toolbar?http://wiki.laptop.org/go/Sugar.activity.activity#How_do_I_disable_and_enable_a_button_on_the_edit_toolbar.3F You can also find the homepage for the documentation at http://wiki.laptop.org/go/Sugar-api-doc. Best, Faisal ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel