Re: is not JSON serializable

2006-09-14 Thread Michael Samoylov

The real solution and patch: http://code.djangoproject.com/ticket/2727/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: is not JSON serializable

2006-09-13 Thread Michael Samoylov

The solution is:

return HttpResponse(simplejson.dumps("%s" % errors), 'text/javascript')


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Mac vs. PC for Django work.

2006-09-13 Thread Michael Samoylov

I use PC with linux. PC laptop is more than twice cheaper than Mac


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



is not JSON serializable

2006-09-13 Thread Michael Samoylov

Hi. I'm fighting with AJAX-based forms and dev process is stalled
because of such error:

Exception Type: TypeError
Exception Value:

'\xd0\x9e\xd0\xb1\xd1\x8f\xd0\xb7\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd0\xbd\xd0\xbe\xd0\xb5
\xd0\xbf\xd0\xbe\xd0\xbb\xd0\xb5.' is not JSON serializable
Exception Location:
/usr/lib/python2.4/site-packages/django/utils/simplejson/encoder.py in
default, line 258

My code:

def registerAjax(request):
"""Allows user to register with CAPTCHA via AJAX call"""
if request.POST:
manipulator = EmailManipulator(request)
redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
errors = manipulator.get_validation_errors(request.POST)
if not errors:
new_data = request.POST.copy()
try:
manipulator.save(new_data)
return HttpResponse(simplejson.dumps(('success',
redirect_to)), 'text/javascript')
except SMTPException, e:
return HttpResponse(simplejson.dumps(e),
'text/javascript')
else:
return HttpResponse(simplejson.dumps(errors),
'text/javascript')

But this code works perfect (returns json list of error messages)!

@login_required
def editInfoAjax(request):
if request.POST:
u = request.user
manipulator = Account.ChangeManipulator(u.id)
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
if not errors:
manipulator.do_html2python(new_data)
manipulator.save(new_data)
return HttpResponse(simplejson.dumps({'status':
'success'}), 'text/javascript')
else:
return HttpResponse(simplejson.dumps(errors),
'text/javascript')

I use django dev version from svn repository. I have LANGUAGE_CODE =
'ru' (have tryed to switch it to 'en' of course and got:

Exception Type: TypeError
Exception Value:'This field is required.' is not JSON serializable

Any ideas? Thanks for your possible help


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: file upload = simple DoS possibility

2006-08-30 Thread Michael Samoylov


Adrian Holovaty wrote:

> I'd recommend handling this at the Apache level. See the
> LimitRequestBody directive:
>
> http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

Thanks a lot!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



file upload = simple DoS possibility

2006-08-29 Thread Michael Samoylov

Hi all.

Is the any way to control upload process (max file size, etc.)? Great
framework but file upload can couse DoS.

For example:

class Account(models.Model):
user = models.OneToOneField(User)
birthday = models.DateField(blank=True, null=True)
icq = models.IntegerField(blank=True, null=True)
website = models.URLField(blank=True, null=True)
resume = models.TextField(blank=True, null=True)
userpic = PhotoField(upload_to='upload', width=100, height=100,
null=True, blank=True)

User can try to upload any size file and waste all server's cpu and
memory and you can imagine situation with hundreds of uploads! I've
patched django with
3581-streaming_uploads_and_uploadprogress_middleware_x_progress_id.diff
but I see no performance  improvements :(


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---