diff options
Diffstat (limited to 'python-django-computedfields.spec')
| -rw-r--r-- | python-django-computedfields.spec | 573 |
1 files changed, 573 insertions, 0 deletions
diff --git a/python-django-computedfields.spec b/python-django-computedfields.spec new file mode 100644 index 0000000..d222c69 --- /dev/null +++ b/python-django-computedfields.spec @@ -0,0 +1,573 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-computedfields +Version: 0.2.2 +Release: 1 +Summary: autoupdated database fields for model methods +License: MIT +URL: https://github.com/netzkolchose/django-computedfields +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/7d/76/b89f78a10af5ed89f305881e4eedf720092eaa4dc5443a74c6b9cbcedcba/django-computedfields-0.2.2.tar.gz +BuildArch: noarch + + +%description +[](https://github.com/netzkolchose/django-computedfields/actions/workflows/build.yml) +[](https://coveralls.io/github/netzkolchose/django-computedfields?branch=master) + + +### django-computedfields ### + +django-computedfields provides autoupdated database fields +for model methods. + +Tested with Django 3.2 and 4.2 (Python 3.7 to 3.10). + + +#### Example #### + +Just derive your model from `ComputedFieldsModel` and place +the `@computed` decorator at a method: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + + @computed(models.CharField(max_length=32), depends=[('self', ['name'])]) + def computed_field(self): + return self.name.upper() +``` + +`computed_field` will be turned into a real database field +and can be accessed and searched like any other database field. +During saving the associated method gets called and it’s result +written to the database. + + +#### How to recalculate without saving the model record #### + +If you need to recalculate the computed field but without saving it, use +`from computedfields.models import compute` + +```python +>>> from computedfields.models import compute +>>> person = MyModel.objects.get(id=1) # this is to retrieve existing record +>>> person.computed_field # outputs 'BERTY' +>>> person.name = 'nina' # changing the dependent field `name` to nina +>>> compute(person, 'computed_field') # outputs 'NINA' +>>> person.computed_field # outputs 'BERTY' because the `person` is not yet saved +>>> person.save() # alters the database record for `name` and `computed_field` +>>> person.computed_field # outputs 'NINA' +``` + +#### `depends` keyword + +The `depends` keyword argument can be used with any relation to indicate dependencies to fields on other models as well: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + fk = models.ForeignKey(SomeModel) + + @computed( + models.CharField(max_length=32), + depends=[ + ('self', ['name']), + ('fk', ['fieldname']) + ] + ) + def computed_field(self): + return self.name.upper() + self.fk.fieldname +``` + +Now changes to `self.name`, `fk` or `fk.fieldname` will update `computed_field`. + + +#### Documentation #### + +The documentation can be found [here](https://django-computedfields.readthedocs.io/en/latest/index.html). + + +#### Changelog #### + +- 0.2.2 + - Django 4.2 support + - Use `model._base_manager` instead of `model.objects` to prevent using overridden `models.objects` with a custom manager + +- 0.2.1 + - Django 4.1 support + +- 0.2.0 - next beta release + - new features: + - better memory control for the update resolver via + ``COMPUTEDFIELDS_QUERYSIZE`` or as argument on ``@computed`` + - update optimization - early update-tree exit + - faster updates with ``COMPUTEDFIELDS_FASTUPDATE`` + - `checkdata` command + - `showdependencies` command + - typing support for computed fields + + - enhancements: + - better `updatedata` command + + - removed features: + - transitive reduction on intermodel graph (due to negative impact) + - pickled resolver map (due to showing low benefit) + - `update_dependent_multi` and `preupdate_dependent_multi` + (due to showing low benefit and being a code nuisance) + - Django 2.2 shims removed + + - bug fixes: + - regression on proxy models fixed + - sliced querset support for mysql fixed + +- 0.1.7 + - add list type support for `update_fields` in signal handlers + +- 0.1.6 + - maintenace version with CI test dependencies changes: + - removed Python 3.6 + - removed Django 2.2 + - added Python 3.10 + - added Django 4.0 + - move dev environment to Python 3.10 and Django 3.2 + + Note that Django 2.2 will keep working until real incompatible code changes occur. + This may happen by any later release, thus treat 0.1.6 as last compatible version. + +- 0.1.5 + - fix error on model instance cloning +- 0.1.4 + - Django 3.2 support +- 0.1.3 + - better multi table inheritance support and test cases + - explicit docs for multi table inheritance +- 0.1.2 + - bugfix: o2o reverse name access + - add docs about model inheritance support +- 0.1.1 + - bugfix: add missing migration +- 0.1.0 + - fix recursion on empty queryset + - dependency expansion on M2M fields + - `m2m_changed` handler with filtering on m2m fields + - remove custom metaclass, introducing *Resolver* class + - new decorator `@precomputed` for custom save methods + - old *depends* syntax removed + - docs update +- 0.0.23: + - Bugfix: Fixing leaking computed fields in model inheritance. +- 0.0.22: + - Automatic dependency expansion on reverse relations. + - Example documentation. +- 0.0.21: + - Bugfix: Fixing undefined _batchsize for pickled map usage. +- 0.0.20 + - Use `bulk_update` for computed field updates. + - Allow custom update optimizations with *select_related* and *prefetch_related*. + - Respect computed field MRO in `compute`. + - Allow updates on local computed fields from `update_dependent` simplifying bulk actions on `ComputedFieldsModel`. +- 0.0.19 + - Better graph expansion on relation paths with support for *update_fields*. +- 0.0.18 + - New *depends* syntax deprecating the old one. + - MRO of local computed field methods implemented. +- 0.0.17 + - Dropped Python 2.7 and Django 1.11 support. + +%package -n python3-django-computedfields +Summary: autoupdated database fields for model methods +Provides: python-django-computedfields +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-computedfields +[](https://github.com/netzkolchose/django-computedfields/actions/workflows/build.yml) +[](https://coveralls.io/github/netzkolchose/django-computedfields?branch=master) + + +### django-computedfields ### + +django-computedfields provides autoupdated database fields +for model methods. + +Tested with Django 3.2 and 4.2 (Python 3.7 to 3.10). + + +#### Example #### + +Just derive your model from `ComputedFieldsModel` and place +the `@computed` decorator at a method: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + + @computed(models.CharField(max_length=32), depends=[('self', ['name'])]) + def computed_field(self): + return self.name.upper() +``` + +`computed_field` will be turned into a real database field +and can be accessed and searched like any other database field. +During saving the associated method gets called and it’s result +written to the database. + + +#### How to recalculate without saving the model record #### + +If you need to recalculate the computed field but without saving it, use +`from computedfields.models import compute` + +```python +>>> from computedfields.models import compute +>>> person = MyModel.objects.get(id=1) # this is to retrieve existing record +>>> person.computed_field # outputs 'BERTY' +>>> person.name = 'nina' # changing the dependent field `name` to nina +>>> compute(person, 'computed_field') # outputs 'NINA' +>>> person.computed_field # outputs 'BERTY' because the `person` is not yet saved +>>> person.save() # alters the database record for `name` and `computed_field` +>>> person.computed_field # outputs 'NINA' +``` + +#### `depends` keyword + +The `depends` keyword argument can be used with any relation to indicate dependencies to fields on other models as well: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + fk = models.ForeignKey(SomeModel) + + @computed( + models.CharField(max_length=32), + depends=[ + ('self', ['name']), + ('fk', ['fieldname']) + ] + ) + def computed_field(self): + return self.name.upper() + self.fk.fieldname +``` + +Now changes to `self.name`, `fk` or `fk.fieldname` will update `computed_field`. + + +#### Documentation #### + +The documentation can be found [here](https://django-computedfields.readthedocs.io/en/latest/index.html). + + +#### Changelog #### + +- 0.2.2 + - Django 4.2 support + - Use `model._base_manager` instead of `model.objects` to prevent using overridden `models.objects` with a custom manager + +- 0.2.1 + - Django 4.1 support + +- 0.2.0 - next beta release + - new features: + - better memory control for the update resolver via + ``COMPUTEDFIELDS_QUERYSIZE`` or as argument on ``@computed`` + - update optimization - early update-tree exit + - faster updates with ``COMPUTEDFIELDS_FASTUPDATE`` + - `checkdata` command + - `showdependencies` command + - typing support for computed fields + + - enhancements: + - better `updatedata` command + + - removed features: + - transitive reduction on intermodel graph (due to negative impact) + - pickled resolver map (due to showing low benefit) + - `update_dependent_multi` and `preupdate_dependent_multi` + (due to showing low benefit and being a code nuisance) + - Django 2.2 shims removed + + - bug fixes: + - regression on proxy models fixed + - sliced querset support for mysql fixed + +- 0.1.7 + - add list type support for `update_fields` in signal handlers + +- 0.1.6 + - maintenace version with CI test dependencies changes: + - removed Python 3.6 + - removed Django 2.2 + - added Python 3.10 + - added Django 4.0 + - move dev environment to Python 3.10 and Django 3.2 + + Note that Django 2.2 will keep working until real incompatible code changes occur. + This may happen by any later release, thus treat 0.1.6 as last compatible version. + +- 0.1.5 + - fix error on model instance cloning +- 0.1.4 + - Django 3.2 support +- 0.1.3 + - better multi table inheritance support and test cases + - explicit docs for multi table inheritance +- 0.1.2 + - bugfix: o2o reverse name access + - add docs about model inheritance support +- 0.1.1 + - bugfix: add missing migration +- 0.1.0 + - fix recursion on empty queryset + - dependency expansion on M2M fields + - `m2m_changed` handler with filtering on m2m fields + - remove custom metaclass, introducing *Resolver* class + - new decorator `@precomputed` for custom save methods + - old *depends* syntax removed + - docs update +- 0.0.23: + - Bugfix: Fixing leaking computed fields in model inheritance. +- 0.0.22: + - Automatic dependency expansion on reverse relations. + - Example documentation. +- 0.0.21: + - Bugfix: Fixing undefined _batchsize for pickled map usage. +- 0.0.20 + - Use `bulk_update` for computed field updates. + - Allow custom update optimizations with *select_related* and *prefetch_related*. + - Respect computed field MRO in `compute`. + - Allow updates on local computed fields from `update_dependent` simplifying bulk actions on `ComputedFieldsModel`. +- 0.0.19 + - Better graph expansion on relation paths with support for *update_fields*. +- 0.0.18 + - New *depends* syntax deprecating the old one. + - MRO of local computed field methods implemented. +- 0.0.17 + - Dropped Python 2.7 and Django 1.11 support. + +%package help +Summary: Development documents and examples for django-computedfields +Provides: python3-django-computedfields-doc +%description help +[](https://github.com/netzkolchose/django-computedfields/actions/workflows/build.yml) +[](https://coveralls.io/github/netzkolchose/django-computedfields?branch=master) + + +### django-computedfields ### + +django-computedfields provides autoupdated database fields +for model methods. + +Tested with Django 3.2 and 4.2 (Python 3.7 to 3.10). + + +#### Example #### + +Just derive your model from `ComputedFieldsModel` and place +the `@computed` decorator at a method: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + + @computed(models.CharField(max_length=32), depends=[('self', ['name'])]) + def computed_field(self): + return self.name.upper() +``` + +`computed_field` will be turned into a real database field +and can be accessed and searched like any other database field. +During saving the associated method gets called and it’s result +written to the database. + + +#### How to recalculate without saving the model record #### + +If you need to recalculate the computed field but without saving it, use +`from computedfields.models import compute` + +```python +>>> from computedfields.models import compute +>>> person = MyModel.objects.get(id=1) # this is to retrieve existing record +>>> person.computed_field # outputs 'BERTY' +>>> person.name = 'nina' # changing the dependent field `name` to nina +>>> compute(person, 'computed_field') # outputs 'NINA' +>>> person.computed_field # outputs 'BERTY' because the `person` is not yet saved +>>> person.save() # alters the database record for `name` and `computed_field` +>>> person.computed_field # outputs 'NINA' +``` + +#### `depends` keyword + +The `depends` keyword argument can be used with any relation to indicate dependencies to fields on other models as well: + +```python +from django.db import models +from computedfields.models import ComputedFieldsModel, computed + +class MyModel(ComputedFieldsModel): + name = models.CharField(max_length=32) + fk = models.ForeignKey(SomeModel) + + @computed( + models.CharField(max_length=32), + depends=[ + ('self', ['name']), + ('fk', ['fieldname']) + ] + ) + def computed_field(self): + return self.name.upper() + self.fk.fieldname +``` + +Now changes to `self.name`, `fk` or `fk.fieldname` will update `computed_field`. + + +#### Documentation #### + +The documentation can be found [here](https://django-computedfields.readthedocs.io/en/latest/index.html). + + +#### Changelog #### + +- 0.2.2 + - Django 4.2 support + - Use `model._base_manager` instead of `model.objects` to prevent using overridden `models.objects` with a custom manager + +- 0.2.1 + - Django 4.1 support + +- 0.2.0 - next beta release + - new features: + - better memory control for the update resolver via + ``COMPUTEDFIELDS_QUERYSIZE`` or as argument on ``@computed`` + - update optimization - early update-tree exit + - faster updates with ``COMPUTEDFIELDS_FASTUPDATE`` + - `checkdata` command + - `showdependencies` command + - typing support for computed fields + + - enhancements: + - better `updatedata` command + + - removed features: + - transitive reduction on intermodel graph (due to negative impact) + - pickled resolver map (due to showing low benefit) + - `update_dependent_multi` and `preupdate_dependent_multi` + (due to showing low benefit and being a code nuisance) + - Django 2.2 shims removed + + - bug fixes: + - regression on proxy models fixed + - sliced querset support for mysql fixed + +- 0.1.7 + - add list type support for `update_fields` in signal handlers + +- 0.1.6 + - maintenace version with CI test dependencies changes: + - removed Python 3.6 + - removed Django 2.2 + - added Python 3.10 + - added Django 4.0 + - move dev environment to Python 3.10 and Django 3.2 + + Note that Django 2.2 will keep working until real incompatible code changes occur. + This may happen by any later release, thus treat 0.1.6 as last compatible version. + +- 0.1.5 + - fix error on model instance cloning +- 0.1.4 + - Django 3.2 support +- 0.1.3 + - better multi table inheritance support and test cases + - explicit docs for multi table inheritance +- 0.1.2 + - bugfix: o2o reverse name access + - add docs about model inheritance support +- 0.1.1 + - bugfix: add missing migration +- 0.1.0 + - fix recursion on empty queryset + - dependency expansion on M2M fields + - `m2m_changed` handler with filtering on m2m fields + - remove custom metaclass, introducing *Resolver* class + - new decorator `@precomputed` for custom save methods + - old *depends* syntax removed + - docs update +- 0.0.23: + - Bugfix: Fixing leaking computed fields in model inheritance. +- 0.0.22: + - Automatic dependency expansion on reverse relations. + - Example documentation. +- 0.0.21: + - Bugfix: Fixing undefined _batchsize for pickled map usage. +- 0.0.20 + - Use `bulk_update` for computed field updates. + - Allow custom update optimizations with *select_related* and *prefetch_related*. + - Respect computed field MRO in `compute`. + - Allow updates on local computed fields from `update_dependent` simplifying bulk actions on `ComputedFieldsModel`. +- 0.0.19 + - Better graph expansion on relation paths with support for *update_fields*. +- 0.0.18 + - New *depends* syntax deprecating the old one. + - MRO of local computed field methods implemented. +- 0.0.17 + - Dropped Python 2.7 and Django 1.11 support. + +%prep +%autosetup -n django-computedfields-0.2.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-django-computedfields -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.2-1 +- Package Spec generated |
