Dirty models for python 3
Project description
dirty-models
Dirty models for python 3
Documentation
Features
Python 3 package.
Easy to create a model.
Non destructive modifications.
Non false positive modifications.
Able to restore original data for each field or whole model.
Access to original data.
Read only fields.
Alias for fields.
Custom getters and setters for each fields.
Automatic cast value.
Easy import from/export to dict.
Basic field type implemented.
HashMap model. It could be used instead of DynamicModel.
Pickable models.
Datetime fields can use any datetime format using parser and formatter functions.
No database dependent.
Installation
$ pip install dirty-models
Issues
Getter and setter feature needs refactor to be able to use as decorators.
DynamicModel is too strange. I don’t trust in it. Try to use HashMapModel.
Basic usage
from dirty_models.models import BaseModel
from dirty_models.fields import StringField, IntegerField
class FooBarModel(BaseModel):
foo = IntegerField()
bar = StringField(name="real_bar")
alias_field = IntegerField(alias=['alias1', 'alias2'])
fb = FooBarModel()
fb.foo = 2
assert fb.foo is 2
fb.bar = 'wow'
assert fb.bar is 'wow'
assert fb.real_bar is 'wow'
fb.alias_field = 3
assert fb.alias_field is 3
assert fb.alias1 is fb.alias_field
assert fb.alias2 is fb.alias_field
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.