On 1/25/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
[snip]
>
> An object's behavior is determined both by its state (the
> self.__dict__ attribute) and its class (the self.__class__ attribute).
>
> reload() doesn't go change the __class__ of all the objects which were
> created before reload was called.
>

True, but using the up-arrow in the shell will recreate the objects
with the reloaded module without any extra typing. The trick is to
import the module, not the objects in the module. Sometimes this
requires a little extra typing the first time around. Using Toms'
example:

    from whatever import models                # import module `models` here
    site = models.Site.objects.all()[0]         # note use of `models.Site`
    site.gsearch("fields")
    # review output and make changes to code
    reload(models)

    #up-arrow three times, then enter
    #up-arrow three times, then enter
    # review output and make changes to code
    #up-arrow three times, then enter
    #repeat...

Sure beats closing the shell, reopening and retyping everything. Just
remember to do it right the first time around. When things get more
complex that this, I'll write up a sample script that prints out the
results and just rerun it after editing. That's generally easier in
the long run, especially if I want to make some changes to the test
code.

-- 
----
Waylan Limberg
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to