Example #1
0
    def checkin(my, tactic_node, search_key, context):
        '''Standard checkin mechanism.  This is a sample checkin mechanism
        that is full featured enough to handle many situations.

        @params:
          tactic_node: the tactic node to be checkedin
          search_key: the search key to check into
          context: the context to check into

        @return
          snapshot: a dictionary representing the final snapshot
          
        
        '''
        server = TacticServerStub.get()

        # verify that this is not a reference!!!


        # create a snapshot
        snapshot = server.create_snapshot(search_key, context)

        # find all of the dependencies
        dependent_nodes = my.get_dependent_nodes(tactic_node)
        for node in dependent_nodes:
            # find out if there is a node there is a file associated with
            # this tactic node
            files = my.get_dependent_references(node)
            print files


        # update the tactic node with the latest snapshot data.  Also, update
        # the tactic node name as it likely has changed
        node_data = my.set_introspect_data(tactic_node, snapshot)
        tactic_node = node_data.get_app_node_name()


        # add the files to the snapshot
        handler = BaseFileExtractionHandler(tactic_node)
        paths = handler.execute()
        #paths = my.extract_to_files(top_node)
        for path in paths:
            print "path: ", path
            server.add_file(snapshot.get("code"), path, mode='upload')

        return snapshot
Example #2
0
    def load(my,
             search_key,
             context,
             version=-1,
             file_type='main',
             mode='reference',
             namespace=''):
        '''Generic loading function used by TACTIC interface by default

        @params:
        search_key: the search key of the sobject to be loaded
        context: the context of the snapshot to be loaded
        version: the version of the snapshot to be loaded
        file_type: the specific file in the snapshot to be loaded

        mode: reference|import|open: the mode in which to bring the file in
        
        
        '''
        server = TacticServerStub.get()

        # FIXME: do we really need to make 2 calls?
        snapshot = server.get_snapshot(search_key,
                                       context=context,
                                       version=version)
        if not snapshot:
            raise CGAppException("No snapshot found for [%s]" % search_key)

        paths = server.get_paths(search_key, context, version, file_type)
        web_paths = paths.get("web_paths")

        for path in web_paths:
            to_path = my.download(path)
            my.load_file(to_path, namespace=namespace, mode=mode)

        # FIXME: if the instance already exists, it will be auto renmaed by
        # the application ... this gets tricky to discover
        snapshot_code = snapshot.get('code')
        if namespace:
            tactic_node = "%s:tactic_%s" % (namespace, snapshot_code)
        else:
            tactic_node = "tactic_%s" % snapshot_code
        return tactic_node
Example #3
0
    def checkin(my, tactic_node, search_key, context):
        '''Standard checkin mechanism.  This is a sample checkin mechanism
        that is full featured enough to handle many situations.

        @params:
          tactic_node: the tactic node to be checkedin
          search_key: the search key to check into
          context: the context to check into

        @return
          snapshot: a dictionary representing the final snapshot
          
        
        '''
        server = TacticServerStub.get()

        # verify that this is not a reference!!!

        # create a snapshot
        snapshot = server.create_snapshot(search_key, context)

        # find all of the dependencies
        dependent_nodes = my.get_dependent_nodes(tactic_node)
        for node in dependent_nodes:
            # find out if there is a node there is a file associated with
            # this tactic node
            files = my.get_dependent_references(node)
            print files

        # update the tactic node with the latest snapshot data.  Also, update
        # the tactic node name as it likely has changed
        node_data = my.set_introspect_data(tactic_node, snapshot)
        tactic_node = node_data.get_app_node_name()

        # add the files to the snapshot
        handler = BaseFileExtractionHandler(tactic_node)
        paths = handler.execute()
        #paths = my.extract_to_files(top_node)
        for path in paths:
            print "path: ", path
            server.add_file(snapshot.get("code"), path, mode='upload')

        return snapshot
Example #4
0
    def load(my, search_key, context, version=-1, file_type='main', mode='reference',namespace=''):
        '''Generic loading function used by TACTIC interface by default

        @params:
        search_key: the search key of the sobject to be loaded
        context: the context of the snapshot to be loaded
        version: the version of the snapshot to be loaded
        file_type: the specific file in the snapshot to be loaded

        mode: reference|import|open: the mode in which to bring the file in
        
        
        '''
        server = TacticServerStub.get()

        # FIXME: do we really need to make 2 calls?
        snapshot = server.get_snapshot(search_key, context=context, version=version)
        if not snapshot:
            raise CGAppException("No snapshot found for [%s]" % search_key)


        paths = server.get_paths(search_key, context, version, file_type)
        web_paths = paths.get("web_paths")

        for path in web_paths:
            to_path = my.download(path)
            my.load_file(to_path, namespace=namespace, mode=mode)


        # FIXME: if the instance already exists, it will be auto renmaed by
        # the application ... this gets tricky to discover
        snapshot_code = snapshot.get('code')
        if namespace:
            tactic_node = "%s:tactic_%s" % (namespace, snapshot_code)
        else:
            tactic_node = "tactic_%s" % snapshot_code
        return tactic_node