Re: session in all templates?

2007-07-11 Thread Simon Drabble

On Wed, 11 Jul 2007, Martin Kaffanke wrote:

> Am Mittwoch, den 11.07.2007, 12:26 -0400 schrieb Simon Drabble:
>> On Wed, 11 Jul 2007, Martin Kaffanke wrote:
>>
>>> Hi there!
>>>
>>> How can I configure django to put the session (request.session) in all
>>> templates?
>>>
>>> I want to put a 'Hello Username' for logged in Users, and I want to do a
>>> dynamic login/logout button into the menu, depends on if there is a
>>> logged in user or not.
>>>
>>> Thanks,
>>> Martin
>>>
>>
>> Extend your templates from a common base, with the session info in the base.
>
> Hum, I do not really understand what you mean... any links?
>
> Thanks,
> Martin
>

Start here:

http://www.djangoproject.com/documentation/templates/

Particularly:

http://www.djangoproject.com/documentation/templates/#extends

-Simon.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: session in all templates?

2007-07-11 Thread Simon Drabble

On Wed, 11 Jul 2007, Martin Kaffanke wrote:

> Hi there!
>
> How can I configure django to put the session (request.session) in all
> templates?
>
> I want to put a 'Hello Username' for logged in Users, and I want to do a
> dynamic login/logout button into the menu, depends on if there is a
> logged in user or not.
>
> Thanks,
> Martin
>

Extend your templates from a common base, with the session info in the base.

-Simon

-- 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Spawning long processes

2007-07-05 Thread Simon Drabble

On Thu, 5 Jul 2007, Oliver Charles wrote:

>
> That doesn't work, I've tried that, it still hangs the view.
>
> Give it a shot with a long python script (while True: time.sleep(1)
> would do) and you'll find that the view never returns. If you can get
> it to return, I'd love to see your code, but it's no go for me...
>


Well, modulo the script name & arguments, that's the code I'm using
successfully to run background processes. How have you verified that
the view does not return? Does the sub-process actually start (i.e.
can you see it with ps)? What OS are you using, and have you verified
that the code you are uring works outside of django (write a small
shell script that does nothing but call the external torrent process -
does that work as expected?).

-Simon.

> On Jul 5, 2:57 pm, Simon Drabble <[EMAIL PROTECTED]> wrote:
>> On Thu, 5 Jul 2007, Oliver Charles wrote:
>>
>>> Just to give an update, I've tried forking the view, and then turning
>>> the child process into a daemon with a double fork, and then exiting
>>> before it gets to the return, and letting the parent do the return,
>>> but this is not working either...
>>
>>> I'm stumped, and don't really want to have to create a specific
>>> controller daemon (but guess I'm going to have to)
>>
>>> - Olllie
>>
>> Use the subprocess module:
>>
>> import subprocess
>> ...
>> script = 'python'
>> args = (script, '/path/to/executable', ...)
>> env = { ... }
>> pid = subprocess.Popen(args, close_fds=True, env=env).pid
>>
>> t = Torrent.objects.create(pid=pid)
>> ...
>>
>> Remember to store the pid for later wait()ing or you'll end up with zombies.
>>
>> -Simon.
>>
>>
>>
>>
>>
>>> On Jul 5, 2:58 am, Oliver Charles <[EMAIL PROTECTED]> wrote:
>>>> Hi
>>
>>>> I'm currently playing around trying to make something akin to
>>>> TorrentFlux, using Django. TorrentFlux is a system that's PHP and it
>>>> calls shell scripts to download torrents in the background, with a web
>>>> interface to control them. For every torrent download, a new process
>>>> is started, which runs with the torrent - downloading and seeding it.
>>
>>>> My system is similar, and i'm at a very proof of concept stage at the
>>>> moment. However, I've hit a problem. I can't find a nice way to spawn
>>>> the processes, without Django hanging as long as the process needs
>>>> (and for 600mb torrents, that's gonna be hours, and endless if seeding
>>>> is expected).
>>
>>>> At the moment I am doing:
>>
>>>> def start(request):
>>
>>>> p = os.spawnlp(os.P_NOWAIT, 'python', 'python', '/Users/acid/Work/
>>>> dTorrent/btdownloadheadless',
>>>> '/Users/acid/Desktop/Inbox/-{mininova.org}- Professional C+
>>>> +.torrent')
>>
>>>> t = Torrent.objects.create(pid=p)
>>
>>>> return HttpResponse(str(p))
>>
>>>> But this is hanging, despite the P_NOWAIT (the Torrent model does get
>>>> created).
>>
>>>> Any ideas?
>>
>> --
>
>
> >

-- 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: [django-users] Re: Spawning long processes

2007-07-05 Thread Simon Drabble

On Thu, 5 Jul 2007, Oliver Charles wrote:

>
> Just to give an update, I've tried forking the view, and then turning
> the child process into a daemon with a double fork, and then exiting
> before it gets to the return, and letting the parent do the return,
> but this is not working either...
>
> I'm stumped, and don't really want to have to create a specific
> controller daemon (but guess I'm going to have to)
>
> - Olllie


Use the subprocess module:

import subprocess
...
script = 'python'
args = (script, '/path/to/executable', ...)
env = { ... }
pid = subprocess.Popen(args, close_fds=True, env=env).pid

t = Torrent.objects.create(pid=pid)
...

Remember to store the pid for later wait()ing or you'll end up with zombies.


-Simon.

>
> On Jul 5, 2:58 am, Oliver Charles <[EMAIL PROTECTED]> wrote:
>> Hi
>>
>> I'm currently playing around trying to make something akin to
>> TorrentFlux, using Django. TorrentFlux is a system that's PHP and it
>> calls shell scripts to download torrents in the background, with a web
>> interface to control them. For every torrent download, a new process
>> is started, which runs with the torrent - downloading and seeding it.
>>
>> My system is similar, and i'm at a very proof of concept stage at the
>> moment. However, I've hit a problem. I can't find a nice way to spawn
>> the processes, without Django hanging as long as the process needs
>> (and for 600mb torrents, that's gonna be hours, and endless if seeding
>> is expected).
>>
>> At the moment I am doing:
>>
>> def start(request):
>>
>> p = os.spawnlp(os.P_NOWAIT, 'python', 'python', '/Users/acid/Work/
>> dTorrent/btdownloadheadless',
>> '/Users/acid/Desktop/Inbox/-{mininova.org}- Professional C+
>> +.torrent')
>>
>> t = Torrent.objects.create(pid=p)
>>
>> return HttpResponse(str(p))
>>
>> But this is hanging, despite the P_NOWAIT (the Torrent model does get
>> created).
>>
>> Any ideas?
>
>
> >

-- 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: [django-users] Re: Including [django-users] in subject line?

2007-06-09 Thread Simon Drabble

On Sun, 10 Jun 2007, Kenneth Gonsalves wrote:

>
>
> On 10-Jun-07, at 7:33 AM, Mike Schinkel wrote:
>
>> Does anyone know of a free service (or software) that I could proxy
>> through
>> that would let me add a subject header?  Given that it appears to be a
>> non-negotiable on the list, that's about the only potential
>> solution left
>> that I can see that would allow me to handle the volume of email on
>> this
>> list.
>
> procmail
>
>


..and just to make it super-easy:

#
# Tag django mailing list
#
:0
* To: [EMAIL PROTECTED]
{
:0 fhc
| sed -e 's/^Subject: /Subject: [django-users] /'
}


..not that I necessarily disagree with the OP's point, but I do think
this is a case where the problem can be solved on an individual basis.


-Simon
-- 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: [django-users] FileBrowser v 2.0

2007-06-07 Thread Simon Drabble
On Thu, 7 Jun 2007, patrickk wrote:

>
> I´ve just released a new version of the filebrowser:
> http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki
>
> things to come:
> ### i18n
> ### integration of snipshot and picnik for basic image-editing
> (already working on that one)
>
> thanks,
> patrick.


Patrick,

Are you planning on/ do you have any support for tagging? I'm working
on a (very alpha) personal file management app geared towards photos,
audioclips, and movies, the prime motivator being to allow easy tagging
of large sets of files.

No sense duplicating wheel-construction so if you have tagging support
planned or available I may take a look at your app.

-Simon.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---