idlesign / django-siteprefs

Reusable app for Django introducing site preferences system
https://github.com/idlesign/django-siteprefs
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

implementing __int__() to allow casting PrefProxy to int #11

Closed yoandym closed 5 years ago

yoandym commented 9 years ago

Please accept my change based on:

If i from setttings import my_var and my my_var was originally an integer value i would like to use it without asking if it's a PrefProxy instance and calling .get_value() on it.

It would be better if could just do int(my_var)

If i'm just using django-siteprefs in the wrong way or there is a better solution just let me know,

thanks.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.12%) to 65.92% when pulling b9c479e1b2898529b583daaa27b8077001c7aed6 on yoandym:master into 669ed990a3a4238106b59590dcb4be0c2fcefeda on idlesign:master.

idlesign commented 9 years ago

The are two problems:

First one is that we still need to cast implicitly (this one may probably be cured with definition of other special methods for numeric types)

Second is that int and co must return an appropriate type else TypeError is raised, yet get_value() won't guarante that.

There probably is a better way to mimic int and other types. Need to think it over. If you have any ideas, you're welcome.

landscape-bot commented 9 years ago

Code Health Code quality remained the same when pulling b9c479e on yoandym:master into 669ed99 on idlesign:master.

idlesign commented 5 years ago

This and other type mimic methods are available in 0.8.1 Closing this.