Skip to content

Commit 3c57b89

Browse files
committed
Big restructuring, creation of Context object with attributes and methods
1 parent 8492a16 commit 3c57b89

File tree

8 files changed

+531
-75
lines changed

8 files changed

+531
-75
lines changed

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Built and tested against Python 2.7. You will need to install
1010
the Python headers and libraries - this is usually a package
1111
called "python-dev"
1212

13-
Currently building against the getdns "develop" branch (to be released
14-
as 0.1.1). getdns external dependencies include:
13+
Currently building against the getdns 0.1.3 release.
14+
getdns external dependencies include:
1515

1616
* [libldns from NLnet Labs](https://www.nlnetlabs.nl/projects/ldns/) version 1.6.11 or later (ldns requires ope
1717
nssl headers and libraries)
@@ -21,6 +21,9 @@ nssl headers and libraries)
2121
* [libevent](http://libevent.org) version 2.0.21 stable, sometimes called libevent2 (only needed if you plan to
2222
use it for asynchronous handling)
2323

24+
Note that getdns **MUST** be built with the --with-libevent flag to
25+
configure.
26+
2427
Building
2528
========
2629
To build,
@@ -51,19 +54,24 @@ Documentation
5154
5255
Documentation is formatted using the [sphinx](http://sphinx-doc.org/)
5356
documentation system. The html-formatted output is under the pygetdns
54-
source tree in doc/_build/html.
57+
source tree in doc/_build/html. It is also available online at [readthedogs.org]
58+
(https://getdns.readthedocs.org/)
59+
60+
Changes from the earlier release
61+
================================
5562
56-
Known issues
57-
============
63+
We've introduced a Context object with attributes and methods, with
64+
queries being Context methods. Attributes can be assigned and read
65+
directly without using the getdns setters and getters. For example,
5866
59-
There are several issues in this alpha release which we expect to be resolved
60-
prior to the TNW hack battle. These include:
67+
```python
68+
import getdns.context
69+
my_context = getdns.Context()
70+
my_context.timeout = 1000
71+
print my_context.timeout
72+
```
6173
62-
* the asynchronous code is not actually asynchronous; it invokes the
63-
callback but the calling function blocks until the callback returns
64-
* getdns exception error strings are not "bubbling up" to the user
65-
from deeply nested functions. You may see an exception thrown with
66-
a warning that the error string is not set as a result
74+
Please see the documentation for details on attributes and methods.
6775
6876
Examples
6977
========

examples/example_address.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def main():
77
print "Usage: {0} hostname".format(sys.argv[0])
88
sys.exit(1)
99

10-
ctx = getdns.context_create()
10+
ctx = getdns.Context()
1111
extensions = { "return_both_v4_and_v6" : getdns.GETDNS_EXTENSION_TRUE }
12-
results = getdns.address(ctx, name=sys.argv[1], extensions=extensions)
12+
results = ctx.address(name=sys.argv[1], extensions=extensions)
1313
if results["status"] == getdns.GETDNS_RESPSTATUS_GOOD:
1414
sys.stdout.write("Addresses: ")
1515

examples/example_dnssec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def main():
2121
print "Usage: {0} hostname".format(sys.argv[0])
2222
sys.exit(1)
2323

24-
ctx = getdns.context_create()
24+
ctx = getdns.Context()
2525
extensions = { "return_both_v4_and_v6" : getdns.GETDNS_EXTENSION_TRUE,
2626
"dnssec_return_status" : getdns.GETDNS_EXTENSION_TRUE }
27-
results = getdns.address(ctx, name=sys.argv[1], extensions=extensions)
27+
results = ctx.address(name=sys.argv[1], extensions=extensions)
2828
if results["status"] == getdns.GETDNS_RESPSTATUS_GOOD:
2929
sys.stdout.write("Addresses: ")
3030
for addr in results["just_address_answers"]:

examples/example_hostname.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
print "Usage: {0} ipaddress".format(sys.argv[0])
1010
sys.exit(1)
1111

12-
ctx = getdns.context_create()
12+
ctx = getdns.Context()
1313
addr["address_data"] = sys.argv[1]
1414
if string.find(sys.argv[1], ":") != -1:
1515
addr["address_type"] = "IPv6"
@@ -18,7 +18,7 @@ def main():
1818
else:
1919
print "{0}: undiscernable address type".format(sys.argv[1])
2020
sys.exit(1)
21-
results = getdns.hostname(ctx, address=addr)
21+
results = ctx.hostname(address=addr)
2222
if results["status"] == getdns.GETDNS_RESPSTATUS_GOOD:
2323
print "Hostnames:"
2424
for responses in results["replies_tree"]:

0 commit comments

Comments
 (0)