durusmail: qp: QP 1.7 questions.
QP 1.7 questions.
2006-08-17
2006-08-17
2006-08-18
QP 1.7 questions.
David Binger
2006-08-17
On Aug 16, 2006, at 11:30 PM, Peter Wilkinson wrote:

> Hi,
> I've noticed the new version of QP and QPY along with Durus, nice
> stuff.

That reminds me, I should send an announcement about QP and Qpy.

>
> One quick thing that I'm running into that might be an issue is the
> new get_durus_address method.
>
>     def get_durus_address(self):
>         """() -> (host:str, port:int)|str
>         The address at which the Durus StorageServer listens.
>         """
>         address = self.get('durus_address')
>         if type(address) is tuple:
>             return address
>         if bool(address):
>             return join(self.get_var_directory(),
>                 address or '%s.durus_server' % self.get_name())
>         else:
>             return None
>
> Given that, my reading is that durus_address=('localhost', 8002)
> will do the usual socket thing, and to get a unix socket I need to
> set a string value. Is the section that does "address or '%
> s.durus_server' % self.get_name()" slightly wrong as I can't see a
> way to get it to generate the name automatically?
> durus_address=True fails as True will then get passed into join
> which tries to do a .startswith() on it and durus_address=False
> stops Durus from starting at all.
>
> The logic that makes sense to me would be:
> durus_address=('localhost', 8002) -> usual
> durus_address=False (or no setting) -> off
> durus_address=True -> Unix socket, '%s.durus_server' % self.get_name()
> durus_address="string" -> Unix socket, whatever that value is.
>
> I hope I'm not missing something obvious here.

No.  You are right, this code is goofy.
I'd prefer to leave the True/False out of it.
The setting should be a string, or a tuple, and that's it.
Does this look better?

     def get_durus_address(self):
         """() -> (host:str, port:int)|str
         The address at which the Durus StorageServer listens.
         """
         address = self.get('durus_address')
         if type(address) is tuple:
             return address
         if address:
             return join(self.get_var_directory(), address)
         else:
             return None




reply