예제 #1
0
파일: __init__.py 프로젝트: oodavy41/isso
    def __init__(self, conf):

        self.conf = conf
        self.db = db.SQLite3(conf.get('general', 'dbpath'), conf)
        self.signer = URLSafeTimedSerializer(
            self.db.preferences.get("session-key"))
        self.markup = html.Markup(conf.section('markup'))
        self.hasher = hash.new(conf.section("hash"))
        self.author = self.hasher.uhash(conf.get('general', 'author'))

        super(Isso, self).__init__(conf)

        subscribers = []
        for backend in conf.getlist("general", "notify"):
            if backend == "stdout":
                subscribers.append(Stdout(None))
            elif backend in ("smtp", "SMTP"):
                subscribers.append(SMTP(self))
            else:
                logger.warn("unknown notification backend '%s'", backend)

        self.signal = ext.Signal(*subscribers)

        self.urls = Map()

        views.Info(self)
        comments.API(self, self.hasher)
예제 #2
0
파일: test_html.py 프로젝트: vsajip/isso
    def test_sanitized_render_extensions(self):
        """Options should be normalized from both dashed-case or snake_case (legacy)"""
        conf = config.new({
            "markup": {
                "options": "no_intra_emphasis",  # Deliberately snake_case
                "flags": "",
                "allowed-elements": "",
                "allowed-attributes": ""
            }
        })
        renderer = html.Markup(conf.section("markup")).render
        self.assertEqual(renderer("foo_bar_baz"), '<p>foo_bar_baz</p>')

        conf.set("markup", "options", "no-intra-emphasis")  # dashed-case
        renderer = html.Markup(conf.section("markup")).render
        self.assertEqual(renderer("foo_bar_baz"), '<p>foo_bar_baz</p>')
예제 #3
0
파일: test_html.py 프로젝트: triosky/isso
 def test_render(self):
     conf = Config.load(None).section("markup")
     renderer = html.Markup(conf).render
     self.assertEqual(
         renderer("http://example.org/ and sms:+1234567890"),
         '<p><a href="http://example.org/">http://example.org/</a> and sms:+1234567890</p>'
     )
예제 #4
0
    def __init__(self, conf):

        self.conf = conf
        db_type = conf.get('general', 'db-type')
        if db_type == 'sqlite':
            self.db = db.SQLite3(conf.get('general', 'dbpath'), conf)
        elif db_type == 'psql':
            self.db = db_psql.PSQL(conf.get('general', 'dbpath'), conf)
        self.signer = URLSafeTimedSerializer(
            self.db.preferences.get("session-key"))
        self.markup = html.Markup(conf.section('markup'))
        self.hasher = hash.new(conf.section("hash"))

        super(Isso, self).__init__(conf)

        subscribers = []
        smtp_backend = False
        for backend in conf.getlist("general", "notify"):
            if backend == "stdout":
                subscribers.append(Stdout(None))
            elif backend in ("smtp", "SMTP"):
                smtp_backend = True
            else:
                logger.warn("unknown notification backend '%s'", backend)
        if smtp_backend or conf.getboolean("general", "reply-notifications"):
            subscribers.append(SMTP(self))

        self.signal = ext.Signal(*subscribers)

        self.urls = Map()

        views.Info(self)
        views.Metrics(self)
        comments.API(self, self.hasher)
 def test_render(self):
     conf = config.new({
         "markup": {
             "options": "autolink",
             "allowed-elements": "",
             "allowed-attributes": ""
         }
     })
     renderer = html.Markup(conf.section("markup")).render
     self.assertEqual(renderer("http://example.org/ and sms:+1234567890"),
                      '<p><a href="http://example.org/">http://example.org/</a> and sms:+1234567890</p>')
예제 #6
0
    def __init__(self, conf):

        self.conf = conf
        with schema.session(self.conf.get('general', 'dbpath')) as session:
            pass  # initialize by using
        self.db = db.SQLite3(conf.get('general', 'dbpath'), conf)
        self.signer = URLSafeTimedSerializer(
            self.db.preferences.get("session-key"))
        self.markup = html.Markup(conf.section('markup'))

        class NoHash:
            def __init__(self, *args, **kwargs):
                pass

            def hash(self, *args, **kwargs):
                return ""

            def uhash(self, *args, **kwargs):
                return ""

        self.hasher = NoHash()

        super(Isso, self).__init__(conf)

        subscribers = []
        for backend in conf.getlist("general", "notify"):
            if backend == "stdout":
                subscribers.append(Stdout(None))
            elif backend in ("smtp", "SMTP"):
                subscribers.append(SMTP(self))
            else:
                logger.warn("unknown notification backend '%s'", backend)

        self.signal = ext.Signal(*subscribers)

        self.urls = Map()

        views.Info(self)
        comments.API(self, self.hasher)
예제 #7
0
    def __init__(self, conf):

        self.conf = conf

        if self.conf.has_option("mysql",
                                "host") or os.getenv("MYSQL_HOST") is not None:
            logger.info("Using mysql database connector")
            self.db = mysql.MySQL(conf)
            logger.info("MySQL version: %s" % self.db.version)
        else:
            logger.info("Using sqlite database connector")
            self.db = db.SQLite3(conf.get('general', 'dbpath'), conf)

        self.signer = URLSafeTimedSerializer(
            self.db.preferences.get("session-key"))
        self.markup = html.Markup(conf.section('markup'))
        self.hasher = hash.new(conf.section("hash"))

        super(Isso, self).__init__(conf)

        subscribers = []
        smtp_backend = False
        for backend in conf.getlist("general", "notify"):
            if backend == "stdout":
                subscribers.append(Stdout(None))
            elif backend in ("smtp", "SMTP"):
                smtp_backend = True
            else:
                logger.warn("unknown notification backend '%s'", backend)
        if smtp_backend or conf.getboolean("general", "reply-notifications"):
            subscribers.append(SMTP(self))

        self.signal = ext.Signal(*subscribers)

        self.urls = Map()

        views.Info(self)
        comments.API(self, self.hasher)