Re: SimpleLazyObject for request.user not correctly evaluated inside RequestContext

2013-09-12 Thread giovanni allegri
Hi German,
thanks for the reply. I apologize for the delay, but I didn't receive the 
notification :(
I've definetly improved the form workflow defining a validator inside my 
form. My validator check avoids the IntegrityError from Postgres.

Anyway, in case such an error happens, how should one manage it? How to 
reference the current transaction to roll it back?

giovanni

Il giorno sabato 7 settembre 2013 04:02:03 UTC+2, Germán Larraín ha scritto:
>
> What DB engine are you using? If it is PostgreSQL, you need to roll back 
> the transaction after a database error exception (e.g. IntegrityError).
>
> By the way, I think what you are doing is wrong. If the form data is 
> invalid, then you need to call . form_invalid
>
> On Friday, September 6, 2013 11:41:34 AM UTC-5, giovanni allegri wrote:
>>
>> I've opened a new thread, which relates to a previous 
>> onefrom me.
>> Digging into a wired behaviour in a FormView I've arrived to the 
>> following problem:
>>
>>  - In my "form_valid" method I need to manage exceptions situations.
>>  - In case of an exception I want to pass the response flow to an 
>> external method, in an other module
>>  - This external method returns a "render_to_response", in which I also 
>> pass a RequestContext instance built from the "FormView.request" object.
>>
>> Sometihng like this (I past a simplified version)
>>
>> class ProjectCreateView(FormView):
>>
>> def form_valid(self, form):
>> try:
>> 
>> except IntegrityError as e:
>> return render_error(_('A project with the same title already 
>> exists'),self.request)
>>
>> def render_error(msg,request):
>> #__dummy__ = request.user.is_authenticated()
>> data = {'error':{'msg':msg}}
>> return 
>> render_to_response('generic_error.html',data,context_instance=RequestContext(request))
>>
>> This causes a DatabaseError, because it crashes when it reaches the 
>> user.is_authenticated template variable. The crashed seems to be caused 
>> because of the SimpleLazyObject around the User instance. It seems it's not 
>> correctly setup, or whatelse... I don't know.
>>
>> This problem disappears if I use the __dummy__ variable in the previous 
>> snippet.
>> This call seems to make the SimpleLazyObject "prepared" for later calls 
>> (within the context processors).
>>
>> Why does this happen???
>> It never happens in other view and generic views I'm using in my project. 
>> What's wrong with the form view?
>>
>> Notice that 
>>
>> 1 - the same happens even if I set self.template_name and call 
>> self.render_to_response.
>> 2 - it doesn't happen during the normal form view workflow
>>
>> Giovanni
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: SimpleLazyObject for request.user not correctly evaluated inside RequestContext

2013-09-06 Thread Germán
What DB engine are you using? If it is PostgreSQL, you need to roll back 
the transaction after a database error exception (e.g. IntegrityError).

By the way, I think what you are doing is wrong. If the form data is 
invalid, then you need to call . form_invalid

On Friday, September 6, 2013 11:41:34 AM UTC-5, giovanni allegri wrote:
>
> I've opened a new thread, which relates to a previous 
> onefrom me.
> Digging into a wired behaviour in a FormView I've arrived to the following 
> problem:
>
>  - In my "form_valid" method I need to manage exceptions situations.
>  - In case of an exception I want to pass the response flow to an external 
> method, in an other module
>  - This external method returns a "render_to_response", in which I also 
> pass a RequestContext instance built from the "FormView.request" object.
>
> Sometihng like this (I past a simplified version)
>
> class ProjectCreateView(FormView):
>
> def form_valid(self, form):
> try:
> 
> except IntegrityError as e:
> return render_error(_('A project with the same title already 
> exists'),self.request)
>
> def render_error(msg,request):
> #__dummy__ = request.user.is_authenticated()
> data = {'error':{'msg':msg}}
> return 
> render_to_response('generic_error.html',data,context_instance=RequestContext(request))
>
> This causes a DatabaseError, because it crashes when it reaches the 
> user.is_authenticated template variable. The crashed seems to be caused 
> because of the SimpleLazyObject around the User instance. It seems it's not 
> correctly setup, or whatelse... I don't know.
>
> This problem disappears if I use the __dummy__ variable in the previous 
> snippet.
> This call seems to make the SimpleLazyObject "prepared" for later calls 
> (within the context processors).
>
> Why does this happen???
> It never happens in other view and generic views I'm using in my project. 
> What's wrong with the form view?
>
> Notice that 
>
> 1 - the same happens even if I set self.template_name and call 
> self.render_to_response.
> 2 - it doesn't happen during the normal form view workflow
>
> Giovanni
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: 'SimpleLazyObject'

2013-07-13 Thread Kakar Arunachal Service
Yes, you are right.


On Sat, Jul 13, 2013 at 7:07 PM, Victor Rocha  wrote:

> This is a wild guess but I do not see the login_required decorator on your
> view. I think you are getting this error because you are trying to save an
> Bookmark object passing an anonymous user as one of your arguments. An
> anonymous user is a SimpleLazyObject; it is a user but there is no
> reference to it on your databases. The Bookmark foreign key expects to
> point to user instance on the users table.
>
> Thank you,
> Victor Rocha
> www.RochApps.com
>
>
>
> On Friday, July 12, 2013 2:45:00 PM UTC-4, Kakar wrote:
>>
>> I've got a TypeError:
>>
>> int() argument must be a string or a number, not 'SimpleLazyObject'
>>
>>
>> Here's my view:
>>
>> def bookmark_save_page(request):
>> if request.method == 'POST':
>> form = BookmarkSaveForm(request.POST)
>> if form.is_valid():
>> # Create or get link.
>> link, dummy = Link.objects.get_or_create(
>> url=form.cleaned_data['url']
>> )
>> # Create or get bookmarks.
>> bookmark, created = Bookmark.objects.get_or_**create(
>> user = request.user,
>> link = link
>> )
>> # Update bookmark title.
>> bookmark.title = form.cleaned_data['title']
>> # If the bookmark is being updated, clear old tag list.
>> if not created:
>> bookmark.tag_set.clear()
>> # Create new tag list.
>> tag_names = form.cleaned_data['tags'].**split()
>> for tag_name in tag_names:
>> tag, dummy = Tag.objects.get_or_create(**name=tag_name)
>> bookmark.tag_set.add(tag)
>> # Save bookmark to database.
>> bookmark.save()
>> return HttpResponseRedirect(
>> '/user/%s/' %request.user.username
>> )
>> else:
>> form = BookmarkSaveForm()
>>
>> variables = RequestContext(request, {'form': form})
>> return render_to_response('bookmark_**save.html',variables)
>>
>> I really don't know what's going on here. Please guide me.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'SimpleLazyObject'

2013-07-13 Thread Victor Rocha
This is a wild guess but I do not see the login_required decorator on your 
view. I think you are getting this error because you are trying to save an 
Bookmark object passing an anonymous user as one of your arguments. An 
anonymous user is a SimpleLazyObject; it is a user but there is no 
reference to it on your databases. The Bookmark foreign key expects to 
point to user instance on the users table.

Thank you,
Victor Rocha
www.RochApps.com
 

On Friday, July 12, 2013 2:45:00 PM UTC-4, Kakar wrote:
>
> I've got a TypeError:
>
> int() argument must be a string or a number, not 'SimpleLazyObject'
>
>
> Here's my view:
>
> def bookmark_save_page(request):
> if request.method == 'POST':
> form = BookmarkSaveForm(request.POST)
> if form.is_valid():
> # Create or get link.
> link, dummy = Link.objects.get_or_create(
> url=form.cleaned_data['url']
> )
> # Create or get bookmarks.
> bookmark, created = Bookmark.objects.get_or_create(
> user = request.user,
> link = link
> )
> # Update bookmark title.
> bookmark.title = form.cleaned_data['title']
> # If the bookmark is being updated, clear old tag list.
> if not created:
> bookmark.tag_set.clear()
> # Create new tag list.
> tag_names = form.cleaned_data['tags'].split()
> for tag_name in tag_names:
> tag, dummy = Tag.objects.get_or_create(name=tag_name)
> bookmark.tag_set.add(tag)
> # Save bookmark to database.
> bookmark.save()
> return HttpResponseRedirect(
> '/user/%s/' %request.user.username
> )
> else:
> form = BookmarkSaveForm()
>
> variables = RequestContext(request, {'form': form})
> return render_to_response('bookmark_save.html',variables)
>
> I really don't know what's going on here. Please guide me.
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'SimpleLazyObject'

2013-07-13 Thread Kakar Arunachal Service
No, it wont do, it loads another error. But my problem is solved. I just
needed to log in. Thanks anyway.


On Sat, Jul 13, 2013 at 10:42 AM, Babatunde Akinyanmi
<tundeba...@gmail.com>wrote:

> How about changing this:
>
> Bookmark.objects.get_or_create(
> user = request.user,
> link = link
> )
>
> To this:
> Bookmark.objects.get_or_create(
> user = request.user.id,
> link = link
> )
>
> Sent from my Windows Phone
> --
> From: Kakar Arunachal Service
> Sent: 7/12/2013 8:46 PM
> To: django-users@googlegroups.com
> Subject: Re: 'SimpleLazyObject'
>
> Here's the traceback info:
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://localhost:8000/save/
>
> Django Version: 1.5.1
> Python Version: 2.7.5
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'bookmarks')
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
>
> Traceback:
> File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   115. response = callback(request,
> *callback_args, **callback_kwargs)
> File "C:\Users\Kakar\web\django_bookmarks\bookmarks\views.py" in
> bookmark_save_page
>   63. link = link
> File "C:\Python27\lib\site-packages\django\db\models\manager.py" in
> get_or_create
>   146. return self.get_query_set().get_or_create(**kwargs)
> File "C:\Python27\lib\site-packages\django\db\models\query.py" in
> get_or_create
>   470. return self.get(**lookup), False
> File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
>   379. clone = self.filter(*args, **kwargs)
> File "C:\Python27\lib\site-packages\django\db\models\query.py" in filter
>   655. return self._filter_or_exclude(False, *args, **kwargs)
> File "C:\Python27\lib\site-packages\django\db\models\query.py" in
> _filter_or_exclude
>   673. clone.query.add_q(Q(*args, **kwargs))
> File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_q
>   1266. can_reuse=used_aliases,
> force_having=force_having)
> File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in
> add_filter
>   1197. connector)
> File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in add
>   71. value = obj.prepare(lookup_type, value)
> File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in
> prepare
>   339. return self.field.get_prep_lookup(lookup_type, value)
> File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
> get_prep_lookup
>   143. return self._pk_trace(value, 'get_prep_lookup',
> lookup_type)
> File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
> _pk_trace
>   216. v = getattr(field, prep_func)(lookup_type, v, **kwargs)
> File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py"
> in get_prep_lookup
>   322. return self.get_prep_value(value)
> File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py"
> in get_prep_value
>   555. return int(value)
>
> Exception Type: TypeError at /save/
> Exception Value: int() argument must be a string or a number, not
> 'SimpleLazyObject'
>
> Please help.
>
>
> On Sat, Jul 13, 2013 at 12:30 AM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> What does the trace information say in your browser (or shell)? The trace
>> should be giving more information - such as, in which line number of which
>> file is the error showing up?.
>>
>>
>> On Fri, Jul 12, 2013 at 8:45 PM, Kakar Arunachal Service <
>> kakararunachalserv...@gmail.com> wrote:
>>
>>> I've got a TypeError:
>>>
>>> int() argument must be a string or a number, not 'SimpleLazyObject'
>>>
>>>
>>> Here's my view:
>>>
>>> def bookmark_save_page(request):
>>> if request.method == 'POST':
>>> fo

RE: 'SimpleLazyObject'

2013-07-12 Thread Babatunde Akinyanmi
How about changing this:
Bookmark.objects.get_or_create(
user = request.user,
link = link
)

To this:
Bookmark.objects.get_or_create(
user = request.user.id,
link = link
)

Sent from my Windows Phone
--
From: Kakar Arunachal Service
Sent: 7/12/2013 8:46 PM
To: django-users@googlegroups.com
Subject: Re: 'SimpleLazyObject'

Here's the traceback info:

Environment:


Request Method: POST
Request URL: http://localhost:8000/save/

Django Version: 1.5.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'bookmarks')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  115. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Users\Kakar\web\django_bookmarks\bookmarks\views.py" in
bookmark_save_page
  63. link = link
File "C:\Python27\lib\site-packages\django\db\models\manager.py" in
get_or_create
  146. return self.get_query_set().get_or_create(**kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in
get_or_create
  470. return self.get(**lookup), False
File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
  379. clone = self.filter(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in filter
  655. return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in
_filter_or_exclude
  673. clone.query.add_q(Q(*args, **kwargs))
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_q
  1266. can_reuse=used_aliases,
force_having=force_having)
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in
add_filter
  1197. connector)
File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in add
  71. value = obj.prepare(lookup_type, value)
File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in
prepare
  339. return self.field.get_prep_lookup(lookup_type, value)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
get_prep_lookup
  143. return self._pk_trace(value, 'get_prep_lookup',
lookup_type)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
_pk_trace
  216. v = getattr(field, prep_func)(lookup_type, v, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in
get_prep_lookup
  322. return self.get_prep_value(value)
File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in
get_prep_value
  555. return int(value)

Exception Type: TypeError at /save/
Exception Value: int() argument must be a string or a number, not
'SimpleLazyObject'

Please help.


On Sat, Jul 13, 2013 at 12:30 AM, Sithembewena Lloyd Dube <zebr...@gmail.com
> wrote:

> What does the trace information say in your browser (or shell)? The trace
> should be giving more information - such as, in which line number of which
> file is the error showing up?.
>
>
> On Fri, Jul 12, 2013 at 8:45 PM, Kakar Arunachal Service <
> kakararunachalserv...@gmail.com> wrote:
>
>> I've got a TypeError:
>>
>> int() argument must be a string or a number, not 'SimpleLazyObject'
>>
>>
>> Here's my view:
>>
>> def bookmark_save_page(request):
>> if request.method == 'POST':
>> form = BookmarkSaveForm(request.POST)
>> if form.is_valid():
>> # Create or get link.
>> link, dummy = Link.objects.get_or_create(
>> url=form.cleaned_data['url']
>> )
>> # Create or get bookmarks.
>> bookmark, created = Bookmark.objects.get_or_create(
>> user = request.user,
>> link = link
>> )
>> # Update bookmark title.
>> bookmark.title = form.cleaned_data['title']
>> # If the bookmark is being updated, clear old tag list.
>> if not created:
>> bookmark.tag_set.cle

Re: 'SimpleLazyObject'

2013-07-12 Thread Kakar Arunachal Service
Here's the traceback info:

Environment:


Request Method: POST
Request URL: http://localhost:8000/save/

Django Version: 1.5.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'bookmarks')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  115. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Users\Kakar\web\django_bookmarks\bookmarks\views.py" in
bookmark_save_page
  63. link = link
File "C:\Python27\lib\site-packages\django\db\models\manager.py" in
get_or_create
  146. return self.get_query_set().get_or_create(**kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in
get_or_create
  470. return self.get(**lookup), False
File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
  379. clone = self.filter(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in filter
  655. return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in
_filter_or_exclude
  673. clone.query.add_q(Q(*args, **kwargs))
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_q
  1266. can_reuse=used_aliases,
force_having=force_having)
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in
add_filter
  1197. connector)
File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in add
  71. value = obj.prepare(lookup_type, value)
File "C:\Python27\lib\site-packages\django\db\models\sql\where.py" in
prepare
  339. return self.field.get_prep_lookup(lookup_type, value)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
get_prep_lookup
  143. return self._pk_trace(value, 'get_prep_lookup',
lookup_type)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in
_pk_trace
  216. v = getattr(field, prep_func)(lookup_type, v, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in
get_prep_lookup
  322. return self.get_prep_value(value)
File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in
get_prep_value
  555. return int(value)

Exception Type: TypeError at /save/
Exception Value: int() argument must be a string or a number, not
'SimpleLazyObject'

Please help.


On Sat, Jul 13, 2013 at 12:30 AM, Sithembewena Lloyd Dube  wrote:

> What does the trace information say in your browser (or shell)? The trace
> should be giving more information - such as, in which line number of which
> file is the error showing up?.
>
>
> On Fri, Jul 12, 2013 at 8:45 PM, Kakar Arunachal Service <
> kakararunachalserv...@gmail.com> wrote:
>
>> I've got a TypeError:
>>
>> int() argument must be a string or a number, not 'SimpleLazyObject'
>>
>>
>> Here's my view:
>>
>> def bookmark_save_page(request):
>> if request.method == 'POST':
>> form = BookmarkSaveForm(request.POST)
>> if form.is_valid():
>> # Create or get link.
>> link, dummy = Link.objects.get_or_create(
>> url=form.cleaned_data['url']
>> )
>> # Create or get bookmarks.
>> bookmark, created = Bookmark.objects.get_or_create(
>> user = request.user,
>> link = link
>> )
>> # Update bookmark title.
>> bookmark.title = form.cleaned_data['title']
>> # If the bookmark is being updated, clear old tag list.
>> if not created:
>> bookmark.tag_set.clear()
>> # Create new tag list.
>> tag_names = form.cleaned_data['tags'].split()
>> for tag_name in tag_names:
>> tag, dummy = Tag.objects.get_or_create(name=tag_name)
>> bookmark.tag_set.add(tag)
>> # Save bookmark to database.
>> bookmark.save()
>> return HttpResponseRedirect(
>> '/user/%s/' %request.user.username
>> )
>> else:
>> form = BookmarkSaveForm()
>>
>> variables = RequestContext(request, {'form': form})
>> return render_to_response('bookmark_save.html',variables)
>>
>> I really don't know what's going on here. Please guide me.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django 

Re: 'SimpleLazyObject'

2013-07-12 Thread Sithembewena Lloyd Dube
What does the trace information say in your browser (or shell)? The trace
should be giving more information - such as, in which line number of which
file is the error showing up?.


On Fri, Jul 12, 2013 at 8:45 PM, Kakar Arunachal Service <
kakararunachalserv...@gmail.com> wrote:

> I've got a TypeError:
>
> int() argument must be a string or a number, not 'SimpleLazyObject'
>
>
> Here's my view:
>
> def bookmark_save_page(request):
> if request.method == 'POST':
> form = BookmarkSaveForm(request.POST)
> if form.is_valid():
> # Create or get link.
> link, dummy = Link.objects.get_or_create(
> url=form.cleaned_data['url']
> )
> # Create or get bookmarks.
> bookmark, created = Bookmark.objects.get_or_create(
> user = request.user,
> link = link
> )
> # Update bookmark title.
> bookmark.title = form.cleaned_data['title']
> # If the bookmark is being updated, clear old tag list.
> if not created:
> bookmark.tag_set.clear()
> # Create new tag list.
> tag_names = form.cleaned_data['tags'].split()
> for tag_name in tag_names:
> tag, dummy = Tag.objects.get_or_create(name=tag_name)
> bookmark.tag_set.add(tag)
> # Save bookmark to database.
> bookmark.save()
> return HttpResponseRedirect(
> '/user/%s/' %request.user.username
> )
> else:
> form = BookmarkSaveForm()
>
> variables = RequestContext(request, {'form': form})
> return render_to_response('bookmark_save.html',variables)
>
> I really don't know what's going on here. Please guide me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: simplelazyobject breaks code

2009-10-19 Thread Eric Holscher

Went ahead and filed a ticket for this. If you would chime in with
your example it probably wouldn't hurt, but I will link to this thread
as well.

http://code.djangoproject.com/ticket/12060

Cheers,
Eric
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---