From 514df1f6480019dd6d4070a981b04c56a7920b05 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 13 Aug 2014 02:33:04 +0100 Subject: actually register the login servlet (uncommitted code thinko?) --- synapse/rest/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'synapse/rest') diff --git a/synapse/rest/__init__.py b/synapse/rest/__init__.py index 5598295793..3d4dd098d6 100644 --- a/synapse/rest/__init__.py +++ b/synapse/rest/__init__.py @@ -14,7 +14,7 @@ # limitations under the License. from . import ( - room, events, register, profile, public, presence, im, directory + room, events, register, login, profile, public, presence, im, directory ) class RestServletFactory(object): @@ -35,10 +35,9 @@ class RestServletFactory(object): room.register_servlets(hs, http_server) events.register_servlets(hs, http_server) register.register_servlets(hs, http_server) + login.register_servlets(hs, http_server) profile.register_servlets(hs, http_server) public.register_servlets(hs, http_server) presence.register_servlets(hs, http_server) im.register_servlets(hs, http_server) directory.register_servlets(hs, http_server) - - -- cgit 1.4.1 From f98e6380f15c68a052e7ccb03b123b6eb91474ea Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 13 Aug 2014 03:14:34 +0100 Subject: add in whitespace after copyright statements to improve legibility --- synapse/__init__.py | 1 + synapse/api/__init__.py | 1 + synapse/api/auth.py | 1 + synapse/api/constants.py | 1 + synapse/api/errors.py | 1 + synapse/api/events/__init__.py | 1 + synapse/api/events/factory.py | 1 + synapse/api/events/room.py | 1 + synapse/api/notifier.py | 1 + synapse/api/streams/__init__.py | 1 + synapse/api/streams/event.py | 1 + synapse/app/__init__.py | 1 + synapse/app/homeserver.py | 2 +- synapse/crypto/__init__.py | 1 + synapse/crypto/config.py | 1 + synapse/crypto/keyclient.py | 1 + synapse/crypto/keyserver.py | 1 + synapse/crypto/resource/__init__.py | 1 + synapse/crypto/resource/key.py | 1 + synapse/federation/__init__.py | 1 + synapse/federation/handler.py | 1 + synapse/federation/pdu_codec.py | 1 + synapse/federation/persistence.py | 1 + synapse/federation/replication.py | 1 + synapse/federation/transport.py | 1 + synapse/federation/units.py | 1 + synapse/handlers/__init__.py | 1 + synapse/handlers/_base.py | 1 + synapse/handlers/directory.py | 1 + synapse/handlers/events.py | 1 + synapse/handlers/federation.py | 1 + synapse/handlers/login.py | 1 + synapse/handlers/presence.py | 1 + synapse/handlers/profile.py | 1 + synapse/handlers/register.py | 1 + synapse/handlers/room.py | 1 + synapse/http/__init__.py | 1 + synapse/http/client.py | 1 + synapse/http/endpoint.py | 1 + synapse/http/server.py | 1 + synapse/rest/__init__.py | 1 + synapse/rest/base.py | 1 + synapse/rest/directory.py | 1 + synapse/rest/events.py | 1 + synapse/rest/im.py | 1 + synapse/rest/login.py | 1 + synapse/rest/presence.py | 1 + synapse/rest/profile.py | 1 + synapse/rest/public.py | 1 + synapse/rest/register.py | 1 + synapse/rest/room.py | 1 + synapse/server.py | 1 + synapse/state.py | 1 + synapse/storage/__init__.py | 1 + synapse/storage/_base.py | 1 + synapse/storage/directory.py | 1 + synapse/storage/feedback.py | 1 + synapse/storage/message.py | 1 + synapse/storage/pdu.py | 1 + synapse/storage/presence.py | 1 + synapse/storage/profile.py | 1 + synapse/storage/registration.py | 1 + synapse/storage/room.py | 1 + synapse/storage/roomdata.py | 1 + synapse/storage/roommember.py | 1 + synapse/storage/stream.py | 1 + synapse/storage/transactions.py | 1 + synapse/types.py | 1 + synapse/util/__init__.py | 1 + synapse/util/async.py | 1 + synapse/util/distributor.py | 1 + synapse/util/jsonobject.py | 1 + synapse/util/lockutils.py | 1 + synapse/util/logutils.py | 1 + synapse/util/stringutils.py | 1 + tests/test_distributor.py | 1 + 76 files changed, 76 insertions(+), 1 deletion(-) (limited to 'synapse/rest') diff --git a/synapse/__init__.py b/synapse/__init__.py index aa760fb341..1e7b2ab272 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -12,5 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This is a reference implementation of a synapse home server. """ diff --git a/synapse/api/__init__.py b/synapse/api/__init__.py index fe8a073cd3..2216c0f1ca 100644 --- a/synapse/api/__init__.py +++ b/synapse/api/__init__.py @@ -12,3 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 5c66a7261f..84bc0398fd 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This module contains classes for authenticating the user.""" from twisted.internet import defer diff --git a/synapse/api/constants.py b/synapse/api/constants.py index 37bf41bfb3..29687c3482 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Contains constants from the specification.""" diff --git a/synapse/api/errors.py b/synapse/api/errors.py index 7ad4d636c2..8b9766fab7 100644 --- a/synapse/api/errors.py +++ b/synapse/api/errors.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Contains exceptions and error codes.""" import logging diff --git a/synapse/api/events/__init__.py b/synapse/api/events/__init__.py index bc2daf3361..921fd08832 100644 --- a/synapse/api/events/__init__.py +++ b/synapse/api/events/__init__.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.errors import SynapseError, Codes from synapse.util.jsonobject import JsonEncodedObject diff --git a/synapse/api/events/factory.py b/synapse/api/events/factory.py index ea7afa234e..12aa04fc6e 100644 --- a/synapse/api/events/factory.py +++ b/synapse/api/events/factory.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.events.room import ( RoomTopicEvent, MessageEvent, RoomMemberEvent, FeedbackEvent, InviteJoinEvent, RoomConfigEvent diff --git a/synapse/api/events/room.py b/synapse/api/events/room.py index b31cd19f4b..f3df849af2 100644 --- a/synapse/api/events/room.py +++ b/synapse/api/events/room.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from . import SynapseEvent diff --git a/synapse/api/notifier.py b/synapse/api/notifier.py index 974f7f0ba0..22d2914d38 100644 --- a/synapse/api/notifier.py +++ b/synapse/api/notifier.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.constants import Membership from synapse.api.events.room import RoomMemberEvent diff --git a/synapse/api/streams/__init__.py b/synapse/api/streams/__init__.py index 08137c1e79..989e63f9ec 100644 --- a/synapse/api/streams/__init__.py +++ b/synapse/api/streams/__init__.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.errors import SynapseError diff --git a/synapse/api/streams/event.py b/synapse/api/streams/event.py index 0cc1a3e36a..4b6d739e54 100644 --- a/synapse/api/streams/event.py +++ b/synapse/api/streams/event.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This module contains classes for streaming from the event stream: /events. """ from twisted.internet import defer diff --git a/synapse/app/__init__.py b/synapse/app/__init__.py index fe8a073cd3..2216c0f1ca 100644 --- a/synapse/app/__init__.py +++ b/synapse/app/__init__.py @@ -12,3 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 5708b3ad95..9ad8ac7f0e 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2014 matrix.org # @@ -12,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#!/usr/bin/env python from synapse.storage import read_schema diff --git a/synapse/crypto/__init__.py b/synapse/crypto/__init__.py index fe8a073cd3..2216c0f1ca 100644 --- a/synapse/crypto/__init__.py +++ b/synapse/crypto/__init__.py @@ -12,3 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/synapse/crypto/config.py b/synapse/crypto/config.py index 801dfd8656..2330133e71 100644 --- a/synapse/crypto/config.py +++ b/synapse/crypto/config.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + import ConfigParser as configparser import argparse import socket diff --git a/synapse/crypto/keyclient.py b/synapse/crypto/keyclient.py index b53d1c572b..e615866b68 100644 --- a/synapse/crypto/keyclient.py +++ b/synapse/crypto/keyclient.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.web.http import HTTPClient from twisted.internet import defer, reactor from twisted.internet.protocol import ClientFactory diff --git a/synapse/crypto/keyserver.py b/synapse/crypto/keyserver.py index 48bd380781..3d80a0e660 100644 --- a/synapse/crypto/keyserver.py +++ b/synapse/crypto/keyserver.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import reactor, ssl from twisted.web import server from twisted.web.resource import Resource diff --git a/synapse/crypto/resource/__init__.py b/synapse/crypto/resource/__init__.py index fe8a073cd3..2216c0f1ca 100644 --- a/synapse/crypto/resource/__init__.py +++ b/synapse/crypto/resource/__init__.py @@ -12,3 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/synapse/crypto/resource/key.py b/synapse/crypto/resource/key.py index 6ce6e0b034..6aecd2b95f 100644 --- a/synapse/crypto/resource/key.py +++ b/synapse/crypto/resource/key.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.web.resource import Resource from twisted.web.server import NOT_DONE_YET from twisted.internet import defer diff --git a/synapse/federation/__init__.py b/synapse/federation/__init__.py index b4d95ed5ac..ac0c10dc33 100644 --- a/synapse/federation/__init__.py +++ b/synapse/federation/__init__.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This package includes all the federation specific logic. """ diff --git a/synapse/federation/handler.py b/synapse/federation/handler.py index 31e8470b33..d361f0aaf7 100644 --- a/synapse/federation/handler.py +++ b/synapse/federation/handler.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from .pdu_codec import PduCodec diff --git a/synapse/federation/pdu_codec.py b/synapse/federation/pdu_codec.py index 9155930e47..adc166c564 100644 --- a/synapse/federation/pdu_codec.py +++ b/synapse/federation/pdu_codec.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from .units import Pdu import copy diff --git a/synapse/federation/persistence.py b/synapse/federation/persistence.py index ad4111c683..372245712a 100644 --- a/synapse/federation/persistence.py +++ b/synapse/federation/persistence.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This module contains all the persistence actions done by the federation package. diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py index 0f5b974291..bea5335f89 100644 --- a/synapse/federation/replication.py +++ b/synapse/federation/replication.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This layer is responsible for replicating with remote home servers using a given transport. """ diff --git a/synapse/federation/transport.py b/synapse/federation/transport.py index 2136adf8d7..09a5e5901a 100644 --- a/synapse/federation/transport.py +++ b/synapse/federation/transport.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """The transport layer is responsible for both sending transactions to remote home servers and receiving a variety of requests from other home servers. diff --git a/synapse/federation/units.py b/synapse/federation/units.py index 0efea7b768..2b2f11f36a 100644 --- a/synapse/federation/units.py +++ b/synapse/federation/units.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ Defines the JSON structure of the protocol units used by the server to server protocol. """ diff --git a/synapse/handlers/__init__.py b/synapse/handlers/__init__.py index 5688b68e49..8a4aa6e5d6 100644 --- a/synapse/handlers/__init__.py +++ b/synapse/handlers/__init__.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from .register import RegistrationHandler from .room import ( MessageHandler, RoomCreationHandler, RoomMemberHandler, RoomListHandler diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index 87a392dd77..c2f4685c92 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -14,6 +14,7 @@ # limitations under the License. + class BaseHandler(object): def __init__(self, hs): diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py index 456007c71d..3cc6348906 100644 --- a/synapse/handlers/directory.py +++ b/synapse/handlers/directory.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from ._base import BaseHandler diff --git a/synapse/handlers/events.py b/synapse/handlers/events.py index 79742a4e1c..3af7d824a2 100644 --- a/synapse/handlers/events.py +++ b/synapse/handlers/events.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from ._base import BaseHandler diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 12e7afca4c..7026df90a2 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Contains handlers for federation events.""" from ._base import BaseHandler diff --git a/synapse/handlers/login.py b/synapse/handlers/login.py index 5a1acd7102..ca69829d77 100644 --- a/synapse/handlers/login.py +++ b/synapse/handlers/login.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from ._base import BaseHandler diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 38db4b1d67..1c24efd454 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.api.errors import SynapseError, AuthError diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index a27206b002..976b8cfcdc 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.api.errors import SynapseError, AuthError diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 246c1f6530..593c603346 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Contains functions for registering clients.""" from twisted.internet import defer diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 4d82b33993..eae40765b3 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Contains functions for performing events on rooms.""" from twisted.internet import defer diff --git a/synapse/http/__init__.py b/synapse/http/__init__.py index fe8a073cd3..2216c0f1ca 100644 --- a/synapse/http/__init__.py +++ b/synapse/http/__init__.py @@ -12,3 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + diff --git a/synapse/http/client.py b/synapse/http/client.py index bb22b0ee9a..d0facbdc6c 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer, reactor from twisted.web.client import _AgentBase, _URI, readBody from twisted.web.http_headers import Headers diff --git a/synapse/http/endpoint.py b/synapse/http/endpoint.py index c4e6e63a80..d91500b07d 100644 --- a/synapse/http/endpoint.py +++ b/synapse/http/endpoint.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet.endpoints import SSL4ClientEndpoint, TCP4ClientEndpoint from twisted.internet import defer from twisted.internet.error import ConnectError diff --git a/synapse/http/server.py b/synapse/http/server.py index 9fb45971d5..d7f4b691bc 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from syutil.jsonutil import ( encode_canonical_json, encode_pretty_printed_json ) diff --git a/synapse/rest/__init__.py b/synapse/rest/__init__.py index 3d4dd098d6..b7f0c1fd2e 100644 --- a/synapse/rest/__init__.py +++ b/synapse/rest/__init__.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from . import ( room, events, register, login, profile, public, presence, im, directory ) diff --git a/synapse/rest/base.py b/synapse/rest/base.py index d90ac611fe..2f1ab57c73 100644 --- a/synapse/rest/base.py +++ b/synapse/rest/base.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This module contains base REST classes for constructing REST servlets. """ import re diff --git a/synapse/rest/directory.py b/synapse/rest/directory.py index a426003a38..31fd26e848 100644 --- a/synapse/rest/directory.py +++ b/synapse/rest/directory.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.types import RoomAlias, RoomID diff --git a/synapse/rest/events.py b/synapse/rest/events.py index 147257a940..dc811b813a 100644 --- a/synapse/rest/events.py +++ b/synapse/rest/events.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This module contains REST servlets to do with event streaming, /events.""" from twisted.internet import defer diff --git a/synapse/rest/im.py b/synapse/rest/im.py index 39f2dbd749..63a77716a0 100644 --- a/synapse/rest/im.py +++ b/synapse/rest/im.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.api.streams import PaginationConfig diff --git a/synapse/rest/login.py b/synapse/rest/login.py index 0284e125b4..88a3218332 100644 --- a/synapse/rest/login.py +++ b/synapse/rest/login.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.api.errors import SynapseError diff --git a/synapse/rest/presence.py b/synapse/rest/presence.py index e4925c20a5..6043848595 100644 --- a/synapse/rest/presence.py +++ b/synapse/rest/presence.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This module contains REST servlets to do with presence: /presence/ """ from twisted.internet import defer diff --git a/synapse/rest/profile.py b/synapse/rest/profile.py index f384227c29..3d0427bf72 100644 --- a/synapse/rest/profile.py +++ b/synapse/rest/profile.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This module contains REST servlets to do with profile: /profile/ """ from twisted.internet import defer diff --git a/synapse/rest/public.py b/synapse/rest/public.py index 6fd1731a61..3430c8049f 100644 --- a/synapse/rest/public.py +++ b/synapse/rest/public.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This module contains REST servlets to do with public paths: /public""" from twisted.internet import defer diff --git a/synapse/rest/register.py b/synapse/rest/register.py index f1cbce5c67..eb457562b9 100644 --- a/synapse/rest/register.py +++ b/synapse/rest/register.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """This module contains REST servlets to do with registration: /register""" from twisted.internet import defer diff --git a/synapse/rest/room.py b/synapse/rest/room.py index c96de5e65d..228bc9623d 100644 --- a/synapse/rest/room.py +++ b/synapse/rest/room.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """ This module contains REST servlets to do with rooms: /rooms/ """ from twisted.internet import defer diff --git a/synapse/server.py b/synapse/server.py index 0aff75f399..4ba203ac38 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + # This file provides some classes for setting up (partially-populated) # homeservers; either as a full homeserver as a real application, or a small # partial one for unit test mocking. diff --git a/synapse/state.py b/synapse/state.py index 439c0b519a..b081de8f4f 100644 --- a/synapse/state.py +++ b/synapse/state.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.federation.pdu_codec import encode_event_id diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index ec93f9f8a7..3c27428c08 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.events.room import ( RoomMemberEvent, MessageEvent, RoomTopicEvent, FeedbackEvent, RoomConfigEvent diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 4d98a6fd0d..65f691ead4 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import logging from twisted.internet import defer diff --git a/synapse/storage/directory.py b/synapse/storage/directory.py index 71fa9d9c9c..b22ce02f3f 100644 --- a/synapse/storage/directory.py +++ b/synapse/storage/directory.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore from twisted.internet import defer diff --git a/synapse/storage/feedback.py b/synapse/storage/feedback.py index 2b421e3342..9bd562c762 100644 --- a/synapse/storage/feedback.py +++ b/synapse/storage/feedback.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore, Table from synapse.api.events.room import FeedbackEvent diff --git a/synapse/storage/message.py b/synapse/storage/message.py index 4822fa709d..7bb69c1384 100644 --- a/synapse/storage/message.py +++ b/synapse/storage/message.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore, Table from synapse.api.events.room import MessageEvent diff --git a/synapse/storage/pdu.py b/synapse/storage/pdu.py index a1cdde0a3b..202d7f6cb6 100644 --- a/synapse/storage/pdu.py +++ b/synapse/storage/pdu.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore, Table, JoinHelper from synapse.util.logutils import log_function diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py index e57ddaf149..6f5b042c25 100644 --- a/synapse/storage/presence.py +++ b/synapse/storage/presence.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index d2f24930c1..91dd565033 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index 4a970dd546..68cdfbb4ca 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from sqlite3 import IntegrityError diff --git a/synapse/storage/room.py b/synapse/storage/room.py index 174cbcf3d8..09d9c2339b 100644 --- a/synapse/storage/room.py +++ b/synapse/storage/room.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from sqlite3 import IntegrityError diff --git a/synapse/storage/roomdata.py b/synapse/storage/roomdata.py index 781d477931..cc04d1ba14 100644 --- a/synapse/storage/roomdata.py +++ b/synapse/storage/roomdata.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore, Table import collections diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index e6e7617797..ef73be4af4 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer from synapse.types import UserID diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index c3b1bfeb32..1dedffac49 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore from .message import MessagesTable from .feedback import FeedbackTable diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index aa41e2ad7f..a277e4971a 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from ._base import SQLBaseStore, Table from .pdu import PdusTable diff --git a/synapse/types.py b/synapse/types.py index 1adc95bbb0..054b1e713c 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from synapse.api.errors import SynapseError from collections import namedtuple diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py index 5361cb7ec2..3ea431a7f9 100644 --- a/synapse/util/__init__.py +++ b/synapse/util/__init__.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import reactor import time diff --git a/synapse/util/async.py b/synapse/util/async.py index e04db8e285..ebbdc00ae1 100644 --- a/synapse/util/async.py +++ b/synapse/util/async.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer, reactor diff --git a/synapse/util/distributor.py b/synapse/util/distributor.py index 32d19402b4..9605d7d1b9 100644 --- a/synapse/util/distributor.py +++ b/synapse/util/distributor.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer import logging diff --git a/synapse/util/jsonobject.py b/synapse/util/jsonobject.py index 190a80a322..e2840b59f9 100644 --- a/synapse/util/jsonobject.py +++ b/synapse/util/jsonobject.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + import copy class JsonEncodedObject(object): diff --git a/synapse/util/lockutils.py b/synapse/util/lockutils.py index e4d609d84e..758be0b901 100644 --- a/synapse/util/lockutils.py +++ b/synapse/util/lockutils.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from twisted.internet import defer import logging diff --git a/synapse/util/logutils.py b/synapse/util/logutils.py index 08d5aafca4..9270a1790b 100644 --- a/synapse/util/logutils.py +++ b/synapse/util/logutils.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + from inspect import getcallargs import logging diff --git a/synapse/util/stringutils.py b/synapse/util/stringutils.py index 91550583a4..e1b0796e56 100644 --- a/synapse/util/stringutils.py +++ b/synapse/util/stringutils.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import random import string diff --git a/tests/test_distributor.py b/tests/test_distributor.py index 36cbf6c52d..db23f16673 100644 --- a/tests/test_distributor.py +++ b/tests/test_distributor.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import unittest from twisted.internet import defer -- cgit 1.4.1 From 7f40fa1d4601960e8c1ea39af26a3e7515ff0f3e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 13 Aug 2014 13:50:01 +0100 Subject: Added a -w flag which will host the web client if specified. Currently this just delegates to the webclient RestServlet. --- synapse/app/homeserver.py | 4 +++- synapse/rest/__init__.py | 8 +++++++- synapse/rest/base.py | 42 ------------------------------------------ synapse/rest/webclient.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ synapse/server.py | 14 ++++++++++---- 5 files changed, 65 insertions(+), 48 deletions(-) create mode 100644 synapse/rest/webclient.py (limited to 'synapse/rest') diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 9ad8ac7f0e..dcf0b5f287 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -126,6 +126,8 @@ def setup(): parser.add_argument('--pid-file', dest="pid", help="When running as a " "daemon, the file to store the pid in", default="hs.pid") + parser.add_argument("-w", "--webclient", dest="webclient", + action="store_true", help="Host the web client.") args = parser.parse_args() verbosity = int(args.verbose) if args.verbose else None @@ -147,7 +149,7 @@ def setup(): # the replication layer hs.get_federation() - hs.register_servlets() + hs.register_servlets(host_web_client=args.webclient) hs.get_http_server().start_listening(args.port) diff --git a/synapse/rest/__init__.py b/synapse/rest/__init__.py index b7f0c1fd2e..74a372e2ff 100644 --- a/synapse/rest/__init__.py +++ b/synapse/rest/__init__.py @@ -15,9 +15,11 @@ from . import ( - room, events, register, login, profile, public, presence, im, directory + room, events, register, login, profile, public, presence, im, directory, + webclient ) + class RestServletFactory(object): """ A factory for creating REST servlets. @@ -42,3 +44,7 @@ class RestServletFactory(object): presence.register_servlets(hs, http_server) im.register_servlets(hs, http_server) directory.register_servlets(hs, http_server) + + def register_web_client(self, hs): + http_server = hs.get_http_server() + webclient.register_servlets(hs, http_server) diff --git a/synapse/rest/base.py b/synapse/rest/base.py index 2f1ab57c73..65d417f757 100644 --- a/synapse/rest/base.py +++ b/synapse/rest/base.py @@ -30,48 +30,6 @@ def client_path_pattern(path_regex): return re.compile("^/matrix/client/api/v1" + path_regex) -class RestServletFactory(object): - - """ A factory for creating REST servlets. - - These REST servlets represent the entire client-server REST API. Generally - speaking, they serve as wrappers around events and the handlers that - process them. - - See synapse.api.events for information on synapse events. - """ - - def __init__(self, hs): - http_server = hs.get_http_server() - - # You get import errors if you try to import before the classes in this - # file are defined, hence importing here instead. - - import room - room.register_servlets(hs, http_server) - - import events - events.register_servlets(hs, http_server) - - import register - register.register_servlets(hs, http_server) - - import profile - profile.register_servlets(hs, http_server) - - import public - public.register_servlets(hs, http_server) - - import presence - presence.register_servlets(hs, http_server) - - import im - im.register_servlets(hs, http_server) - - import login - login.register_servlets(hs, http_server) - - class RestServlet(object): """ A Synapse REST Servlet. diff --git a/synapse/rest/webclient.py b/synapse/rest/webclient.py new file mode 100644 index 0000000000..75a425c14c --- /dev/null +++ b/synapse/rest/webclient.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2014 matrix.org +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from synapse.rest.base import RestServlet + +import logging +import re + +logger = logging.getLogger(__name__) + + +class WebClientRestServlet(RestServlet): + # No PATTERN; we have custom dispatch rules here + + def register(self, http_server): + http_server.register_path("GET", + re.compile("^/$"), + self.on_GET_redirect) + http_server.register_path("GET", + re.compile("^/matrix/client$"), + self.on_GET) + + def on_GET(self, request): + return (200, "not implemented") + + def on_GET_redirect(self, request): + request.setHeader("Location", request.uri + "matrix/client") + return (302, None) + + +def register_servlets(hs, http_server): + logger.info("Registering web client.") + WebClientRestServlet(hs).register(http_server) \ No newline at end of file diff --git a/synapse/server.py b/synapse/server.py index 4ba203ac38..ba9022f323 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -171,7 +171,13 @@ class HomeServer(BaseHomeServer): def build_distributor(self): return Distributor() - def register_servlets(self): - """Simply building the ServletFactory is sufficient to have it - register.""" - self.get_rest_servlet_factory() + def register_servlets(self, host_web_client): + """ Register all servlets associated with this HomeServer. + + Args: + host_web_client (bool): True to host the web client as well. + """ + # Simply building the ServletFactory is sufficient to have it register + factory = self.get_rest_servlet_factory() + if host_web_client: + factory.register_web_client(self) -- cgit 1.4.1