Package: coaster
Coaster contains functions and db models for recurring patterns in Flask
apps. Documentation athttp://coaster.readthedocs.org/Coaster is compatible with Python versions 2.7 and 3.6. Earlier 3.x versions
are not supported due to obsolete SQLite drivers missing some functionality.
If you need to use an earlier 3.x version (3.3-3.5) and don’t use SQLite, you
may still be in luck.Run testsTesting requires SQLite and PostgreSQL for thecoaster.sqlalchemymodule.
Create a test database in PostgreSQL:$ createuser `whoami`
$ createdb -O `whoami` coaster_testTesting also requires additional dependencies. Install them with:$ pip install -r test_requirements.txtOn Python 2.7, an additional package is required, to replace the obsolete
SQLite driver shipped with 2.7:$ pip install PySqliteTo run a single test:$ nosetests tests.<test_filename>
$ # Example: nosetests tests.test_render_withTo run all tests in one go:$ ./runtests.shSome tests are in the form of doctests within each function, and only
accessible by running all tests viaruntests.sh.0.6.1Renamedcoaster.roles.set_rolestowith_rolesand added support for
wrappingdeclared_attrand column propertiesRestructured roles to match current understanding of principals, actors and
anchorsAdded SQLAlchemy column annotationsReorganisedcoaster.utilsandcoaster.sqlalchemyinto sub-packagesLabeledEnumnow supports grouped values if declared as a setNew:coaster.sqlalchemy.StateManageradds state management to modelsDiscontinued:coaster.utils.*is no longer available directly ascoaster.*Discontinued:coaster.views.load_modelsno longer accepts theworkflowparameterNew:requestqueryandrequestformto complementcoaster.views.requestargsNew:coaster.authmodule with acurrent_authproxy that provides
a standardised API for login managers to useNew:is_collectionutil for testing if an item is a collection data typeNew:coaster.views.requires_permissiondecoratorNew:coaster.views.classviewprovides a new take on organising views
into a classNew:coaster.utils.classmethodproperty: like a property, but for class
methodsNew:coaster.views.endpoint_for: discover an endpoint given a URLChanged:UuidMixinno longer providesurl_idNew:coaster.sqlalchemy.UrlForMixinnow provides anabsolute_urlpropertyChanged:coaster.sqlalchemy.UrlForMixinnow recognises that the project
may have multiple apps with distinct URLs for the same contentNew:coaster.sqlalchemy.registryprovides two registries for forms and
views associated with modelsNew:coaster.views.requires_rolesdecorator forModelView, withis_availabletestNew:UrlForMixinnow providesview_forandclassview_forChanged:TimestampMixinoptionally usestimestamptzcolumns.
A future release may make this the defaultChanged: Markdown parser has moved tocoaster.utils.markdownand is no
longer a hack to be embarrassed byNew: Unicode whitespace strippers,ulstrip,urstripandustripAdded lazy role grant evaluation and declarative role grantsNew:nary_opdecorator to turn a binary operator into a chained n-ary
operatorAdded datasets for limited enumeration in role access, as a stopgap until
migration to GraphQLRemoved ShortUUID in favour of the more stable Base58MarkdownColumn now supports a custom markdown processor and optionsNew: Support for secret key rotation in Flask appsLast version to support Python 2.7; Coaster 0.7 will be Py 3.6+ only0.6.0Removed deprecatedcoaster.app.configurecoaster.app.init_appnow takes an optional environment, reading from theFLASK_ENVenvironment variable and defaulting toDEVELOPMENT. This
reverses the change introduced in version 0.3.2coaster.manageno longer accepts environment or callsinit_for.
Apps must do this themselvescoaster.managenow exposes Alembic migrations via Flask-Migrate instead
of Flask-AlembicWhen using UUID primary keys inIdMixin, a UUID is automatically
generated the first time theidcolumn is accessed, without the need
to commit to the databaseThe underlying implementaiton,auto_init_default, is also available
for use on other modelsTheurl_idproperty is now part ofIdMixinand supports SQL queries
as well. This makes it compatible with the support forurl_nameinload_modelsNew:shortuuidmodule exposed via theutilsmodule, withsuuid,suuid2uuidanduuid2suuidfunctionsbuidreverts to using UUID4 instead of UUID1mcThe deprecatednewidalias forbuidhas now been removedNew:UuidMixinthat adds a UUID secondary key and complementsIdMixinBaseIdNameMixinnow implementsurl_id_name(previouslyurl_name)
as a hybrid property and has an additionalurl_name_suuidproperty.BaseScopedIdNameMixinhas an upgradedurl_id_nameas wellload_modelsno longer hardcodes forurl_name, instead accepting an
optionalurlchecklist parameterAdded Python 3.6 compatibilityRemoved the unusednullstrand renamednullunicodetonullstrNew:add_primary_relationshipto define a primary child on parent modelsAddedNoIdMixinthat is BaseMixin minus the id columnNew:require_one_ofutil for functions that require any one of many
parameters0.5.2Removedadd_and_commitand associated testsfailsafe_addnow takes filters optionally, failing silently in case of
errorAdded Slack error logging and better throttling for Slack and SMSNew util:isoweek_datetimefor week-based datetimes in reportsNew util:midnight_to_utcfor midnight in any timezone converted to UTC0.5.1New util:uuid1mcgenerates a UUID1 with a random multicast MAC idNew util:uuid1mc_from_datetimegenerates a UUID1 with a specific
timestampIdMixin now supports UUID primary keysDeprecatedadd_and_commitin favour offailsafe_addNew utils:uuid2buidandbuid2uuidRemovedtimestamp_columns(was deprecated in 0.4.3)Replacedpy-bcryptdependency withbcryptbuidnow uses UUID1 with random multicast MAC addresses instead of UUID4New util:unicode_http_headerconverts ASCII HTTP header strings to
UnicodeError traceback incoaster.loggingnow includes request context and
session cookieNew:func.utcnowfor reliable UTC timestamps generated in the databaseTimestampMixin now usesfunc.utcnowto move datetime generation
server-side0.5.0Base(Scoped)?(Id)?NameMixinnow disallows blank names by default. Bumped
version number since this is a non-breaking incompatible changeJsonDictnow usesJSONBon PostgreSQL 9.4NewCoordinatesMixinadds latitude and longitude columnsRudimentary NLP methodsLabeledEnumnow haskeys()andvalues()methods as wellMove the query class toIdMixinandTimestampMixinas they are used
independently of BaseMixinLabeledEnumnow takes an__order__specificationNewword_countutil returns word count for HTML documentsNewfor_tsqueryformats text queries to PostgreSQL to_tsquery parametersNewgetandupsertmethods inBase(Scoped)NameMixinrender_withno longer enables JSON handler by default; now gracefully
handles*/*requestsmanage.py’s shell now allows additional context to be made available inlocals()coaster.dbnow provides a custom SQLAlchemy session with additional
helper methods, starting with one:add_and_commit, which rolls back if
the commit failsRemovedone_or_nonein favor of SQLAlchemy’s implementation of the same
in 1.0.9Newis_url_fordecorator in UrlForMixin0.4.3Initial work on Fluentd loggingNew util:base_domain_matchescompares if two domains have the same base
domainutils.make_namenow returns ASCII slugs instead of Unicode slugsNew:domain_namespace_matchfunctioncoaster.gfm.markdownnow supports optional HTML markupDeprecatedsqlalchemy.timestamp_columns, introducingmake_timestamp_columnssorted_timezonesnow includes both country name and timezone nameBase query now has anotempty()method that is more efficient thanbool(count())New util:deobfuscate_emaildeobfuscates common email obfuscation
patterns0.4.2NameTitlenamedtuple and support inLabeledEnumfor(value, name, title)Provide UglifyJS minifier to webassets via the UglipyJS wrapperBaseScopedNameMixin’smake_titlenow usesshort_titleas source0.4.1views.get_next_urlnow considers subdomains as non-externalsqlalchemy.BaseMixinnow provides a new query class withone_or_noneCoaster now requires all dependencies used by submodules. They are no longer
optionalLabeledEnums now have aget()method to emulate dictionaries0.4.0Moved utility functions intocoaster.utilsBugfix: makeget_email_domainsomewhat more reliableSwitched to usingcoaster.dbin testsNew:MarkdownColumncomposite column for Markdown contentChanged:JsonDictcolumn will use PostgreSQL’s native JSON type if
the server is PostgreSQL >= 9.2TimestampMixinnow usesdatetime.utcnowinstead offunc.nowbecause thenow()function in PostgreSQL returns local time with
timezone, not UTC time, and discards the timezone component if the column
doesn’t store them. This made timestamps local, not in UTC unless the server
was also in UTCDatabase tests are now run against both SQLite3 and PostgreSQLBugfix:PermissionMixinwas mutating inherited permissionsBugfix:render_withno longer attempts to render pre-rendered responsesutils.make_namenow takes caller-specified counter numberssqlalchemy.BaseNameMixinandBaseScopedNameMixin.make_namenow take a
reserved names listNew:utils.nullint,nullstrandnullunicodefor returningint(v),str(v)andunicode(v)ifvisn’t false0.3.13short_titlemethod inBaseScopedNameMixinassets.requirenow raisesAssetNotFoundon missing assetsNew:coaster.db.dbis an instance of Flask-SQLAlchemy0.3.12Bugfix: Support single-char usernamesNew feature: Labeled enumerationsEnhancement:load_modelsallows choice of permissions and takes
additional permissionsRewroterequestargsview decorator for efficiency and ease of useNewrender_withview decoratorNew gfm module for GitHub Flavoured Markdownload_modelsnow supports “redirect” modelsLogging now looks forMAIL_DEFAULT_SENDERbeforeDEFAULT_MAIL_SENDERCompatibility with Flask 0.10 for SandboxedFlask0.3.11Bugfix:PermissionMixin.permissions()now checks if parent is not None0.3.10Newsorted_timezonesfunction0.3.9New module for asset management, with testcases and documentation.coaster.logging.configureis nowinit_appin keeping with convention0.3.8Updated documentationNew SQLAlchemy column types and helpersUse SQL expressions to seturl_idin scoped id classes0.3.7Don’t usedeclared_attrfor theid,created_atandupdated_atcolumnsRenamenewidtobuidbut retain old name for compatibilityNewrequestargsview wrapper to make working withrequest.argseasier0.3.6NewSandboxedFlaskincoaster.appthat uses Jinja’sSandboxedEnvironment0.3.5load_modelsnow caches data toflask.gSQLAlchemy models now usedeclared_attrfor all columns to work around a
column duplication bug with joined table inheritance in SQLAlchemy < 0.8Misc fixes0.3.4get_next_urlnow takes a default parameter. Passdefault=Noneto
returnNoneif no suitable next URL can be foundget_next_urlno longer looks in the session by default. Passsession=Trueto look in the session. This was added since poppingnextfrom session modifies the session, which shouldn’t happen in agetfunctionload_modelsacceptsg.<name>notation for parameters to indicate
that the parameter should be available asg.<name>. The view function
will get called with just<name>as usualIf the view requires permissions,load_modelscaches availablepermissions asg.permissions0.3.3coaster.views.get_next_urlnow looks in the session for the next URL0.3.2Newcoaster.app.init_appfunction moves away from passing configuration
status in environment variables0.3.0SQLAlchemy models now have apermissionsmethod thatload_modelslooks up0.2.2Added logging module0.1First version