Skip to content

Commit

Permalink
example tac is now the tac you should use; updated
Browse files Browse the repository at this point in the history
 * updated conf
 * updated pyapns.tac
  • Loading branch information
Samuel Sutch committed Jan 25, 2013
1 parent a7bdc7a commit aff1106
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 68 deletions.
35 changes: 3 additions & 32 deletions example_conf.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
{
"port": 7077,
"rest_port": 8088,
"autoprovision": [
{
"app_id": "sandbox:com.ficture.ficturebeta",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta.pem",
"app_id": "com.example.myapp",
"cert": "/path/to/cert.pem",
"environment": "sandbox",
"timeout": 15
},

This comment has been minimized.

Copy link
@troppoli

troppoli Jan 28, 2013

This trailing comma is tripping up the json parser for me

This comment has been minimized.

Copy link
@samuraisam

samuraisam Jan 30, 2013

Owner

Thanks for the note, I can fix it.

{
"app_id": "production:com.ficture.ficturebeta",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta.pem",
"environment": "production",
"timeout": 15
},
{
"app_id": "sandbox:com.ficture.ficturebeta2",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta2.pem",
"environment": "sandbox",
"timeout": 15
},
{
"app_id": "production:com.ficture.ficturebeta2",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta2.pem",
"environment": "production",
"timeout": 15
},
{
"app_id": "sandbox:com.ficture.ficturebeta3",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta3.pem",
"environment": "sandbox",
"timeout": 15
},
{
"app_id": "production:com.ficture.ficturebeta3",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta3.pem",
"environment": "production",
"timeout": 15
}
]
}
36 changes: 0 additions & 36 deletions example_tac.tac

This file was deleted.

62 changes: 62 additions & 0 deletions pyapns.tac
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# CONFIG FILE LOCATION
# relative to this file or absolute path

config_file = '/path/to/config/pyapns_conf.json'

# you don't need to change anything below this line really

import twisted.application, twisted.web, twisted.application.internet
import pyapns.server, pyapns._json
import pyapns.rest_service, pyapns.model
import os

config = {}

if os.path.exists(os.path.abspath(config_file)):
with open(os.path.abspath(config_file)) as f:
config.update(pyapns._json.loads(f.read()))
else:
print 'No config file loaded. Alter the `config_file` variable at', \
'the top of this file to set one.'

xml_service = pyapns.server.APNSServer()

# get automatic provisioning
if 'autoprovision' in config:
for app in config['autoprovision']:
# for XML-RPC
xml_service.xmlrpc_provision(app['app_id'], app['cert'],
app['environment'], app['timeout'])
# for REST
pyapns.model.AppRegistry.put(
app['app_id'], app['environment'], app['cert'],
timeout=app['timeout']
)

application = twisted.application.service.Application("pyapns application")

# XML-RPC server support ------------------------------------------------------

if 'port' in config:
port = config['port']
else:
port = 7077

resource = twisted.web.resource.Resource()
resource.putChild('', xml_service)

site = twisted.web.server.Site(resource)

server = twisted.application.internet.TCPServer(port, site)
server.setServiceParent(application)

# rest service support --------------------------------------------------------
if 'rest_port' in config:
rest_port = config['rest_port']
else:
rest_port = 8088

site = twisted.web.server.Site(pyapns.rest_service.default_resource)

server = twisted.application.internet.TCPServer(rest_port, site)
server.setServiceParent(application)

0 comments on commit aff1106

Please sign in to comment.