| Conditions | 6 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | 1 | from django.db import transaction |
|
| 10 | 1 | def save(self, *args, **kwargs): |
|
| 11 | """Saves this model instance to the database.""" |
||
| 12 | |||
| 13 | 1 | max_retries = getattr( |
|
| 14 | settings, |
||
| 15 | 'LOCALIZED_FIELDS_MAX_RETRIES', |
||
| 16 | 100 |
||
| 17 | ) |
||
| 18 | |||
| 19 | 1 | if not hasattr(self, 'retries'): |
|
| 20 | 1 | self.retries = 0 |
|
| 21 | |||
| 22 | 1 | with transaction.atomic(): |
|
| 23 | 1 | try: |
|
| 24 | 1 | return super().save(*args, **kwargs) |
|
| 25 | 1 | except IntegrityError as ex: |
|
| 26 | # this is as retarded as it looks, there's no |
||
| 27 | # way we can put the retry logic inside the slug |
||
| 28 | # field class... we can also not only catch exceptions |
||
| 29 | # that apply to slug fields... so yea.. this is as |
||
| 30 | # retarded as it gets... i am sorry :( |
||
| 31 | 1 | if 'slug' not in str(ex): |
|
| 32 | 1 | raise ex |
|
| 33 | |||
| 34 | 1 | if self.retries >= max_retries: |
|
| 35 | 1 | raise ex |
|
| 36 | |||
| 37 | 1 | self.retries += 1 |
|
| 38 | return self.save() |
||
| 39 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.