Skip to content

Commit 97bd46b

Browse files
committed
Major update
1 parent 8db7a84 commit 97bd46b

18 files changed

Lines changed: 82 additions & 296 deletions

File tree

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
mailman-api
3+
-----------
4+
5+
RESTful API to access some funcionalities of Mailman 2

Vagrantfile

Lines changed: 0 additions & 122 deletions
This file was deleted.

mailmanapi/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
2-
from api import *

mailmanapi/api.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import os
33
import uuid
44

5-
from bottle import route, request, template
5+
from bottle import route, request, template, default_app
66
from Mailman import Utils, Errors, Post, mm_cfg
77

8-
from members import Member
9-
from utils import parse_boolean, jsonify, get_mailinglist, get_timestamp
8+
from .members import Member
9+
from .utils import parse_boolean, jsonify, get_mailinglist, get_timestamp
1010

1111

1212
CWD = os.path.abspath(os.path.dirname(__file__))
@@ -108,3 +108,15 @@ def sendmail(listname):
108108
Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR)
109109
return jsonify(True)
110110

111+
112+
def get_application(allowed_ips):
113+
bottle_app = default_app()
114+
def application(environ, start_response):
115+
if environ['REMOTE_ADDR'] not in allowed_ips:
116+
status = '403 FORBIDDEN'
117+
headers = [('Content-type', 'text/plain')]
118+
start_response(status, headers)
119+
return 'FORBIDDEN'
120+
121+
return bottle_app(environ, start_response)
122+
return application

mailmanapi/settings.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

mailmanapi/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import simplejson
2+
import json
33

44
from time import strftime
55
from bottle import HTTPResponse
@@ -15,7 +15,7 @@ def parse_boolean(value):
1515

1616
def jsonify(body='', status=200):
1717
response = HTTPResponse(content_type='application/json')
18-
response.body = simplejson.dumps(body)
18+
response.body = json.dumps(body)
1919
response.status = status
2020
return response
2121

puppet/bootstrap.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

puppet/hiera.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

puppet/hieradata/common.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

puppet/manifests/init.pp

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)