Personal tools
You are here: Home Developers Corner General Examples - start and save
Document Actions

Examples - start and save

by Rasmus Fogh last modified 2007-07-06 16:34

Examples of how to start and save projects

NOTE - any changing of repositories should be done before making data, or in a separate session where you are not modifying data. Changes in repositories, repository paths etc. should affect the isModified attributes but this is not coded properly.


- All starts with :

from memops.api import Implementation as II

- New Repository with root directory urlPath:

newRepository = myProject.newRepository(name=newName, url=II.Url(path=urlPath))

- Change repository for package that starts out using the 'any' PackageLocator (normal data):

myProject.newPackageLocator(targetName='qualified.name.of.package',
               backup=myProject.findFIrstRepository(name='backup'),
               repositories=(newRepository,)
)

-  Change url path for existing repository:
  For standard file repositories everything but the urlPath has the default value, so you can do

myRepository.url = II.Url(path=urlPath).

In more complicated cases you would need to clone and modify the Url. For now you can hack it, but a cone() function for DataObjTypes is on the TODO list

- Change repository lookup path for package that already has individual PackageLocator.

myPackageLocator = myProject.findFirstPackageLocator(targetName=qualified.name.of.package')
myPackageLocator.repositories = aList

aList contains the repositories to be searched, in order, when looking for extents of the package. If you are changing to a single new repository, you should have

aList = [newRepository]

If you want a new local repository as the first location to look (and the location of newly created extents), do

aList = (newRepository,) + myPackageLocator.repositories

- Setting the guid for a newly created TopObject:

Simply pass the guid in as an input parameter. If there is already a TopObject with that guid you would get an error, therefore you would have to remove the old one first.

An (untested) alternative:

Save the old object to newRepository (which precedes previousRepository in the search path).

delete all children of the topObject.

modify the contents of the topObject as desired, possibly using the override attribute of MemopsRoot

Use the TopObject as the nucleus to create the new extent


Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: