Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def authorizeChirper(session_store, transaction, session):
# type: (ISessionStore, Transaction, ISession) -> Deferred
account = (yield session.authorize([ISimpleAccount]))[ISimpleAccount]
if account is not None:
returnValue(Chirper(transaction, account, chirpTable))
style.renderMethod, account=Authorization(ISimpleAccount, required=False)
)
def ifLoggedIn(tag, account):
# type: (Tag, ISimpleAccount) -> Any
"""
Render the given tag if the user is logged in, otherwise don't.
"""
if account is None:
return u""
else:
return tag
defaults={
"homeActive": "",
"loginActive": "",
"signupActive": "",
"sessionsActive": "",
}
)
from sqlalchemy import Column, String, ForeignKey
import attr
@attr.s
class Chirper(object):
transaction = attr.ib(type=Transaction)
account = attr.ib(type=ISimpleAccount)
chirpTable = attr.ib(type=Table)
def chirp(self, value):
# type: (str) -> Deferred
chirpTable = self.chirpTable
return self.transaction.execute(chirpTable.insert().values(
account_id=self.account.accountID,
chirp=value
))
appMetadata = MetaData()
sessionSchema = SessionSchema.withMetadata(appMetadata)
chirpTable = Table(
'chirp', appMetadata,
Column("account_id", String(),
ForeignKey(sessionSchema.account.c.account_id)),