I've searched and searched and the usual response seems to be "set debug and template_debug to True".
However.
I'm generating mails for notification purposes and I have a small class that handles the template rendering as well are the creation of the EmailMessage object afterwards(for DRY reasons in regards to html content etc).
The thing is that I would like to log any rendering errors so that I can analyze them elsewhere. There's a lot of different mails to be sent out with a lot of different variables based on dates, memberships, permissions etc. And I would like to know if a variable was missing while rendering..
Right now I have to regularly check Mandrill (where they store the content of mails for up to 30 days) so see if all mails have all the relevant data..
I know I could go the unit test way - but that seems a bit much when all I wan't to do is to catch any errors unobtrusively.
What do you think? Am I way off in how this could be handled??
Related
I'm making a website right now and need to use django-tracking2 for analytics. Everything works but I would like to allow users to opt out and I haven't seen any options for that. I was thinking modifying the middleware portion may work but honestly, I don't know how to go about that yet since I haven't written middleware before.
I tried writing a script to check a cookie called no_track and if it wasn't set, I would set it to false for default tracking and if they reject, it sets no_track to True but I had no idea where to implement it (other than the middle ware, when I tried that the server told me to contact the administrator). I was thinking maybe I could use signals to prevent the user being tracked but then that would slow down the webpage since it would have to deal with preventing a new Visitor instance on each page (because it would likely keep making new instances since it would seem like a new user). Could I subclass the Visitor class and modify __init__ to do a check for the cookie and either let it save or don't.
Thanks for any answers, if I find a solution I'll edit the post or post and accept the answer just in case someone else needs this.
I made a function in my tools file (holds all functions used throughout the project to make my life easier) to get and set a session key. Inside the VisitorTrackingMiddleware I used the function _should_track() and placed a check that looks for the session key (after _should_track() checks that sessions is installed and before all other checks), with the check_session() function in my tools file, if it doesn't exist, the function creates it with the default of True (Track the user until they accept or reject) and returns an HttpResponse (left over from trying the cookie method).
When I used the cookie method, the firefox console said the cookie will expire so I just switched to sessions another reason is that django-tracking2 runs on it.
It seems to work very well and it didn't have a very large impact on load times, every time a request is made, that function runs and my debug tells me if it's tracking me or not and all the buttons work through AJAX. I want to run some tests to see if this does indeed work and if so, maybe I'll submit a pull request to django-tracking2 just in case someone else wants to use it.
A Big advantage to this is that you can allow users to change their minds if they want or you can reprompt at user sign up depending on if they accepted or not. with the way check_session() is set up, I can use it in template tags and class methods as well.
When DEBUG = False I know errors do get mailed to ADMINs, but I would like to see the errors on the screen if I am logged in as superuser.
Is there a way to trigger it to show the debug screen instead of the 500.html for public users?
As mentioned Sentry, or another service actually is a better choice. But for the case that you really want it your way, you would need a custom 500 handler and in there use django.views.debug.technical_500_response
https://docs.djangoproject.com/en/dev/_modules/django/views/debug/
There's no real documentation on this - except for a simple comment -, since it's a method that shouldn't really be used externally. But you're free to use it:
urls.py
urls.handler500 = views.handler500
views.py
def handler500(request):
if request.user.is_superuser():
return technical_500_response(some, params, dontaskme)
else:
return render(request, "500.html")
If you're not happy with the information generated in the emails, you're better off using something like Sentry to track what happens on your site so that you can see what users come up against.
It uses standard python logging so you can set what level sentry is triggered by, and have various messages in your app to tell you pieces of information, and it automatically picks up the warnings/errors that might occur. It gives you all the kind of information you get from the standard debug error page with the stacktrace, context information etc.
I am using Django Postman for the intercommunication between two user of my django website .
But when i am sending a message to another user .It is not delivered to the recepient .
I shows me as sent message .In http://127.0.0.1:8000/messages/sent
Here is settings.py setting
############################# Django postman
POSTMAN_AUTO_MODERATE_AS = True
POSTMAN_SHOW_USER_AS = True
POSTMAN_NOTIFIER_APP = True
###################################
And once the messages is sent it is storing properly in the Dtabase but it is not appearing to the recepient inbox.
Please tell me what might I am doing wrong here .
I encountered seemingly identical problem, in my case cause was default moderation.
To better diagnose if this is the case, you can:
check your 'invisible' messages in database, for example using phpmyadmin. If there's 'p' as m moderation_status or anything suspicious under moderation_... columns, this track is probably good;
dig into code: locate postman/models.py and experiment with class MessageManager, method inbox (since other message directories are fine, this one is suspicious). Any of filters there might be cause of your problem - for me it was obviously 'moderation_status'. Even if your case is different, this is good starting point for further debugging.
Use case: let's assume moderation issues
I see that you have
POSTMAN_AUTO_MODERATE_AS = True
set, but perhaps you have left moderation function somewhere, or something gets overwritten in your configuration? Postman's Quick Start Guide indicates that both are necessary:
To disable the moderation feature (no control, no filter):
Set this option to True
Do not provide any auto-moderation functions
I'd suggest removing all other postman specific options from your settings.py, leaving only POSTMAN_AUTO_MODERATE_AS = True and check if there are any utility functions that could potentially interfere with Message objects.
For further reference, more information about moderation is here: https://bitbucket.org/psam/django-postman/wiki/Moderation
I am currently trying to develop a web activity that a client would like to track via their Learning Management System. Their LMS uses the AICC standard (HACP binding), and they keep the actual learning objects on a separate content repository.
Right now I'm struggling with the types of communication between the LMS and the "course" given that they sit on two different servers. I'm able to retreive the sessionId and the aicc_url from the URL string when the course launches, and I can successfully post values to the aicc_url on the LMS.
The difficulty is that I can not read and parse the return response from the LMS (which is formatted as plain text). AICC stipulates that the course start with posting a "getParam" command to the aicc_url with the session id in order to retrieve information like completion status, bookmarking information from previous sessions, user ID information, etc, all of which I need.
I have tried three different approaches so far:
1 - I started with using jQuery (1.7) and AJAX, which is how I would typically go about a same-server implementation. This returned a "no transport" error on the XMLHttpRequest. After some forum reading, I tried making sure that the ajax call's crossdomain property was set to true, as well as a recommendation to insert $.support.cors = true above the ajax call, neither of which helped.
2 & 3 - I tried using an oldschool frameset with a form in a bottom frame which would submit and refresh with the returned text from the LMS and then reading that via javascript; and then a variation upon that using an iFrame as a target of an actual form with an onload handler to read and parse the contents. Both of these approaches worked in a same-server environment, but fail in the cross-domain environment.
I'm told that all the other courses running off the content repository bookmark as well as track completion, so obviously it is possible to read the return values from the LMS somehow; AICC is pitched frequently as working in cross-server scenarios, so I'm thinking there must be a frequently-used method to doing this in the AICC structure that I am overlooking. My forum searches so far haven't turned up anything that's gotten me much further, so if anyone has any experience in cross-domain AICC implementations I could certainly use recommendations!
The only idea I have left is to try setting up a PHP "relay" form on the same server as the course, and having the front-end page send values to that, and using the PHP to submit those to the LMS, and relay the return text from the LMS to the front-end iframe or ajax call so that it would be perceived as being within the same domain.... I'm not sure if there's a way to solve the issue without going server-side. It seems likely there must be a common solution to this within AICC.
Thanks in advance!
Edits and updates:
For anyone encountering similar problems, I found a few resources that may help explain the problem as well as some alternate solutions.
The first is specific to Plateau, a big player in the LMS industry that was acquired by Successfactors. It's some documentation that provide on setting up a proxy to handle cross-domain content:
http://content.plateausystems.com/ContentIntegration/content/support_files/Cross-domain_Proxlet_Installation.pdf
The second I found was a slide presentation from Successfactors that highlights the challenge of cross-domain content, and illustrates so back-end ideas for resolving it; including the use of reverse proxies. The relevant parts start around slide 21-22 (page 11 in the PDF).
http://www.successfactors.com/static/docs/successconnect/sf/successfactors-content-integration-turley.pdf
Hope that helps anyone else out there trying to resolve the same issues!
The answer in this post may lead you in the right direction:
Best Practice: Legitimate Cross-Site Scripting
I think you are on the right track with setting up a PHP "relay." I think this is similar to choice #1 in the answer from the other post and seems to make most sense with what you described in your question.
On very rate occasions, my error log is showing the following error:
"You specified a Fuseaction of registrationaction#close which is not defined in Circuit public."
The full link is:"http://myUrl/index.cfm?do=public.registrationAction#close"
As you can see, the has merely points to an anchor (close) on the page.
This code is working 99% of the time, but on the odd occasion, Coldfusion / Fusebox throws this error out.
Why is this happening?
Could it be related to the device accessing my page somehow? Like a cell phone or Apple product that for some reason does handle hashes the way I am expecting it to?
Could it be javascript / JQuery being disabled?
Any guidance would be appreciated
Thanks
I used to see stuff like that. Older versions of Internet Explorer were not handling the hashtag properly when there were URL parameters. The best solution I could come up with was kludgey at best, but basically it forced the anchor tag to separate from the URL parameter.
http://myUrl/index.cfm?do=public.registrationAction&#close
I'm not sure there is a simple answer to this. We get odd exceptions all the time on our site for all sorts of reasons. Sometimes it's people not using the site the way you expect and sometimes it stuff like you mention such as user-agent edge cases etc.
Basically you need to start to gather evidence and see what comes up that's unusual with these requests.
So to start: do you catch exceptions in you application? If so dumping all scopes (CGI/CLIENT/FORM/URL/SESSION) in an email along with the full exception and emailing them to a custom emails address (such as errors#yourdomain.com) will give you a reference you can square up to your error times and this might give you a hint as to the real issue.
Hope that helps some!