Development Team/Almanac/Code Snippets: Difference between revisions

FIELD_OTHER
m Reverted edits by 61.19.222.7 (Talk) to last version by 80.90.160.194
Line 38: Line 38:
FIELD_MESSAGE_boboget
FIELD_MESSAGE_boboget


FIELD_MESSAGE_sitalc
== Files ==
 
This snippet shows how to get a [http://mailman.laptop.org/pipermail/sugar/2007-February/001459.html path to files in the running Activity]:
 
from sugar.activity import activity
bundle_path = activity.get_bundle_path()
 
This snippet shows how to get [http://lists.laptop.org/pipermail/devel/2008-March/011799.html a path to an activity's writable directories] (i.e. the SUGAR_ACTIVITY_ROOT environment variable; see also [[Activity_DBus_API#Security | the activity DBus API]]):
 
class WebActivity(activity.Activity):
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        temp_path = os.path.join(self.get_activity_root(), 'instance')


== Images ==
== Images ==