Your IP : 216.73.216.213
B
�d{TM � @ s` d Z dZddlmZmZ ddlZdadd� Zdd� Zd d
� Z dd� Z
d
d� Zdd� Zdd� Z
dS )z<A set of utility function to ease the use of OmniORBpy.
zrestructuredtext en� )�CORBA�PortableServerNc C s$ t dkr ddl} t�| jtj�a t S )z�
returns a reference to the ORB.
The first call to the method initialized the ORB
This method is mainly used internally in the module.
Nr )�orb�sysr ZORB_init�argvZORB_ID)r � r �J/opt/alt/python37/lib/python3.7/site-packages/logilab/common/corbautils.py�get_orb s r c C s0 t � } | �d�}|�tj�}|dk s,td��|S )zq
returns a reference to the NameService object.
This method is mainly used internally in the module.
ZNameServiceNz$Failed to narrow root naming context)r �resolve_initial_references�_narrow� CosNaming�
NamingContext�AssertionError)r ZnssZrootContextr r r �get_root_context, s
r c C s� t � }x~|dd� D ]n\}}t�||�g}y|�|�}W q tjjk
r� } z&|�|��tj�}|dk sptd��W dd}~X Y qX qW |d \}}t�||�g}y|� || �
� � W n6 tjjk
r� } z|�|| �
� � W dd}~X Y nX dS )a
Registers a object in the NamingService.
The name path is a list of 2-uples (id,kind) giving the path.
For instance if the path of an object is [('foo',''),('bar','')],
it is possible to get a reference to the object using the URL
'corbaname::hostname#foo/bar'.
[('logilab','rootmodule'),('chatbot','application'),('chatter','server')]
is mapped to
'corbaname::hostname#logilab.rootmodule/chatbot.application/chatter.server'
The get_object_reference() function can be used to resolve such a URL.
N���z.test context exists but is not a NamingContext)r r Z
NameComponentZbind_new_contextr
ZAlreadyBound�resolver r �bindZ_thisZrebind)�object�namepath�context�id�kind�name�exr r r �register_object_name8 s
r c C s$ t � } | �d�}|�� }|�� dS )z�
This methods activates the Portable Object Adapter.
You need to call it to enable the reception of messages in your code,
on both the client and the server.
ZRootPOAN)r r
Z_get_the_POAManager�activate)r ZpoaZ
poaManagerr r r �activate_POAW s
r c C s t � �� dS )zc
Enters the ORB mainloop on the server.
You should not call this method on the client.
N)r �runr r r r �run_orbb s r c C s t � �| �S )zg
Resolves a corbaname URL to an object proxy.
See register_object_name() for examples URLs
)r Zstring_to_object)�urlr r r �get_object_referencei s r c C s d� dd� |D ��}d| |f S )zrgiven an host name and a name path as described in register_object_name,
return a corba string identifier
�/c S s g | ]}d � |��qS )�.)�join)�.0Zpath_eltr r r �
<listcomp>t s z%get_object_string.<locals>.<listcomp>zcorbaname::%s#%s)r# )�hostr Zstrnamer r r �get_object_stringp s r'