MongoEngine/mongoengine — pull request #164 by helduel (2012-11-08 16:00:16+00:00)
Title: IP fields

Hello,

I added the following IP handling fields:
* IPv4Field
* IPv4NetworkField
* IPv6Field
* IPv6NetworkField

These fields are searchable and you can even search for IP fields that are part of specified networks. And search for networks that contain a specific IP address. This works for both, IPv4 and v6.

The trick I did: Networks are stored as mere dicts containing the net prefix and its lowest and highest IP address as either int (v4) or hex strings (v6). This allows to search whether an IP is in the range the network.

As user you are just confronted with IP objects (from IPy). The IP handling is done transparently.

IP fields are searchable with the standard lt, lte, gt, gte, ne and the in/nin operators. in/nin ist used to search for IPs that are/aren't contained within the given net.

IP network fields are searchable with lt, lte, gt, gte, ne and contains. contains is used to search for networks containing a given IP.

What do you think. Would this be a usable feature for you?

Greetings,
Manuel