Mathieu, What you said prompt me some idea: If I write my plugin registering codes into a middleware, and load it in django's settings.py, will it executed when app boot up?
On 8月17日, 下午11时51分, Mathieu Leduc-Hamel <marra...@gmail.com> wrote: > Paul, no it's not exactly the point. When you said some code on the boot up > it means really a piece of code shared by everyone and executed just one > time, by example, for mod_wsgi it would be when apache is starting. > > That's exactly what's done in the Pylons world to be able to load some piece > of code like the different middleware initialization. It could be useful > when you need launch some external long running process or anything like > that. > > But putting the code anywhere cause it would be evaluated when the code is > loaded is not safe cause you don't if everything was correctly loaded a this > time... > > > > On Tue, Aug 17, 2010 at 5:13 PM, Paul Winkler <sli...@gmail.com> wrote: > > Seems to me that "on boot up" doesn't mean anything in a shared- > > nothing architecture like Django's. For example if you deploy on eg. > > mod_wsgi. > > You have no idea how long any particular thread or process is going to > > live, > > and no idea how often this "boot" code would get run. > > > But assuming that's OK, one naive strategy would be to just call the > > function(s) at top level in some module that gets imported by your > > app. > > Good enough? > > > On Aug 17, 9:12 am, Mathieu Leduc-Hamel <marra...@gmail.com> wrote: > > > Tang, > > > > do you mean : > > > > "How to execute some pieces of code when you launch the "runserver" > > command > > > by example" ? If this is what you mean, it's not a easy thing to do right > > > now. Then only way i found it possible is by using: twod.wsgi > > > > With twod.wsgi you can use the entry points system of python and do, like > > in > > > Pylons, an entry defined by Paster "app_factory" > > > > You can see an example there: > >http://packages.python.org/twod.wsgi/manual/paste-factory.html#using-... > > > > mathieu > > > > On Tue, Aug 17, 2010 at 2:45 PM, Emily Rodgers < > > emily.kate.rodg...@gmail.com > > > > > wrote: > > > > On Aug 17, 2:26 am, Tang Daogang <daogangt...@gmail.com> wrote: > > > > > Dear all, > > > > > > Recently, I have developed a plugin system for my app, and I want to > > > > > register those plugins when my app boot up, this need to execute some > > > > > user defined codes (functions) in app boot procedure, I don't know > > > > > where insert my registering codes to, anyone can help? > > > > > > Thank you. > > > > > Hi, > > > > > I don't know how to help you, but I think it is because you haven't > > > > explained what you want to do thoroughly enough. > > > > > What do you mean by a plugin system, and what do you mean by > > > > registering them with the app on boot up? Are you talking about > > > > including another python module in your code? Or perhaps including > > > > another django app in your code? > > > > > Can you give us a bit more information (and maybe examples) of what > > > > you are trying to do. > > > > > Cheers, > > > > Em > > > > > -- > > > > 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<django-users%2bunsubscr...@google-groups.com> > > <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@g-ooglegroups.com> > > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > 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<django-users%2bunsubscr...@google-groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en.- 隐藏被引用文字 - > > - 显示引用的文字 - -- 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.