dolamroth / starlette-web Goto Github PK
View Code? Open in Web Editor NEWThis project forked from dmitryburnaev/starlette-web
Asynchronous web framework, based on Starlette and inspired by Django
License: MIT License
This project forked from dmitryburnaev/starlette-web
Asynchronous web framework, based on Starlette and inspired by Django
License: MIT License
Consider, which of these may be useful to include/link in the framework
While at it, also move from initializing app with session maker in each command, but provide a global application object.
Redo settings.DATABASE -> settings.DATABASES and provide global variable connections, in the same manner as Django
ConnectionHandler is a wrapper around project sessionmaker(s). This will be a step for #21
https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html
# using example from "Custom Vertical Partitioning"
import random
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.ext.asyncio import async_sessionmaker
from sqlalchemy.orm import Session
# construct async engines w/ async drivers
engines = {
'leader':create_async_engine("sqlite+aiosqlite:///leader.db"),
'other':create_async_engine("sqlite+aiosqlite:///other.db"),
'follower1':create_async_engine("sqlite+aiosqlite:///follower1.db"),
'follower2':create_async_engine("sqlite+aiosqlite:///follower2.db"),
}
class RoutingSession(Session):
def get_bind(self, mapper=None, clause=None, **kw):
# within get_bind(), return sync engines
if mapper and issubclass(mapper.class_, MyOtherClass):
return engines['other'].sync_engine
elif self._flushing or isinstance(clause, (Update, Delete)):
return engines['leader'].sync_engine
else:
return engines[
random.choice(['follower1','follower2'])
].sync_engine
# apply to AsyncSession using sync_session_class
AsyncSessionMaker = async_sessionmaker(
sync_session_class=RoutingSession
)
This would require to switch to asynchronous template rendering, substituting default starlette's TemplateResponse, since they don't favor async template rendering https://www.starlette.io/templates/#asynchronous-template-rendering
It appears, this library has no support for composite primary keys, which potentially may be a problem.
def argparse_uuid_type(arg_value: str) -> uuid.UUID:
try:
return uuid.UUID(arg_value)
except (ValueError, TypeError):
raise argparse.ArgumentTypeError('Invalid UUID value')
def argparse_date_type(arg_value: str) -> datetime.date:
try:
return datetime.datetime.strptime(arg_value, "%Y-%m-%d").date()
except ValueError:
raise argparse.ArgumentTypeError('Invalid date value')
Targets for 0.2:
All pros and cons must be carefully decided.
Requirements:
Additional requirements:
FastAPI-admin seems to be more feature complete, than starlette_admin, but has a hard requirement for Tortoise ORM.
Additional point to consider is that Tortoise ORM basically autocommit all-the-way-through, similar to Django ORM.
Will probably require to move from marshmallow to pydantic, but needs consideration. Pydantic is widely reported to be faster and more feature complete, but marshmallow is said to be more customizable. However, it was pointed out, that Pydantic reliance on Python typing features may be a limitation in certain tasks.
Based on discussion agronholm/smtpproto#35
Validation for constance has sense if it is used in admin panel, and has not much sense otherwise.
This issue requires the following task to be performed before:
Validation should be done by making base class ConstanceType, which defines .clear() method, and widget for admin-panel.
async def _async_load_location_data(self, schema, req, location):
data = await super()._async_load_location_data(schema, req, location)
return underscoreize(data, no_underscore_before_number=True)
Some ideas may be fetched from:
Targets:
Starlette itself is anyio-compatible. However, underlying implementations of low-level libraries are mostly not.
Desireable contrib libraries to have around for production
httpx
In this case, module __file__
is None
Must be rstrip
instead of strip
(as of now, strips initial slash "/" on Linux)
strip/strip -> rstrip/lstrip
Just add hardcoded warnings, the duplicates are already forbidden
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.