示例#1
0
文件: common.py 项目: RekGRpth/py4web
        OAuth2Facebook(
            client_id=settings.OAUTH2FACEBOOK_CLIENT_ID,
            client_secret=settings.OAUTH2FACEBOOK_CLIENT_SECRET,
            callback_url="auth/plugin/oauth2facebook/callback",
        ))

if settings.OAUTH2OKTA_CLIENT_ID:
    from py4web.utils.auth_plugins.oauth2okta import OAuth2Okta  # TESTED

    auth.register_plugin(
        OAuth2Okta(
            client_id=settings.OAUTH2OKTA_CLIENT_ID,
            client_secret=settings.OAUTH2OKTA_CLIENT_SECRET,
            callback_url="auth/plugin/oauth2okta/callback",
        ))

if settings.USE_CELERY:
    from celery import Celery

    # to use from . common import scheduled and then use it accoding to celery docs
    # examples in tasks.py
    scheduler = Celery("apps.%s.tasks" % settings.APP_NAME,
                       broker=settings.CELERY_BROKER)

# we enable auth, which requres sessions, T, db and we make T available to
# the template, although we recommend client-side translations instead
auth.enable(uses=(session, T, db), env=dict(T=T))

unauthenticated = ActionFactory(db, session, T, flash, auth)
authenticated = ActionFactory(db, session, T, flash, auth.user)
示例#2
0
def is_git_repo(project):
    return os.path.exists(os.path.join(FOLDER, project, ".git/config"))


class Logged(Fixture):
    def __init__(self, session):
        self.__prerequisites__ = [session]
        self.session = session

    def on_request(self):
        user = self.session.get("user")
        if not user or not user.get("id"):
            abort(403)


authenticated = ActionFactory(Logged(session))
session_secured = action.uses(Logged(session))


@action('version')
def version():
    return __version__


if MODE in ("demo", "readonly", "full"):

    @action("index")
    @action.uses("index.html", session, T)
    def index():
        return dict(
            languages=dumps(T.local.language),
示例#3
0
        elif form.errors:
            messages.append("form %s has errors: %s " %
                            (form.form_name, form.errors))
    return dict(forms=forms, messages=messages)


# exposed as /examples/showme
@action("helpers")
@action.uses("generic.html")
def example_helpers():
    return dict(a=H1("I am a title"),
                b=2,
                c=dict(d=3, e=4, x=INPUT(_name="test")))


expose = ActionFactory(auth, T, Inject(message="Hello World"))


@expose.get("test_expose1", template="generic.html")
def test_expose1():
    return dict()


@expose.get("test_expose2")
def test_expose2():
    return dict()


@expose("test_expose3")
def test_expose3():
    return dict()
示例#4
0
        ))
if settings.OAUTH2FACEBOOK_CLIENT_ID:
    from py4web.utils.auth_plugins.oauth2facebook import OAuth2Facebook  # UNTESTED

    my_auth.register_plugin(
        OAuth2Facebook(
            client_id=settings.OAUTH2FACEBOOK_CLIENT_ID,
            client_secret=settings.OAUTH2FACEBOOK_CLIENT_SECRET,
            callback_url="auth/plugin/oauth2google/callback",
        ))

if settings.USE_CELERY:
    from celery import Celery
    # to use from . common import scheduled and then use it accoding to celery docs
    # examples in tasks.py
    scheduler = Celery('apps.%s.tasks' % settings.APP_NAME,
                       broker=settings.CELERY_BROKER)

# we enable auth, which requres sessions, T, db and we make T available to
# the template, although we recommend client-side translations instead
my_auth.enable(uses=(session, T, db), env=dict(T=T))

unauthenticated = ActionFactory(db, session, T, my_auth)
authenticated = ActionFactory(db, session, T, my_auth.user)

logging.basicConfig(
    filename='apps/strahovka/applog.txt',
    filemode='a',
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)