push_notifications:postgresql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
push_notifications:postgresql [2015/02/23 15:34] – Prova (successo) push in seguito a fire del trigger letti | push_notifications:postgresql [2015/03/03 17:33] (current) – letti | ||
---|---|---|---|
Line 70: | Line 70: | ||
< | < | ||
- | CREATE OR REPLACE FUNCTION | + | CREATE OR REPLACE FUNCTION push_notifications_login(url text, login text, password text) |
RETURNS text AS | RETURNS text AS | ||
$BODY$ | $BODY$ | ||
Line 89: | Line 89: | ||
LANGUAGE plpythonu VOLATILE | LANGUAGE plpythonu VOLATILE | ||
COST 100; | COST 100; | ||
- | ALTER FUNCTION | + | ALTER FUNCTION push_notifications_login(text, |
- | OWNER TO matteo; | + | OWNER TO postgres; |
</ | </ | ||
Line 98: | Line 98: | ||
< | < | ||
- | CREATE OR REPLACE FUNCTION | + | CREATE OR REPLACE FUNCTION push_notifications_notify(login_url text, login text, password text, push_url text, channel text, token text, payload text) |
RETURNS text AS | RETURNS text AS | ||
$BODY$ | $BODY$ | ||
Line 108: | Line 108: | ||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | ||
- | notify_values | + | login_values |
- | login_data = urllib.urlencode(notify_values) | + | login_data = urllib.urlencode(login_values) |
- | notify_resp | + | login_resp |
- | return | + | |
+ | if login_resp.getcode() == ' | ||
+ | |||
+ | notify_values = {' | ||
+ | notify_data = urllib.urlencode(notify_values) | ||
+ | |||
+ | | ||
+ | |||
+ | if notify_restp.getcode() | ||
+ | return True | ||
+ | else: | ||
+ | return False | ||
$BODY$ | $BODY$ | ||
LANGUAGE plpythonu VOLATILE | LANGUAGE plpythonu VOLATILE | ||
COST 100; | COST 100; | ||
- | ALTER FUNCTION | + | ALTER FUNCTION push_notifications_notify(text, text, text, text, text, text, text) |
- | OWNER TO matteo; | + | OWNER TO postgres; |
</ | </ | ||
Line 152: | Line 163: | ||
notify_url := ' | notify_url := ' | ||
- | | + | |
) USING login_url; | ) USING login_url; | ||
| | ||
| | ||
- | EXECUTE format(' | + | EXECUTE format(' |
- | ) USING notify_url, | + | ) USING login_url, login, password, |
| | ||
END; | END; |
push_notifications/postgresql.1424705692.txt.gz · Last modified: 2015/02/23 15:34 by letti