Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
© 2018 SiLeader and Cerussite.
PyMVC is MVC-like server side framework for python. This framework is using Flask.
pip install pymvc
import pymvc
# setting: ex1
pymvc.settings.database.database = "pymmvc_example"
# router: ex1. Add route by method
class TopController(pymvc.Controller):
VIEW = "top.html"
def get(self, **kwargs):
pass
pymvc.add_route("/", TopController)
# router: ex2. Add route by decorator
@pymvc.route("/users/<id>")
class UserController(pymvc.Controller):
VIEW = "user.html"
def get(self, id):
return pymvc.render(id=id)
# model: ex1. User manager model
class User(pymvc.Model):
name = pymvc.StringType()
id = pymvc.UniqueIdType(primary=True)
if __name__ == '__main__':
pymvc.app.run()
pymvc.app
is Flask instance.
pymvc.settings.database.database
property)run()
method.pymvc.app
as WSGI app.Controller class has VIEW
(class variable) and get
, post
, put
and delete
instance methods.
if you want to support GET method, override get
method.
these functions' default operation is return abort(404)
.
Model class is ORM for MongoDB (using pymongo). if inherit it, it creates collection.
collection's data is specified as class variable.
import pymvc
class Other1(pymvc.Model):
pass
class ModelExample(pymvc.Model):
string_data = pymvc.StringType() # string
int_data = pymvc.IntType() # integer
float_data = pymvc.FloatType() # float
unique_data = pymvc.UniqueIdType() # UUID
foreign_data1 = pymvc.ForeignType(Other1) # other collection
foreign_data2 = pymvc.ForeignType("Other2") # other collection
class Other2(pymvc.Model):
pass
collection name is snake case of class name. (e.g. User: user, UserInfo: user_info)
model data types' constructor parameters are primary
and default
.
if primary
is True
, this value is marked as primary key.
default
is default value.
PyMVC add some Jinja2 function.
function | operation |
---|---|
load_one(model, primary=None, **query) | load one data (using find_one) |
load_many(model, primary=None, **query) | load all data match query and primary data |
model
is require parameter.
primary
is primary key value.
key value hint is **query
.
Apache License 2.0
FAQs
MVC framework for Python
We found that pymvc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.