# Path: coaster/db.py
# def _set_sqlite_pragma(dbapi_connection, connection_record):
# def _set_postgresql_timezone(dbapi_connection, connection_record):
# 
# Path: tests/test_sqlalchemy_models.py
# class Container(BaseMixin, db.Model):
#     __tablename__ = 'container'
#     name = Column(Unicode(80), nullable=True)
#     title = Column(Unicode(80), nullable=True)
# 
#     content = Column(Unicode(250))
# 
# class NamedDocument(BaseNameMixin, db.Model):
#     __tablename__ = 'named_document'
#     reserved_names = ['new']
#     container_id = Column(Integer, ForeignKey('container.id'))
#     container = relationship(Container)
# 
#     content = Column(Unicode(250))
# 
# class ScopedNamedDocument(BaseScopedNameMixin, db.Model):
#     __tablename__ = 'scoped_named_document'
#     reserved_names = ['new']
#     container_id = Column(Integer, ForeignKey('container.id'))
#     container = relationship(Container)
#     parent = synonym('container')
# 
#     content = Column(Unicode(250))
#     __table_args__ = (UniqueConstraint('container_id', 'name'),)


import unittest
import pytest
from flask import Flask
from werkzeug.routing import BuildError
from coaster.db import db
from .test_sqlalchemy_models import Container, NamedDocument, ScopedNamedDocument


@app1.route('/<doc>')
@NamedDocument.is_url_for('view', doc='name')
def doc_view(doc):
    return f'view {doc}'


@app1.route('/<doc>/edit')
@NamedDocument.is_url_for('edit', doc='name')
def doc_edit(doc):
    return f'edit {doc}'


@app1.route('/<doc>/upper')
@NamedDocument.is_url_for('upper', doc=lambda d: d.name.upper())
def doc_upper(doc):
    return f'upper {doc}'


# The unusual parameter `other='**other.name'` requires an explanation.
# The first `other` refers to `<other>` in the URL. The second refers
# to the parameter given to `NamedDocument.url_for` in the test below.
@app1.route('/<doc>/with/<other>')
@NamedDocument.is_url_for('with', doc='name', other='**other.name')
def doc_with(doc, other):
    return f'{doc} with {other}'


@app1.route('/<container>/<doc>')

# Path: coaster/db.py
# def _set_sqlite_pragma(dbapi_connection, connection_record):
# def _set_postgresql_timezone(dbapi_connection, connection_record):
# 
# Path: tests/test_sqlalchemy_models.py
# class Container(BaseMixin, db.Model):
#     __tablename__ = 'container'
#     name = Column(Unicode(80), nullable=True)
#     title = Column(Unicode(80), nullable=True)
# 
#     content = Column(Unicode(250))
# 
# class NamedDocument(BaseNameMixin, db.Model):
#     __tablename__ = 'named_document'
#     reserved_names = ['new']
#     container_id = Column(Integer, ForeignKey('container.id'))
#     container = relationship(Container)
# 
#     content = Column(Unicode(250))
# 
# class ScopedNamedDocument(BaseScopedNameMixin, db.Model):
#     __tablename__ = 'scoped_named_document'
#     reserved_names = ['new']
#     container_id = Column(Integer, ForeignKey('container.id'))
#     container = relationship(Container)
#     parent = synonym('container')
# 
#     content = Column(Unicode(250))
#     __table_args__ = (UniqueConstraint('container_id', 'name'),)


# Path: tests/test_url_for.py
import unittest
import pytest
from flask import Flask
from werkzeug.routing import BuildError
from coaster.db import db
from .test_sqlalchemy_models import Container, NamedDocument, ScopedNamedDocument



@app1.route('/<doc>')
@NamedDocument.is_url_for('view', doc='name')
def doc_view(doc):
    return f'view {doc}'


@app1.route('/<doc>/edit')
@NamedDocument.is_url_for('edit', doc='name')
def doc_edit(doc):
    return f'edit {doc}'


@app1.route('/<doc>/upper')
@NamedDocument.is_url_for('upper', doc=lambda d: d.name.upper())
def doc_upper(doc):
    return f'upper {doc}'


# The unusual parameter `other='**other.name'` requires an explanation.
# The first `other` refers to `<other>` in the URL. The second refers
# to the parameter given to `NamedDocument.url_for` in the test below.
@app1.route('/<doc>/with/<other>')
@NamedDocument.is_url_for('with', doc='name', other='**other.name')
def doc_with(doc, other):
    return f'{doc} with {other}'


@app1.route('/<container>/<doc>')

@ScopedNamedDocument.is_url_for('view', container='parent.id', doc='name')