Re: Proposal: Signal connection via "my_app.MyModel"

2012-08-22 Thread Andrew Ingram
I can see a use case for this, but would this not work?

from django.db.models import get_model

post_save.connect(

my_signal_handler,

sender=get_model('my_app', 'MyModel'),
)

As long as the app cache has been initialised before you call get_model,
this should work fine.

- Andy


On 22 August 2012 06:17, Yo-Yo Ma  wrote:
> Is there anyone else out there who doesn't like having to import models
from app X into app Y just so that app Y can connect post save signals to
them?
>
> --
> You received this message because you are subscribed to the Google Groups
"Django developers" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/django-developers/-/_vcka4fdtPUJ.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.
>

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



Re: Proposal: Signal connection via "my_app.MyModel"

2012-08-22 Thread Russell Keith-Magee
On Wed, Aug 22, 2012 at 1:17 PM, Yo-Yo Ma  wrote:
> Is there anyone else out there who doesn't like having to import models from 
> app X into app Y just so that app Y can connect post save signals to them?

I can't say the need to import models to set up a signal has ever
caused me any difficulty.

Yours,
Russ Magee %-)

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



Re: Proposal: Signal connection via "my_app.MyModel"

2012-08-21 Thread Yo-Yo Ma
Is there anyone else out there who doesn't like having to import models from 
app X into app Y just so that app Y can connect post save signals to them?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/_vcka4fdtPUJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: Proposal: Signal connection via "my_app.MyModel"

2012-05-13 Thread Yo-Yo Ma
It would not be a "hard link". Do you know the definition of
"dependency graph", and do you know anything about Django's internals
or about how Django already allows you to connect models' foreign keys
this way? It would be simply "get me the model 'MyModel' from the app
'my_app'". The app could easily be moved around, and no extra imports
would be used in the process (see models.get_models()). This gives you
the ability to move the app around easily. The real benefit in my
oppinion would be the ability to connect signals for models from app A
inside of app B without having to worry about import order or errors,
due to some crisscross in app A's dependency graph.

On May 12, 4:24 am, Dougal Matthews  wrote:
> On 9 May 2012 22:14, Yo-Yo Ma  wrote:
>
> > This would allow for better decoupling of code, as well as a far
> > cleaner dependency graph.
>
> The dependancy will still be there, the string containing the dotted path
> would be a hard link. However, this will be hidden and a less obvious
> dependancy than a normal Python import.
>
> So, I'd be -1 as I don't see the advantage of this and rather it just adds
> further complexity.

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



Re: Proposal: Signal connection via "my_app.MyModel"

2012-05-12 Thread Dougal Matthews
On 9 May 2012 22:14, Yo-Yo Ma  wrote:
> This would allow for better decoupling of code, as well as a far
> cleaner dependency graph.

The dependancy will still be there, the string containing the dotted path
would be a hard link. However, this will be hidden and a less obvious
dependancy than a normal Python import.

So, I'd be -1 as I don't see the advantage of this and rather it just adds
further complexity.

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



Re: Proposal: Signal connection via "my_app.MyModel"

2012-05-11 Thread Yo-Yo Ma
I'd be willing to implement this, with some guidance.

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