[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Defaulting Query's fall_back_to_authority to False



commit cf0a4b2f7cff17ff6f819c91e35b2a86ffcb6a81
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Aug 4 11:21:22 2013 -0700

    Defaulting Query's fall_back_to_authority to False
    
    When a user opts to use the Query class direcly they're doing so to use
    specific endpoints. We'll probably cause more confusion then help by falling
    back to the authorities here. We'll still fall back by default in the
    downloader, though.
    
    This also includes a tweak so users can override the downloader's endpoints.
---
 stem/descriptor/remote.py |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 8b6497f..698e141 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -218,7 +218,7 @@ class Query(object):
   :param bool start: start making the request when constructed (default is **True**)
   """
 
-  def __init__(self, resource, descriptor_type = None, endpoints = None, retries = 2, fall_back_to_authority = True, timeout = None, start = True, validate = True, document_handler = stem.descriptor.DocumentHandler.ENTRIES):
+  def __init__(self, resource, descriptor_type = None, endpoints = None, retries = 2, fall_back_to_authority = False, timeout = None, start = True, validate = True, document_handler = stem.descriptor.DocumentHandler.ENTRIES):
     if not resource.startswith('/'):
       raise ValueError("Resources should start with a '/': %s" % resource)
 
@@ -581,8 +581,13 @@ class DescriptorDownloader(object):
     args = dict(self._default_args)
     args.update(query_args)
 
+    if not 'endpoints' in args:
+      args['endpoints'] = self._endpoints
+
+    if not 'fall_back_to_authority' in args:
+      args['fall_back_to_authority'] = True
+
     return Query(
       resource,
-      endpoints = self._endpoints,
       **args
     )



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits