Exemplo n.º 1
0
    def setUp(self):
        sandbox_path = os.path.join(os.path.dirname(__file__),
                                    '../data/sandbox.xml')
        locator_path = os.path.join(os.path.dirname(__file__),
                                    '../data/locator.xml')

        self.x = load_from_file(sandbox_path)
        self.y = load_from_file(locator_path)
    def setUp(self):
        collection_path = os.path.join(os.path.dirname(__file__),
                                       '../data/sandbox_collection.json')
        document_path = os.path.join(os.path.dirname(__file__),
                                     '../data/sandbox_document.json')

        self.x = load_from_file(collection_path)
        self.y = load_from_file(document_path)
Exemplo n.º 3
0
    def __init__(self, configuration_location, **settings):
        BaseApplication.__init__(self, **settings)

        self._config_main_path = os.path.join(self._base_path, configuration_location)
        self._config_base_path = os.path.dirname(self._config_main_path)

        self._config = load_from_file(self._config_main_path)

        # Initialize the routing map
        self._routing_map = RoutingMap()

        # Default properties
        self._scope = settings['scope'] if 'scope' in settings else None
        self._port  = 8000

        # Register the default services.
        self._register_default_services()

        # Add the main configuration to the watch list.
        watch(self._config_main_path)

        # Configure the included files first.
        for inclusion in self._config.children('include'):
            source_location = inclusion.attribute('src')

            if source_location[0] != '/':
                source_location = os.path.join(self._config_base_path, source_location)

            pre_config = load_from_file(source_location)

            self._configure(pre_config, source_location)

            watch(source_location)

            self._logger.info('Included the configuration from %s' % source_location)

        self._configure(self._config)

        # Override the properties with the parameters.
        if 'port' in settings:
            self._port = settings['port']
            self._logger.info('Changed the listening port: %s' % self._port)

        # Update the routing map
        AppServices.get('routing_map').update(self._routing_map)

        # Normal procedure
        self._update_routes(self._routing_map.export())
        self.listen(self._port)
        self._activate()
Exemplo n.º 4
0
    def parse(self, filepath : str):
        root_node     = load_from_file(filepath)
        container_map = {}

        for container_node in root_node.children():
            meta_container = convert_container_node_to_meta_container(container_node)

            container_map[meta_container.id] = meta_container

        return container_map
Exemplo n.º 5
0
    def parse(self, filepath: str):
        root_node = load_from_file(filepath)
        container_map = {}

        for container_node in root_node.children():
            meta_container = convert_container_node_to_meta_container(
                container_node)

            container_map[meta_container.id] = meta_container

        return container_map
Exemplo n.º 6
0
    def _load_inclusion(self, inclusion):
        source_location = inclusion.attribute('src')

        if source_location[0] != '/':
            source_location = os.path.join(self._config_base_path, source_location)

        pre_config = load_from_file(source_location)

        self._configure(pre_config, source_location)

        watch(source_location)

        self._logger.info('Included the configuration from %s' % source_location)
Exemplo n.º 7
0
    def __init__(self, configuration_location, **settings):
        BaseApplication.__init__(self, **settings)

        self._service_assembler = ImaginationAssembler(ImaginationTransformer(AppServices))
        self._config_main_path = os.path.join(self._base_path, configuration_location)
        self._config_base_path = os.path.dirname(self._config_main_path)

        self._config = load_from_file(self._config_main_path)

        # Initialize the routing map
        self._routing_map = RoutingMap()

        # Default properties
        self._scope = settings['scope'] if 'scope' in settings else None
        self._port  = 8000

        # Register the default services.
        self._register_default_services()

        # Add the main configuration to the watch list.
        watch(self._config_main_path)

        # Configure with the configuration files
        self._service_assembler.activate_passive_loading()

        for inclusion in self._config.children('include'):
            self._load_inclusion(inclusion)

        self._configure(self._config)

        self._prepare_db_connections()
        self._prepare_session_manager()

        self._service_assembler.deactivate_passive_loading()

        # Override the properties with the parameters.
        if 'port' in settings:
            self._port = settings['port']
            self._logger.info('Changed the listening port: %s' % self._port)

        # Update the routing map
        AppServices.get('routing_map').update(self._routing_map)

        # Normal procedure
        self._update_routes(self._routing_map.export())
        self.listen(self._port)
        self._activate()
Exemplo n.º 8
0
 def load(self, initial_directory_data_location):
     xml = load_from_file(initial_directory_data_location)
     
     queued_entities = self.get_groups(xml).values() + self.get_users(xml).values()
     
     entities = []
     
     for queued_entity in queued_entities:
         registered_entity = self.get_by_alias(queued_entity.__class__, queued_entity.alias)
         
         if registered_entity: return
         
         entities.append(queued_entity)
     
     self.db.post(*entities)
     
     return entities
Exemplo n.º 9
0
    def load(self, filepath):
        """
        Load the configuration.

        :param str filepath: the file path to the configuration.
        """
        xml = load_from_file(filepath)

        # First, register proxies to entities (for lazy initialization).
        for node in xml.children():
            self.__validate_node(node)
            self.__register_proxy(node)

        # Then, register loaders for entities.
        for node in xml.children():
            self.__get_interceptions(node)
            self.__register_entity(node)

        self.__activate_interceptions()
    def setUp(self):
        sandbox_path = os.path.join(os.path.dirname(__file__), "../data/sandbox.xml")
        locator_path = os.path.join(os.path.dirname(__file__), "../data/locator.xml")

        self.x = load_from_file(sandbox_path)
        self.y = load_from_file(locator_path)
 def setUp(self):
     file_path = os.path.join(os.path.dirname(__file__),
                              '../data/sandbox.xml')
     self.x = load_from_file(file_path)
Exemplo n.º 12
0
import xml.dom

for const in dir(xml.dom.Node):
    if '__' in const: continue
    key = 'xml.dom.Node.%s' % const
    print '%2d => %s' % (eval(key), key)

from kotoba import misc, load_from_file

misc.debug_mode = True
kotoba = load_from_file('sandbox_data.xml')
nodes = kotoba.find('created_at')

for node in nodes:
    node.dump('RESULT / A', True, True)
    print node.data()
    print

nodes = kotoba.children('status')

for node in nodes:
    node.dump('RESULT / B', True, True)
    print
Exemplo n.º 13
0
import xml.dom

for const in dir(xml.dom.Node):
    if '__' in const: continue
    key = 'xml.dom.Node.%s' % const
    print '%2d => %s' % (eval(key), key)

from kotoba import misc, load_from_file

misc.debug_mode = True
kotoba = load_from_file('sandbox_data.xml')
nodes  = kotoba.find('created_at')

for node in nodes:
    node.dump('RESULT / A', True, True)
    print node.data()
    print

nodes  = kotoba.children('status')

for node in nodes:
    node.dump('RESULT / B', True, True)
    print
 def setUp(self):
     file_path = os.path.join(os.path.dirname(__file__), '../data/sandbox.xml')
     self.x    = load_from_file(file_path)
 def setUp(self):
     self.x = load_from_file('data/sandbox.xml')
     self.y = load_from_file('data/locator.xml')
Exemplo n.º 16
0
 def setUp(self):
     self.x = load_from_file('data/sandbox.xml')
    def setUp(self):
        collection_path = os.path.join(os.path.dirname(__file__), "../data/sandbox_collection.json")
        document_path = os.path.join(os.path.dirname(__file__), "../data/sandbox_document.json")

        self.x = load_from_file(collection_path)
        self.y = load_from_file(document_path)