from autobahn_sync import AutobahnSync, DEFAULT_AUTOBAHN_ROUTER, DEFAULT_AUTOBAHN_REALM


class FlaskAutobahnSync(object):

    def __init__(self, app=None, **config):
        self.config = {
            'router': DEFAULT_AUTOBAHN_ROUTER,
            'realm': DEFAULT_AUTOBAHN_REALM,
            'in_twisted': False
        }
        self.app = app
        self.autobahn_sync = AutobahnSync()
        if app is not None:
            self.init_app(app, **config)

    def init_app(self, app, router=None, realm=None, in_twisted=None):
        router = router or app.config.get('AUTHOBAHN_ROUTER')
        realm = realm or app.config.get('AUTHOBAHN_REALM')
        in_twisted = in_twisted or app.config.get('AUTHOBAHN_IN_TWISTED')
        if router:
            self.config['router'] = router
        if realm:
            self.config['realm'] = realm
        if in_twisted:
            self.config['in_twisted'] = in_twisted
        self.autobahn_sync.start(url=self.config['router'],
                                 realm=self.config['realm'],
                                 in_twisted=self.config['in_twisted'])

    def __getattr__(self, name):
        if name in ('publish', 'call', 'register', 'subscribe'):
            return getattr(self.autobahn_sync, name)
        else:
            super(FlaskAutobahnSync, self).__getattr__(self, name)

@@ -111,16 +111,293 @@
 ync(
-object):
+AutobahnSync):%0A%0A    %22%22%22Inherit from :class:%60autobahn_sync.AutobahnSync%60 to integrate it with Flask.%0A%0A    :param app: Flask app to configure, if provided :meth:%60init_app%60 is automatically called%0A    :param config: remaining kwargs will be passed to %60%60init_app%60%60 as configuration%0A    %22%22%22
 %0A%0A  
@@ -623,52 +623,8 @@
 app%0A
-        self.autobahn_sync = AutobahnSync()%0A
     
@@ -756,24 +756,429 @@
 sted=None):%0A
+        %22%22%22Configure and call the :meth:%60AutobahnSync.start%60 method%0A%0A        :param app: Flask app to configure%0A        :param router: WAMP router to connect to%0A        :param realm: WAMP realm to connect to%0A        :param in_twisted: Is the code is going to run inside a Twisted application%0A%0A        .. Note:: The config provided as argument will overwrite the one privided by %60%60app.config%60%60%0A        %22%22%22%0A
         rout
@@ -1568,30 +1568,16 @@
    self.
-autobahn_sync.
 start(ur
@@ -1620,30 +1620,16 @@
         
-             
- 
 realm=se
@@ -1644,38 +1644,24 @@
 g%5B'realm'%5D,%0A
-              
             
@@ -1709,237 +1709,4 @@
 '%5D)%0A
-%0A    def __getattr__(self, name):%0A        if name in ('publish', 'call', 'register', 'subscribe'):%0A            return getattr(self.autobahn_sync, name)%0A        else:%0A            super(FlaskAutobahnSync, self).__getattr__(self, name)%0A

Simplify flask extension and add doc