Logo Search packages:      
Sourcecode: r-cran-nws version File versions  Download package

def nwsclient::NwsServer::openWs (   self,
  wsName,
  space = None,
  opt 
)
Open a workspace.

s.openWs(wsName[, space]) -> space

If called without a space argument, this method will construct a
NetWorkSpace object that will be associated with this NwsServer
object, and then perform an open operation with it against the NWS
server.  The open operation tells the NWS server that this
client wants to use that workspace, and is willing to take
ownership of it, if it doesn't already exist.

The space argument is only intended to be used from the
NetWorkSpace constructor.

The return value is the constructed NetWorkSpace object.

Arguments:

wsName -- Name of the workspace to open.  If the space argument
is not None, this value must match the space's name.

space -- NetWorkSpace object to use for the open operation.
If the value is None, then openWs will construct a
NetWorkSpace object, specifying this NwsServer object as
the space's server.  Note that this argument is only
intended to be used from the NetWorkSpace constructor.
The default value is None.

Keyword Arguments:

persistent -- Boolean value indicating whether the workspace
should be persistent or not.  See the description of the
persistent argument in the __init__ method of the
NetWorkSpace class for more information.

create -- Boolean value indicating whether the workspace should
be created if it doesn't already exist.  The default
value is true.

Examples:

    Let's create an NwsServer, and then use openWs to create an
    NetWorkSpace object for a workspace called 'foo':

>>> from nws.client import NwsServer
>>> server = NwsServer()
>>> workspace = server.openWs('foo')

    Note that this is (nearly) equivalent to:

>>> from nws.client import NetWorkSpace
>>> workspace = NetWorkSpace('foo')

Definition at line 313 of file nwsclient.py.

                                               :
        """Open a workspace.

        s.openWs(wsName[, space]) -> space

        If called without a space argument, this method will construct a
        NetWorkSpace object that will be associated with this NwsServer
        object, and then perform an open operation with it against the NWS
        server.  The open operation tells the NWS server that this
        client wants to use that workspace, and is willing to take
        ownership of it, if it doesn't already exist.

        The space argument is only intended to be used from the
        NetWorkSpace constructor.

        The return value is the constructed NetWorkSpace object.

        Arguments:

        wsName -- Name of the workspace to open.  If the space argument
                is not None, this value must match the space's name.

        space -- NetWorkSpace object to use for the open operation.
                If the value is None, then openWs will construct a
                NetWorkSpace object, specifying this NwsServer object as
                the space's server.  Note that this argument is only
                intended to be used from the NetWorkSpace constructor.
                The default value is None.

        Keyword Arguments:

        persistent -- Boolean value indicating whether the workspace
                should be persistent or not.  See the description of the
                persistent argument in the __init__ method of the
                NetWorkSpace class for more information.

        create -- Boolean value indicating whether the workspace should
                be created if it doesn't already exist.  The default
                value is true.

        Examples:

            Let's create an NwsServer, and then use openWs to create an
            NetWorkSpace object for a workspace called 'foo':

                >>> from nws.client import NwsServer
                >>> server = NwsServer()
                >>> workspace = server.openWs('foo')

            Note that this is (nearly) equivalent to:

                >>> from nws.client import NetWorkSpace
                >>> workspace = NetWorkSpace('foo')

        """
        if type(wsName) != str:
            raise TypeError, 'workspace name must be a string'

        # if invoked directly by user, we need to create a space
        # instance. if invoked via NetWorkSpace constructor, use the
        # space passed in.
        if not space:
            space = NetWorkSpace(wsName, server=self)
        elif space.currentWs() != wsName:
            raise ValueError, 'name of the specified workspace is incorrect'

        op = 'open ws'
        owner = '%d' % os.getpid()

        p = 'no'
        if opt.get('persistent', False): p = 'yes'

        if opt.get('create', True):
            self._sendAll('0004%020d%s%020d%s%020d%s%020d%s' % \
                    (len(op), op, len(wsName), wsName, len(owner), owner,
                        len(p), p))
        else:
            create = 'no'
            self._sendAll('0005%020d%s%020d%s%020d%s%020d%s%020d%s' % \
                    (len(op), op, len(wsName), wsName, len(owner), owner,
                        len(p), p, len(create), create))

        status = int(self._recvN(4))
        if status: raise NwsNoWorkSpaceException, "workspace %s doesn't exist" % repr(wsName)
        return space


Generated by  Doxygen 1.6.0   Back to index