Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 1, 2010 17:29:14

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

signal locations


Now, i've read the thread in regards to putting the import in the
__init__.py

here is my structure

website_project
- > signals
- - > signals.py (and an __init__.py)
- > shared_apps (link to numerous apps shared amongst other projects)
- - > gallery application

my signals.py looks like this

from django.db.models.signals import post_save
from django.core.mail import send_mail
from gallery.models import Gallery

def send_creation(sender, instance, *args, **kwargs):
if 'created' in kwargs:
if kwargs and instance.published:
send_mail('Subject here',, 'f...@example.com', ,
fail_silently=False)

post_save.connect(send_creation,sender=Gallery)

this works when in the gallery application, however... this is just a
test case, eventually i am going to be hitting up the fb graph api and
posting the website's facebook profile, and i'd prefer to keep the
gallery application useful for both facebook and non-facebook
integrated websites.

I've attempted import signals and import signals.signals in the
website_project __init__.py. the former resulting in nothing and the
latter resulting in a "internal server failure" upon restart.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 1, 2010 20:28:28

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

signal locations


On Dec 1, 5:29 pm, garagefan <monkeygar...@gmail.com> wrote:
> Now, i've read the thread in regards to putting the import in the
> __init__.py
>
> here is my structure
>
> website_project
> - > signals
> - - > signals.py (and an __init__.py)
> - > shared_apps (link to numerous apps shared amongst other projects)
> - - > gallery application
>
> my signals.py looks like this
>
> from django.db.models.signals import post_save
> from django.core.mail import send_mail
> from gallery.models import Gallery
>
> def send_creation(sender, instance, *args, **kwargs):
>     if 'created' in kwargs:
>         if kwargs and instance.published:
>             send_mail('Subject here',, 'f...@example.com', ,
> fail_silently=False)
>
> post_save.connect(send_creation,sender=Gallery)
>
> this works when in the gallery application, however... this is just a
> test case, eventually i am going to be hitting up the fb graph api and
> posting the website's facebook profile, and i'd prefer to keep the
> gallery application useful for both facebook and non-facebook
> integrated websites.
>
> I've attempted import signals and import signals.signals in the
> website_project __init__.py. the former resulting in nothing and the
> latter resulting in a "internal server failure" upon restart.

You should do this the other way round. Keep the signal definition -
the `send_creation` function itself - in signals.py, but don't import
Gallery there. Instead, in gallery/models.py, import the *signal*:
from signals.signals import send_creation - and then do the
registering at the bottom of that file.
--
DR.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 1, 2010 21:32:41

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

signal locations


That wouldn't resolve the problem any more than having everything in
the models.py.

i wish to externalize this signal from the gallery application so that
it is up to the website project whether or not a signal is being used.
i suppose i could add a toggle variable in the gallery settings file
so the project settings file can decide whether or not to utilize the
work being done within the method via a local variable...

seems kind of a messy way to do things... it'd be great to have a
single file for the website's signals... sort of like setting up
templatetags at the project level


On Dec 1, 3:28 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Dec 1, 5:29 pm, garagefan <monkeygar...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Now, i've read the thread in regards to putting the import in the
> > __init__.py
>
> > here is my structure
>
> > website_project
> > - > signals
> > - - > signals.py (and an __init__.py)
> > - > shared_apps (link to numerous apps shared amongst other projects)
> > - - > gallery application
>
> > my signals.py looks like this
>
> > from django.db.models.signals import post_save
> > from django.core.mail import send_mail
> > from gallery.models import Gallery
>
> > def send_creation(sender, instance, *args, **kwargs):
> >     if 'created' in kwargs:
> >         if kwargs and instance.published:
> >             send_mail('Subject here',, 'f...@example.com', ,
> > fail_silently=False)
>
> > post_save.connect(send_creation,sender=Gallery)
>
> > this works when in the gallery application, however... this is just a
> > test case, eventually i am going to be hitting up the fb graph api and
> > posting the website's facebook profile, and i'd prefer to keep the
> > gallery application useful for both facebook and non-facebook
> > integrated websites.
>
> > I've attempted import signals and import signals.signals in the
> > website_project __init__.py. the former resulting in nothing and the
> > latter resulting in a "internal server failure" upon restart.
>
> You should do this the other way round. Keep the signal definition -
> the `send_creation` function itself - in signals.py, but don't import
> Gallery there. Instead, in gallery/models.py, import the *signal*:
> from signals.signals import send_creation - and then do the
> registering at the bottom of that file.
> --
> DR.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Dec. 2, 2010 04:58:50

Cal L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

signal locations


Place your signals into webapp/app/signals.py

Then, inside the signals, do "from webapp.app import models"Then attach the signals in a fashion which you are accustom to (seehttp://docs.djangoproject.com/en/dev/topics/signals/).Then, inside the __init__.py OR the models.py, do "importwebapp.app.signals"I do not know if Django checks if a signal has already been attached, soyou might want to unit test this first.On 01/12/2010 21:32, garagefan wrote:That wouldn't resolve the problem any more than having everything in
the models.py.

i wish to externalize this signal from the gallery application so that
it is up to the website project whether or not a signal is being used.
i suppose i could add a toggle variable in the gallery settings file
so the project settings file can decide whether or not to utilize the
work being done within the method via a local variable...

seems kind of a messy way to do things... it'd be great to have a
single file for the website's signals... sort of like setting up
templatetags at the project level


On Dec 1, 3:28 pm, Daniel Roseman<dan...@roseman.org.uk> wrote:On Dec 1, 5:29 pm, garagefan<monkeygar...@gmail.com> wrote:Now, i've read the thread in regards to putting the import in the
__init__.py
here is my structure
website_project
-> signals
- -> signals.py (and an __init__.py)
-> shared_apps (link to numerous apps shared amongst other projects)
- -> gallery application
my signals.py looks like this
from django.db.models.signals import post_save
from django.core.mail import send_mail
from gallery.models import Gallery
def send_creation(sender, instance, *args, **kwargs):
if 'created' in kwargs:
if kwargs and instance.published:
send_mail('Subject here',, 'f...@example.com', ,
fail_silently=False)
post_save.connect(send_creation,sender=Gallery)
this works when in the gallery application, however... this is just a
test case, eventually i am going to be hitting up the fb graph api and
posting the website's facebook profile, and i'd prefer to keep the
gallery application useful for both facebook and non-facebook
integrated websites.
I've attempted import signals and import signals.signals in the
website_project __init__.py. the former resulting in nothing and the
latter resulting in a "internal server failure" upon restart.You should do this the other way round. Keep the signal definition -
the `send_creation` function itself - in signals.py, but don't import
Gallery there. Instead, in gallery/models.py, import the *signal*:
from signals.signals import send_creation - and then do the
registering at the bottom of that file.
--
DR.--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support