Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Private Member Functions | Private Attributes
asyncconn.Connection Class Reference
Inheritance diagram for asyncconn.Connection:
Inheritance graph
[legend]
Collaboration diagram for asyncconn.Connection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__
def destroy
def set_auth_info
def current_operation

Private Member Functions

def _make_binding
def _call_function
def _subst_reply_handler
def _subst_error_handler
def _subst_auth_handler

Private Attributes

 _destroyed
 _conn
 _bindings
 _methodcalls

Detailed Description

Definition at line 108 of file asyncconn.py.


Constructor & Destructor Documentation

def asyncconn.Connection.__init__ (   self,
  reply_handler = None,
  error_handler = None,
  auth_handler = None,
  host = None,
  port = None,
  encryption = None,
  parent = None,
  try_as_root = True,
  prompt_allowed = True 
)

Definition at line 111 of file asyncconn.py.

00111 
00112                   parent=None, try_as_root=True, prompt_allowed=True):
00113         super (Connection, self).__init__ ()
00114 
00115         self._destroyed = False
00116 
00117         # Decide whether to use direct IPP or PolicyKit.
00118         if host == None:
00119             host = cups.getServer()
00120         use_pk = ((host.startswith ('/') or host == 'localhost') and
00121                   os.getuid () != 0)
00122 
00123         def subst_reply_handler (conn, reply):
00124             self._subst_reply_handler (None, reply_handler, reply)
00125 
00126         def subst_error_handler (conn, exc):
00127             self._subst_error_handler (None, error_handler, exc)
00128 
00129         def subst_auth_handler (prompt, conn, method, resource):
00130             self._subst_auth_handler (None, auth_handler, prompt, method, resource)
00131 
00132         if use_pk and try_as_root:
00133             debugprint ("Using polkit-1 connection class")
00134             c = asyncpk1.PK1Connection (reply_handler=subst_reply_handler,
00135                                         error_handler=subst_error_handler,
00136                                         host=host, port=port,
00137                                         encryption=encryption,
00138                                         parent=parent)
00139             self._conn = c
00140         else:
00141             debugprint ("Using IPP connection class")
00142             c = asyncipp.IPPAuthConnection (reply_handler=subst_reply_handler,
00143                                             error_handler=subst_error_handler,
00144                                             auth_handler=subst_auth_handler,
00145                                             host=host, port=port,
00146                                             encryption=encryption,
00147                                             parent=parent,
00148                                             try_as_root=try_as_root,
00149                                             prompt_allowed=prompt_allowed,
00150                                             semantic=self)
00151             self._conn = c
00152 
00153         methodtype = type (self._conn.getPrinters)
00154         instancemethodtype = type (self._conn.getDevices)
00155         bindings = []
00156         for fname in dir (self._conn):
00157             if fname.startswith ('_'):
00158                 continue
00159             fn = getattr (self._conn, fname)
00160             if type (fn) != methodtype and type (fn) != instancemethodtype:
00161                 continue
00162             if not hasattr (self, fname):
00163                 setattr (self, fname, self._make_binding (fn))
00164                 bindings.append (fname)
00165 
00166         self._bindings = bindings
00167         self._methodcalls = []
00168         debugprint ("+%s" % self)

Definition at line 169 of file asyncconn.py.

00169 
00170     def __del__ (self):
00171         debug.debugprint ("-%s" % self)


Member Function Documentation

def asyncconn.Connection._call_function (   self,
  fn,
  args,
  kwds 
) [private]

Definition at line 189 of file asyncconn.py.

00189 
00190     def _call_function (self, fn, *args, **kwds):
00191         methodcall = _AsyncMethodCall (fn,
00192                                        self._subst_reply_handler,
00193                                        self._subst_error_handler,
00194                                        self._subst_auth_handler)
00195         self._methodcalls.append (methodcall)
00196         methodcall.run (*args, **kwds)

Here is the call graph for this function:

Here is the caller graph for this function:

def asyncconn.Connection._make_binding (   self,
  fn 
) [private]

Definition at line 186 of file asyncconn.py.

00186 
00187     def _make_binding (self, fn):
00188         return lambda *args, **kwds: self._call_function (fn, *args, **kwds)

Here is the call graph for this function:

def asyncconn.Connection._subst_auth_handler (   self,
  methodcall,
  auth_handler,
  prompt,
  method,
  resource 
) [private]

Definition at line 215 of file asyncconn.py.

00215 
00216     def _subst_auth_handler (self, methodcall, auth_handler, prompt, method, resource):
00217         if methodcall:
00218             methodcall.destroy ()
00219             i = self._methodcalls.index (methodcall)
00220             del self._methodcalls[i]
00221         if auth_handler and not self._destroyed:
00222             auth_handler (prompt, self, method, resource)

Here is the caller graph for this function:

def asyncconn.Connection._subst_error_handler (   self,
  methodcall,
  error_handler,
  args 
) [private]

Definition at line 206 of file asyncconn.py.

00206 
00207     def _subst_error_handler (self, methodcall, error_handler, *args):
00208         if methodcall:
00209             methodcall.destroy ()
00210             i = self._methodcalls.index (methodcall)
00211             del self._methodcalls[i]
00212             args = args[1:]
00213         if error_handler and not self._destroyed:
00214             error_handler (self, *args)

Here is the caller graph for this function:

def asyncconn.Connection._subst_reply_handler (   self,
  methodcall,
  reply_handler,
  args 
) [private]

Definition at line 197 of file asyncconn.py.

00197 
00198     def _subst_reply_handler (self, methodcall, reply_handler, *args):
00199         if methodcall:
00200             methodcall.destroy ()
00201             i = self._methodcalls.index (methodcall)
00202             del self._methodcalls[i]
00203             args = args[1:]
00204         if reply_handler and not self._destroyed:
00205             reply_handler (self, *args)

Here is the caller graph for this function:

Definition at line 47 of file asyncconn.py.

00047 
00048     def current_operation (self):
00049         try:
00050             return self._operation_stack[0]
00051         except IndexError:
00052             return None

Definition at line 172 of file asyncconn.py.

00172 
00173     def destroy (self):
00174         debugprint ("DESTROY: %s" % self)
00175         self._destroyed = True
00176         try:
00177             self._conn.destroy ()
00178         except AttributeError:
00179             pass
00180 
00181         for methodcall in self._methodcalls:
00182             methodcall.destroy ()
00183 
00184         for binding in self._bindings:
00185             delattr (self, binding)

Here is the caller graph for this function:

def asyncconn.Connection.set_auth_info (   self,
  password 
)
Call this from your auth_handler function.

Definition at line 223 of file asyncconn.py.

00223 
00224     def set_auth_info (self, password):
00225         """Call this from your auth_handler function."""
00226         self.thread.set_auth_info (password)


Member Data Documentation

Definition at line 165 of file asyncconn.py.

Definition at line 138 of file asyncconn.py.

Definition at line 114 of file asyncconn.py.

Definition at line 166 of file asyncconn.py.


The documentation for this class was generated from the following file: