Inherits from
- HasTraits: enthought.traits.has_traits.HasTraits
Attributes
- application
Current envisage application.
application = Instance(Application, transient = True)
- dirty
True if this project contains un-saved state (has been modified.)
dirty = Bool(False, transient = True)
- is_save_allowed
True if we allow save requests on the project.
is_save_allowed = Bool(True, transient = True)
- is_save_as_allowed
True if we allow save_as requests on the project.
is_save_as_allowed = Bool(True, transient = True)
- location
The location of this project on the filesystem. The default value depends on the runtime environment so we use a traits default method to set it.
location = Directory
- name
The name of this project. This is calculated from the project's current location or, if there is no location, from a default value. See the property's getter method.
name = Property(Str)
- PROJECTS_ARE_FILES
Indicates whether instances of this project class are stored as files or directories. The rest of the single_project plugin will follow this setting when using this project class.
This is meant to be a constant for the lifetime of this class!
PROJECTS_ARE_FILES = True
- traits_view
The UI view to use when creating a new project
traits_view = View(Group('location'), title = 'New Project', id = 'enthought.envisage.single_project.project.Project', buttons = [ 'OK', 'Cancel' ], width = 0.33000000000000002, close_result = False, resizable = True)
Inherited from base classes
Method summary
- __getstate__(self)
- __setstate__(self, state)
- __str__(self)
- get_default_name(self)
- get_default_path(cls, application)
- get_default_project_location(self, application)
- get_pickle_filename(cls, location)
- get_pickle_package(cls)
- load(cls, location, application)
- register_editor(self, resource, editor, remove = False)
- save(self, location = None, overwrite = False)
- start(self)
- stop(self)
Inherited from base classes
- __deepcopy__(self, memo)
- __prefix_trait__(self, name, is_set)
- __reduce_ex__(self, protocol)
- add_class_trait(cls, name, *trait)
- add_trait(self, name, *trait)
- add_trait_category(cls, category)
- add_trait_listener(self, object, prefix = '')
- all_trait_names(self)
- base_trait(self, name)
- class_default_traits_view(cls)
- class_editable_traits(cls)
- class_trait_names(cls, **metadata)
- class_trait_view(cls, name = None, view_element = None)
- class_trait_view_elements(cls)
- class_traits(cls, **metadata)
- clone_traits(self, traits = None, memo = None, copy = None, **metadata)
- configure_traits(self, filename = None, view = None, kind = None, edit = True, context = None, handler = None, id = '', scrollable = None, **args)
- copy_traits(self, other, traits = None, memo = None, copy = None, **metadata)
- copyable_trait_names(self, **metadata)
- default_traits_view(self)
- edit_traits(self, view = None, parent = None, kind = None, context = None, handler = None, id = '', scrollable = None, **args)
- editable_traits(self)
- has_traits_interface(self, *interfaces)
- on_trait_change(self, handler, name = None, remove = False, dispatch = 'same', priority = False, deferred = False)
- print_traits(self, show_help = False, **metadata)
- remove_trait(self, name)
- remove_trait_listener(self, object, prefix = '')
- reset_traits(self, traits = None, **metadata)
- set_trait_dispatch_handler(cls, name, klass, override = False)
- sync_trait(self, trait_name, object, alias = None, mutual = True, remove = False)
- trait(self, name, force = False, copy = False)
- trait_context(self)
- trait_get(self, *names, **metadata)
- trait_monitor(cls, handler, remove = False)
- trait_names(self, **metadata)
- trait_set(self, trait_change_notify = True, **traits)
- trait_setq(self, **traits)
- trait_subclasses(cls, all = False)
- trait_view(self, name = None, view_element = None)
- trait_view_elements(self)
- trait_views(self, klass = None)
- traits(self, **metadata)
- validate_trait(self, name, value)
Methods
- __getstate__(self)
Get the state of this object for pickling.
Extended to limit which attributes get pickled and also to add version numbers to our pickle.
It is STRONGLY recommended that derived classes not leverage the pickling mechanism if they wish to store additional data in OTHER files as part of their project. Instead, they should override the _save method.
Extending this method in derived classes IS appropriate if you want to store additional data in the SAME pickle file as the project.
- __setstate__(self, state)
Restore the state of this object during unpickling.
Extended to upgrade pickles to the current Project version.
It is STRONGLY recommended that derived classes not leverage the unpickling mechanism if they wish to load data from additional pickle files. Instead, they should override the _load method.
Extending this method in derived classes IS appropriate if you want to load additional data from the SAME pickle file as the project.
- __str__(self)
Return the unofficial string representation of this object.
- get_default_name(self)
Return the default name for a new project.
- get_default_path(cls, application)
Return the default path to the parent directory for a new project.
- get_default_project_location(self, application)
Return the default location for a new project.
- get_pickle_filename(cls, location)
Generate the project's pickle filename given a source location.
By default, the filename IS the specified location or, when saving projects as directories, a file called 'project' within a directory that is the specified location,
Derived classes may wish to use the location as the basis for identifying the real pickle file.
- get_pickle_package(cls)
Returns the pickle package to use for pickling and unpickling projects.
Implementors can override this to customize the way in which projects are pickled and unpickled.
This implementation returns the enthought.sweet_pickle package which supports versioning and refactoring of classes.
- load(cls, location, application)
Load a project from a specified location.
The loaded project's location is always set to the location the project was actually loaded from. Additionally, the dirty flag is cleared on the loaded project.
An exception will be raised to indicate a failure.
- register_editor(self, resource, editor, remove = False)
Inform us that an editor has been opened for what is believed to be a resource in this project.
Note that if this project can be represented as a hierarchy, the resource may not be a top level object in that hierarchy!
- save(self, location = None, overwrite = False)
Save this project.
The project is saved to its current location, identified by the value of the location trait, unless a new location is explicitly provided. The specification of a new location is used to do a 'save as' operation.
If a new location is provided, and a file or directory already exists at that location, then an AssertionError exception is raised unless the overwrite flag is True. This ensures that users won't accidentally overwrite existing data.
This method requires the overwrite flag because prompting the user to confirm the overwrite requires GUI interaction and thus should not be done at the model level.
Note that, because we can rely on the location of a loaded project always being set to the location it was loaded from, there is no reason to try to force the location trait within a saved project to the location we are trying to save to. Instead, we update the value in the in-memory version of the project only if the save completed successfully.
The dirty flag is always cleared upon a succesfull save of the project.
An exception will be raised to indicate a failure.
- start(self)
Notify this project that it is now the 'current' project.
This call should only be made by the project plugin framework!
This call could happen multiple times to a project, but only if interwoven with paired calls to the 'stop' method.
Derived classes should override this, and chain the base implementation, if they need to do anything when a project becomes current.
- stop(self)
Called only by the project plugin framework to notify this project it is no longer the current project.
This call could happen multiple times to a project, but only if interwoven with paired calls to the 'start' method.
Derived classes should override this, and chain the base implementation, if they need to do anything when a project stops being current.