On Aug 18, 7:05 am, Tang Daogang <daogangt...@gmail.com> wrote:
> hi, Emily,
>
> Let me introduce Scala/Lift as example.
>
> Every lift project has a file named 'Boot.scala', this file will only
> be executed once when this project boots up. In this file, we can
> write some initial codes to initial project and some userdefined
> structures.
>
> Emm, that's it. I want to find one file acting like Boot.scala of Lift
> within Django, but failed. If there is one file like that, I will put
> my plugins registering codes into it, thus, when I type "python
> manage.py runserver", it can be executed automatically and only once.
> By it, my plugins can be registered when app boot up.
>
> Do you understand my meaning? Welcome suggestion.

But you still haven't understood that a Django website served by eg
Apache is different from a standalone single-process application like
your Scala example. There's simply no such thing as 'at bootup',
because Apache will dynamically create and kill processes as required
by website load. In many configurations, those processes are
independent and do not share state with each other.

So, do you really want something that is only run once - by the
initial process that is created on server startup? If so, any in-
memory structures that it creates would not be accessible by other
processes that are started later. This might be what you want if the
data is persisted to disk or the database, so you really do only want
it created once.

Or, do you want a process to set up in-memory structures for itself
when it starts, which then persist inside that process for the
duration of that process? In which case, you might try putting
something into urls.py so it is run when that module is imported,
which is the way that the admin is set up via admin.autodiscover().
--
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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to