Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install repoze.what.plugins.ip

How to install repoze.what.plugins.ip

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install repoze.what.plugins.ip
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
Windows (64-bit)
0.2 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
Linux (32-bit)
0.2 Available View build log
Linux (64-bit)
0.2 Available View build log
Apache 2.0
Lastest release
version 0.2 on Jan 5th, 2011

It is a repoze.what plugin that provides an ip_from predicate.



$ <env>/bin/easy_install repoze.what.plugins.ip


$ <env>/bin/pip install repoze.what.plugins.ip


The source code can be found at code.google.com.


ip_from([allowed=None], [proxies=None]) checks whether REMOTE_ADDR in the environment points to an allowed IP address. If HTTP_X_FORWARDED_FOR is set in the environment (meaning proxy access) then REMOTE_ADDR is treated as a proxy address and HTTP_X_FORWARDED_FOR as an originating IP address.

allowed optional, default - None
A list of IPs to allow access. Can be a string which is then interpreted as a single IP address
proxies optional, default - None

If a list or tuple provided then treated as a list of authorized proxy IP addresses.

If a string or unicode provided then treated as a single IP address.

Any other value - bool(proxies) == True means that all proxies are accepted

You can filter the incoming IP address:

>>> from repoze.what.plugins.ip import ip_from
>>> p = ip_from(allowed=[''])
>>> env = {'REMOTE_ADDR': ''}
>>> p.is_met(env)
>>> env = {'REMOTE_ADDR': ''}
>>> p.is_met(env)

By default proxy access is disabled. You can enable it with proxies=True:

>>> p = ip_from(allowed=[''], proxies=True)
>>> env = {
...     'REMOTE_ADDR': '',           # proxy
...     'HTTP_X_FORWARDED_FOR': ''   # origin
... }
>>> p.is_met(env)

And you can also explicitly specify proxies to allow:

>>> p = ip_from(allowed='', proxies=[''])
>>> env = {
...     'REMOTE_ADDR': '',           # proxy
...     'HTTP_X_FORWARDED_FOR': ''   # origin
... }
>>> p.is_met(env)

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.