Example #1
0
# -*- coding: utf8 -*-
__all__ = ('CIAHook',)
import xmltodict

from flask import url_for, request, abort
from flask.ext import wtf
from flask.ext.xmlrpc import XMLRPCHandler

from notifico import app, db
from notifico.services.hooks import HookService


handler = XMLRPCHandler('hub')
handler.connect(app, '/RPC2')
hub = handler.namespace('hub')


class CIAConfigForm(wtf.Form):
    use_colors = wtf.BooleanField('Use Colors', validators=[
        wtf.Optional()
    ], default=True, description=(
        'If checked, messages will include minor mIRC coloring.'
    ))


class CIAHook(HookService):
    """
    HookService hook for cia.vc style messages.
    """
    SERVICE_NAME = 'cia.vc'
    SERVICE_ID = 50
Example #2
0
import string
from datetime import datetime
from flask import url_for
from flask.ext.xmlrpc import XMLRPCHandler, Fault
from . import app, db
from .models import User, Post, Tag, Category

# MetaWeblogAPI XML-RPC
handler = XMLRPCHandler('xmlapi')
handler.connect(app, '/xmlapi')
metaweblog = handler.namespace('metaWeblog')
blogger = handler.namespace('blogger')
wordpress = handler.namespace('wp')
moveabletype = handler.namespace('mt')

def authenticate(username, password):
    user = User.is_authentic(username, password)
    if not user:
        raise Fault("invalid_user",
                    "Invalid username/password, please try again.")
    return user

def xmlpost(post):
    return {
        'title': post.title,
        'link': 'http://127.0.0.1/post/' + post.slug,
        'description': post.content['raw'],
        'postid': post.id,
        'mt_excerpt': post.teaser,
        'mt_tags': ','.join([tag.name for tag in post.tags]),
        'dateCreated': post.create_date,
Example #3
0
# -*- coding: utf8 -*-
__all__ = ('CIAHook',)
import xmltodict

from flask import url_for, request, abort
from flask.ext import wtf
from flask.ext.xmlrpc import XMLRPCHandler

from notifico import db
from notifico.services.hooks import HookService


handler = XMLRPCHandler('hub')
hub = handler.namespace('hub')


class CIAConfigForm(wtf.Form):
    use_colors = wtf.BooleanField('Use Colors', validators=[
        wtf.Optional()
    ], default=True, description=(
        'If checked, messages will include minor mIRC coloring.'
    ))


class CIAHook(HookService):
    """
    HookService hook for cia.vc style messages.
    """
    SERVICE_NAME = 'cia.vc'
    SERVICE_ID = 50
Example #4
0
# -*- coding: utf8 -*-
__all__ = ('CIAHook', )
import xmltodict

from flask import url_for, request, abort
from flask.ext import wtf
from flask.ext.xmlrpc import XMLRPCHandler

from notifico import db
from notifico.services.hooks import HookService

handler = XMLRPCHandler('hub')
hub = handler.namespace('hub')


class CIAConfigForm(wtf.Form):
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, messages will include minor mIRC coloring.'))


class CIAHook(HookService):
    """
    HookService hook for cia.vc style messages.
    """
    SERVICE_NAME = 'cia.vc'
    SERVICE_ID = 50

    @classmethod
Example #5
0
def create_app(config=None, app_name=None, modules=None):
    
    if app_name is None:
        app_name = DEFAULT_APP_NAME

    if modules is None:
        modules = DEFAULT_MODULES
    
    app = Flask(app_name,static_path=None, static_url_path=None,
                static_folder='static', template_folder='templates',
                instance_path=None, instance_relative_config=False)
    
    handler = XMLRPCHandler('sale')
    handler.connect(app, '/sale')
    
    @handler.register
    def hello(name="world"):
        if not name:
            raise Fault("unknown_recipient", "I need someone to greet!")
        return "Hello, %s!" % name
    
    app.config.from_pyfile('config.cfg',silent=True)
    app.debug = True
    app.config['SECRET_KEY'] = "zuSAyu3XRqGRvAg0HxsKX12Nrvf6Hk3AgZCWg1S1j9Y="
    for module in modules:
        app.register_blueprint(module)
    def url():
        pass
    app.add_url_rule('/url','url',url)
    
    def before():
        print 'Before-first-request'
    #app.before_first_request_funcs = [before]
    @app.errorhandler(414)
    def page_not_found(error):
        return 'This page does not exist', 414
    app.error_handler_spec[None][414] = page_not_found

    admin = Admin(app,name='Maiden',index_view=MyHomeView())
    admin.add_view(FileAdmin(path, '/static/', name='Static Files'))
    admin.add_view(UserAdmin(db.session))
    admin.add_view(ProductsAdmin(db.session))
    
    #DebugToolbarExtension(app)
    login.login_view = "login_view.fun_login"
    class Anonymous(AnonymousUser):
        name = u"Anonymous"
    login.anonymous_user = Anonymous
    login.login_message = u"请登录."
    login.refresh_view = "users.reauth"
    login.setup_app(app)
    
    configure_logging(app)
    configure_errorhandlers(app)
    configure_extensions(app)
    configure_template_filters(app)
    

    
    assets = Environment()
    assets.ASSETS_DEBUG = True
    assets.init_app(app)
    mail = Mail(app)
    principals = Principal(app)
    
    return app