<s> from flask import Flask <EOL> from flask_sqlalchemy import SQLAlchemy <EOL> from wtforms import fields , widgets <EOL> import flask_admin as admin <EOL> from flask_admin . contrib import sqla <EOL> app = Flask ( __name__ ) <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> app . config [ '<STR_LIT>' ] = True <EOL> db = SQLAlchemy ( app ) <EOL> '''<STR_LIT>''' <EOL> class CKTextAreaWidget ( widgets . TextArea ) : <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> existing_classes = kwargs . pop ( '<STR_LIT:class>' , '<STR_LIT>' ) or kwargs . pop ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> kwargs [ '<STR_LIT:class>' ] = u'<STR_LIT>' % ( existing_classes , "<STR_LIT>" ) <EOL> return super ( CKTextAreaWidget , self ) . __call__ ( field , ** kwargs ) <EOL> class CKTextAreaField ( fields . TextAreaField ) : <EOL> widget = CKTextAreaWidget ( ) <EOL> class Page ( db . Model ) : <EOL> id = db . Column ( db . Integer , primary_key = True ) <EOL> name = db . Column ( db . Unicode ( <NUM_LIT:64> ) ) <EOL> text = db . Column ( db . UnicodeText ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class PageAdmin ( sqla . ModelView ) : <EOL> form_overrides = dict ( text = CKTextAreaField ) <EOL> create_template = '<STR_LIT>' <EOL> edit_template = '<STR_LIT>' <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> def index ( ) : <EOL> return '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> admin = admin . Admin ( app , name = "<STR_LIT>" ) <EOL> admin . add_view ( PageAdmin ( Page , db . session ) ) <EOL> db . create_all ( ) <EOL> app . run ( debug = True ) </s>
