Comments (12)
Hi Eric,
Good catch! Great to see you added tests to verify your fix. I will pull your changes and release a new version.
Regards,
Joost
from django-analytical.
I merged your branch, but decided not to release a new version for this fix. It was not a user-visible bug, so let's not bother them just yet.
Thanks again!
- Joost
from django-analytical.
Sounds good.
from django-analytical.
Strange. I just tested my setting-deleted
branch on linux and now I'm getting "maximum recursion depth errors." Hold off on cutting a release until I can figure this out. You didn't get any errors, right?
It's always something :)
from django-analytical.
edavis/django-analytical@master...setting-deleted
As best I can tell, copy.copy
was trying to getattr
self.default_settings
until it hit the maximum recursion depth. This fix overrides __getattr__
so self.default_settings
gets returned as normal.
I have a suspicion it's a Python 2.6 vs. 2.7 thing but won't be able to test it until later.
But anyway, you can find two commits in my setting-deleted
branch. Let me know if you catch anything else.
UPDATE: I can confirm it was a 2.6 vs. 2.7 thing. Testing against both versions -- with tox -- shows everything in setting-deleted
passing as intended.
from django-analytical.
Hi Eric,
Thanks for the heads-up. I did not encounter this problem, but I have
never felt really comfortable using a system 'copy' function (maybe a
hesitation left over from my Java days). The new code looks good in
any case.
There is just one problem with the test code when I run "python2.6
setup.py test": the structure "with self.assertRaises" does not work
on Python 2.6. (From the docs: "Changed in version 2.7: Added the
ability to use assertRaises() as a context manager.")
I now also understand why my original code did not work: a class
descriptor is set on a class, not an instance.
Regards,
Joost
2011/9/17 Eric Davis
[email protected]:
edavis/django-analytical@master...setting-deleted
As best I can tell,
copy.copy
was trying togetattr
self.default_settings
until it hit the maximum recursion depth. This fix short-circuits it sodefault_settings
gets returned.I have a suspicion it's a Python 2.6 vs. 2.7 thing but won't be able to test it until later.
But anyway, you can find two commits in my
setting-deleted
branch. Let me know if you catch anything else.Reply to this email directly or view it on GitHub:
#8 (comment)
Joost Cassee
http://joost.cassee.net
from django-analytical.
Hi Joost,
Yeah, I'm not a huge fan of using copy
like that but it's the only way I've found to create a completely isolated instance of settings._wrapped
which is needed to "add back" deleted tests.
Good catch on the assertRaises context manager problem. I've changed all assertRaises context managers into "regular" method calls. Turns out you can use it as a context manager with Python 2.6 and Django 1.3 because Django 1.3 bundles unittest2 which includes it as a context manager. But it does fail with Python 2.6 and Django 1.2.
To be on the safe side, I also check for assertRaisesRegexp
and use it if it exists, but use plain assertRaises
if it doesn't.
To help manage all of these versions, I also added a tox.ini
config file for use with tox. With it I test against:
- Python 2.6 and Django 1.2
- Python 2.7 and Django 1.2
- Python 2.6 and Django 1.3
- Python 2.7 and Django 1.3
So if you could pull from edavis/django-analytical@master...setting-deleted again and test it out, I think this should do it.
from django-analytical.
Hi Eric,
Using tox is a good idea. I don't understand one thing, though: why not just use the Python 2.6 way of doing assertRaises? That also works on 2.7, right?
Regards,
Joost
from django-analytical.
I assume you mean in the test_get_required_setting
method? If so, I wanted to add a regression test to make sure get_required_setting
fails on getattr
rather than the regexp check.
So if they have assertRaisesRegexp
I use it but if they don't I fallback to a generic assertRaises
.
Though, now that you mention it, if they're using Python 2.6 it won't be much of a regression test because AnalyticalException
gets raised for both missing settings and regexp check failures... kind of defeating the purpose.
Maybe subclass AnalyticalException
into AnalyticalMissingSetting
and AnalyticalIncorrectSettingRegex
and use assertRaises
against that instead of checking the exception message. Could be overkill, though.
What do you think?
from django-analytical.
Hi Eric,
Yes, I meant specifically these lines:
# only available in python >= 2.7
if hasattr(self, 'assertRaisesRegexp'):
with self.assertRaisesRegexp(AnalyticalException, "^USER_ID
setting: not found$"):
user_id = get_required_setting("USER_ID", "\d+", "invalid USER_ID")
else:
self.assertRaises(AnalyticalException,
get_required_setting, "USER_ID", "\d+",
"invalid USER_ID")
I understand what you are doing now. I think it is fine as it is.
Subclassing AnalyticalException feels like overkill at the moment, and
I will be testing django-analytical on Python 2.7 anyway. The
conditional is just to make it pass on Python 2.6.
Looks like this issue can be closed for real, now, don't you think?
Regards,
Joost
2011/9/18 Eric Davis
[email protected]:
I assume you mean in the
test_get_required_setting
method? If so, I wanted to add a regression test to make sureget_required_setting
fails ongetattr
rather than the regexp check.So if they have
assertRaisesRegexp
I use it but if they don't I fallback to a genericassertRaises
.Though, now that you mention it, if they're using Python 2.6 it won't be much of a regression test because
AnalyticalException
gets raised for both missing settings and regexp check failures... kind of defeating the purpose.Maybe subclass
AnalyticalException
intoAnalyticalMissingSetting
andAnalyticalIncorrectSettingRegex
and useassertRaises
against that instead of checking the exception message. Could be overkill, though.What do you think?
Reply to this email directly or view it on GitHub:
#8 (comment)
Joost Cassee
http://joost.cassee.net
from django-analytical.
Yeah, I think this should about do it. Thanks for your help and feedback.
from django-analytical.
Hah! No, thank you for contributing! :-)
from django-analytical.
Related Issues (20)
- Gitter Sidecar integration
- New release and follow-up tasks HOT 1
- Clickmap link in README links to spammy website HOT 2
- Support for Google Analytics 4 tags HOT 9
- Default value for SECURE_REFERRER_POLICY in Django 3.1 breaks Clicky HOT 2
- how to set enhanced eCommerce in google analytics HOT 2
- how to set identity_func HOT 3
- Ability to push custom commands to Matomo
- Respecting Consent ( Possible fix for #141 ) HOT 6
- Ability to pass FACEBOOK_PIXEL_ID directly in template tag HOT 1
- GA not tracking logged in users, GTAG user_id seems to require a different syntax now HOT 4
- support for python 3.10 HOT 1
- Rename default branch (master ➜ main) HOT 1
- Support for Posthog HOT 1
- Allow to set a custom location for google analytics js - support for proxy HOT 2
- Matomo ReDoS vulnerability (regex denial of service)
- Latest docs must build from `main` (not `master`) HOT 3
- basic mixpanel tracking HOT 4
- Setting google_analytics_gtag_identity does not work HOT 3
- Usage in Docker HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-analytical.