Parent: [4cc3a8] (diff)

Child: [1a62f9] (diff)

Download this file

react.py    61 lines (47 with data), 1.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import logging
from lamson.routing import route, route_like, stateless
from config.settings import relay
from lamson import view, queue
import os
import ming
import pylons
from paste.deploy import appconfig
from pyforge.config.environment import load_environment
from pyforge import model as M
from pyforge.model import Project
logging.config.fileConfig("config/react_logging.conf")
class EmptyClass(object): pass
@route("(loc)@(proj)\\.(host)", loc=".*", proj=".*")
@stateless
def REACTING(message, post_name=None, loc=None, proj=None, host=None):
conf = appconfig('config:%s' % 'development.ini',relative_to=os.getcwd())
load_environment(conf.global_conf, conf.local_conf)
pylons.c._push_object(EmptyClass())
from pyforge.lib.app_globals import Globals
pylons.g._push_object(Globals())
ming.configure(**conf)
try:
valid = Project.m.find({"name":proj, "database":"projects:"+proj}).one()
except:
try:
valid = Project.m.find({"name":proj, "database":"users:"+proj}).one()
except:
logging.debug('REACT: project "' + proj + '" does not exist as project or user')
else:
relay.deliver(message)
logging.debug('REACT: project "' + proj + '" exists as user!')
else:
relay.deliver(message)
logging.debug('REACT: project "' + proj + '" exists as project!')
# conn = BrokerConnection(hostname="localhost", port=5672,
# userid="celeryuser", password="celerypw",
# virtual_host="celeryvhost")
#
# publisher = Publisher(connection=conn,
# exchange="forge", routing_key="mail")
# publisher.send({"message": message}, serializer="pickle")
# publisher.close()
#
# #index_q = queue.Queue("run/posts")
# #index_q.push(message)
return REACTING