Observable Queries
by in CodeSOD on 2022-08-31Rachel is doing some Python/Django work on an application that, among other things, handles a pile of Internet addresses, a mix of IP addresses and domain names. Since each of those has a very different query path (domains could be filtered on the TLD or the name portion of the domain, for example), Rachel implemented some helper objects built on Django observables, the IPAddressObservable
and the DomainObservable
.
This way, when someone wanted to search the database for an address, some code like this could run: