Oh!  I've seen this before!

In the pure python implementation of the qmf console (see qpid/extras/qmf/ ... 
/console.py), there's some "syntactic sugar" that allows the application to 
fetch a QMF object when given a attribute of an Object Id is surrounded by 
"_"'s!

Specifically, for:

q._altExchange_.name,

The "q" object is an instance of a broker Queue object as defined by QMF.  This 
object has an attribute called "altExchange", which happens to be the Object 
Identifier that references the alternate exchange configured for the queue.

The syntax:  q._altExchange_ actually means 
"getObjects(_objectId=q.altExchange)[0]".  - which returns the QMF object for 
the alternate exchange.  The name of the exchange is then returned.

Take a look at the function console.py::Object::__getattr_ - see the comment 
"Dereference references".

Not very intuitive, IMHO.....


-K

----- Original Message -----
> Any takers on this? Is there some python guru out there who can
> explain what
> this is doing.
> 
> I can't even get sensible answers Googling - imagine what "python
> underscore" returns :-/
> 
> MTIA
> Frase
> 
> 
> 
> fadams wrote:
> >
> > Hello,
> > In qpid-config there's code to print the name of the alternate
> > exchange
> > for queues or exchanges.
> >
> > For queues it's
> >
> > if q.altExchange:
> >                     print "--alternate-exchange=%s" %
> > q._altExchange_.name,
> >
> > I'm not familiar with python so the "_altExchange_" is very cryptic
> > to me
> > the "q.altExchange" just checks for the presence of the altExchange
> > property.
> >
> > The altExchange property is an objId that references an exchange to
> > I'd
> > have assumed code like
> >
> > exchanges = self.qmf.getObjects(_class="exchange",
> > _agent=self.brokerAgent)
> > ex = self.findById (exchanges, q.altExchange)
> > altename = ex.name
> >
> > would have been needed to find the name of the alternate exchange
> >
> > Could someone please tell me what's going on?
> >
> > Thanks
> > Fraser
> >
> 
> 
> --
> View this message in context:
> http://apache-qpid-users.2158936.n2.nabble.com/qpid-config-what-does-q-altExchange-name-do-tp6591980p6603419.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:[email protected]

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to