def __init__(self, host, port, database, user, passwd, name=None, obj_id=None, obj_type=None, connection_id=None, version_node=None, version_tag=None): print "here", host, port, database, user, passwd, name, obj_id, obj_type,connection_id, version_node, version_tag _DBLocator.__init__(self, host, port, database, user, passwd, name, obj_id, obj_type, connection_id, version_node, version_tag)
def __init__(self, host, port, database, user, passwd, name=None, **kwargs): _DBLocator.__init__(self, host, port, database, user, passwd, name, **kwargs) self.ext_connection_id = -1
def save_as(self, save_bundle, version=None): save_bundle = _DBLocator.save(self, save_bundle, True, version) for obj in save_bundle.get_db_objs(): klass = self.get_convert_klass(obj.vtType) klass.convert(obj) obj.locator = self # Need to copy images into thumbnail cache directory so references # won't become invalid if they are in a temp dir that gets destroyed # when the previous locator is closed import shutil thumb_cache = ThumbnailCache.getInstance() thumb_cache_dir = thumb_cache.get_directory() new_thumbnails = [] for thumbnail in save_bundle.thumbnails: if os.path.dirname(thumbnail) == thumb_cache_dir: new_thumbnails.append(thumbnail) else: cachedir_thumbnail = os.path.join(thumb_cache_dir, os.path.basename(thumbnail)) try: shutil.copyfile(thumbnail, cachedir_thumbnail) new_thumbnails.append(cachedir_thumbnail) except Exception, e: debug.critical('copying %s -> %s failed: %s' % \ (thumbnail, cachedir_thumbnail, str(e)))
def save(self, save_bundle): save_bundle = _DBLocator.save(self, save_bundle, False) for obj in save_bundle.get_db_objs(): klass = self.get_convert_klass(obj.vtType) klass.convert(obj) obj.locator = self return save_bundle
def load(self, klass=None): from core.vistrail.vistrail import Vistrail if klass is None: klass = Vistrail obj = _DBLocator.load(self, klass.vtType) klass.convert(obj) obj.locator = self return obj
def load(self, klass=None): from core.vistrail.vistrail import Vistrail if klass is None: klass = Vistrail save_bundle = _DBLocator.load(self, klass.vtType, ThumbnailCache.getInstance().get_directory()) for obj in save_bundle.get_db_objs(): klass = self.get_convert_klass(obj.vtType) klass.convert(obj) obj.locator = self return save_bundle
def load(self, klass=None): from core.vistrail.vistrail import Vistrail if klass is None: klass = Vistrail save_bundle = _DBLocator.load( self, klass.vtType, ThumbnailCache.getInstance().get_directory()) if klass.vtType == DBWorkflow.vtType: wf = save_bundle klass = self.get_convert_klass(wf.vtType) klass.convert(wf) wf.locator = self return wf for obj in save_bundle.get_db_objs(): klass = self.get_convert_klass(obj.vtType) klass.convert(obj) obj.locator = self return save_bundle
def from_xml(node, include_name=False): locator = _DBLocator.from_xml(node, include_name) locator.__class__ = DBLocator return locator
def save_as(self, obj): klass = obj.__class__ obj = _DBLocator.save(self, obj, True) klass.convert(obj) obj.locator = self return obj