Re: signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Robocop

Holy crap it is!  Thanks for the idea, i'm going to do a lil testing
and verify everything works.  Thanks again!

On Feb 9, 10:21 am, Jake Elliott  wrote:
> hi robocop -
>
> is it enough to add the '**kwargs' syntax to your receiver function?
> or is that already present?
>
> like:
>
> def _save(self, **kwargs):
>     ...
>
> and
>
> def delete(**kwargs):
>     ...
>
> -jake
>
> On Mon, Feb 9, 2009 at 12:15 PM, Robocop  wrote:
>
> > Hello,
> > I've recently been porting many projects to 1.0, but have hit a snag
> > with the current one.  I'm looking at an old project that uses nesh's
> > django utils (mainly just the thumbnail image field model), and have
> > been slowly porting the project (and by extension nesh's code) to
> > 1.0.  Now i have read the documentation on signals, as well as the
> > porting to 1.0 guide's signals section, but because i have not really
> > used signals in my projects, i'm a little unsure what exactly is being
> > called for by this error, and thought someone here may be of some
> > help.
>
> > The original code looked like:
>
> >    def contribute_to_class(self, cls, name):
> >        super(ImageWithThumbnailField, self).contribute_to_class(cls,
> > name)
> >        dispatcher.connect(_delete, signals.post_delete, sender=cls)
> >        dispatcher.connect(self._save, signals.pre_save, sender=cls)
>
> > My poor attempt at porting:
>
> >      def contribute_to_class(self, cls, name):
> >        super(ImageWithThumbnailField, self).contribute_to_class(cls,
> > name)
> >        signals.post_delete.connect(_delete, sender=cls)
> >        signals.pre_save.connect(self._save, sender=cls)
>
> > and the resultant error:
>
> > line 45, in contribute_to_class
> >    signals.post_delete.connect(_delete, sender=cls)
> >  File "/usr/lib/python2.4/site-packages/django/dispatch/
> > dispatcher.py", line 84, in connect
> >    assert argspec[2] is not None, \
> > AssertionError: Signal receivers must accept keyword arguments
> > (**kwargs).
>
> > now my understanding of the syntax is that _delete and self._save
> > would be keyword arguments, but apparently i am incorrect.  Any help
> > or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Jake Elliott

hi robocop -

is it enough to add the '**kwargs' syntax to your receiver function?
or is that already present?

like:

def _save(self, **kwargs):
...

and

def delete(**kwargs):
...

-jake

On Mon, Feb 9, 2009 at 12:15 PM, Robocop  wrote:
>
> Hello,
> I've recently been porting many projects to 1.0, but have hit a snag
> with the current one.  I'm looking at an old project that uses nesh's
> django utils (mainly just the thumbnail image field model), and have
> been slowly porting the project (and by extension nesh's code) to
> 1.0.  Now i have read the documentation on signals, as well as the
> porting to 1.0 guide's signals section, but because i have not really
> used signals in my projects, i'm a little unsure what exactly is being
> called for by this error, and thought someone here may be of some
> help.
>
> The original code looked like:
>
>def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>dispatcher.connect(_delete, signals.post_delete, sender=cls)
>dispatcher.connect(self._save, signals.pre_save, sender=cls)
>
> My poor attempt at porting:
>
>  def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>signals.post_delete.connect(_delete, sender=cls)
>signals.pre_save.connect(self._save, sender=cls)
>
> and the resultant error:
>
> line 45, in contribute_to_class
>signals.post_delete.connect(_delete, sender=cls)
>  File "/usr/lib/python2.4/site-packages/django/dispatch/
> dispatcher.py", line 84, in connect
>assert argspec[2] is not None, \
> AssertionError: Signal receivers must accept keyword arguments
> (**kwargs).
>
>
> now my understanding of the syntax is that _delete and self._save
> would be keyword arguments, but apparently i am incorrect.  Any help
> or suggestions would be greatly appreciated.
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---