I was looking for how to execute a script and I was just thinking how to use django code and here is your e-mail! Thank you!
I am just not sure about how to call the shell script. should I use the os.system(command) or the os.popen ? That seems that popen just return when I close the script and this is exactly what I want to avoid. and considering that a file called sendmail.py with all the script to read from a database and send the e-mails will be in the same path as the view, how can I call it? def startsending(request): os.system("sendmail.py") return HttpResponse('Your e-mails are being send") ? and I got an example that does a python script, on the end of the script it does: ---------------------------------------------- [script code] if __name__ == "__main__": while something: execute(command) [end of the script] ---------------------- if I call it from a view using os.system, it still will be the main so I have to use this code? Thanks for your help =) On 3/30/07, xgdlm <[EMAIL PROTECTED]> wrote: > > Hello, > > Sending email within a view seems to me quite a strange process :) > You should send your emails within a shell python (or whatever) > process. > > What I would do ... > I would within my view, write some kind of data to a database or a > text file or whatever. > Then, have a cronjob that check that data (should I send emails or > not ?) > Then if the answer is 'True' fire a script that sends emails. > > In this case your long process won't involve any fcgi/webserver > process. > > Of course you can use Django in shell python script. You juste have to > wrtite some script with the flowing caneva : > ----------------------------------------------------------------------------------- > #!/usr/bin/env python > > import sys > sys.path.append('/path/to/django/source') > sys.path.append('/path/to/projects') > > import os > > # assuming /path/to/your/projects/myproject/settings.py > os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' > > from project.models import whatever > > django code > ----------------------------------------------------------------------------------- > > > Regards, > xav > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---