Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@requirer.require(style.renderMethod, account=Authorization(ISimpleAccount))
def username(tag, account):
# type: (Tag, ISimpleAccount) -> Tag
return tag(account.username)
binding=Authorization(ISimpleAccountBinding, required=False),
session=RequestComponent(ISession),
)
@inlineCallbacks
def sessions(binding, form, session):
# type: (ISimpleAccountBinding, Form, ISession) -> Deferred
if binding is None:
returnValue({"sessions": []})
else:
dump = {
"sessions": [
oneSession.widget(
session_info, form, session.identifier == session_info.id
)
for session_info in (yield binding.boundSessionInformation())
]
}
reader=Authorization(ChirpReader)
)
@inlineCallbacks
def readSomeChirps(user, reader):
# type: (str, ChirpReader) -> Deferred
chirps = yield reader.readChirps(user)
returnValue({
"user": user,
"chirps": chirps,
})
account=Authorization(ISimpleAccount, required=False),
chirp_form=Form.rendererFor(addChirp, "/chirp")
)
def root(chirp_form, account):
# type: (Chirper, ISimpleAccount) -> Dict
return {
"result": "hello world",
"homeActive": "active",
"chirp_form": chirp_form if account is not None else u"",
}
chirper=Authorization(Chirper),
)
@inlineCallbacks
def addChirp(chirper, value):
# type: (Chirper, str) -> Deferred
yield chirper.chirp(value)
returnValue(Redirect(b"/"))
binding=Authorization(ISimpleAccountBinding),
sessionID=Field.text(),
url=RequestURL(),
)
@inlineCallbacks
def logOtherOut(sessionID, binding, url):
# type: (str, ISimpleAccountBinding, DecodedURL) -> Deferred
from attr import assoc
# TODO: public API for getting to this?
session = yield binding._session._sessionStore.loadSession(
sessionID, url.scheme == u'https', SessionMechanism.Header
)
other_binding = assoc(binding, _session=session)
yield other_binding.unbindThisSession()
returnValue(Redirect(b"/sessions"))