Re: ubuntu 6.06 deployment issues

2007-07-05 Thread Jeremy Dunck

On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote:
> In my settings.py, I now have:
> MEDIA_ROOT = '/var/www/mysite.com/media/'
> MEDIA_URL = 'http://mysite.com/media/'
> ADMIN_MEDIA_PREFIX = '/media/'

Err, I don't have my code or settings file handy.   This is the kind
of thing you forget, since it just works once you have it configured.

But if you plan to serve media other than admin, you'll want to nest
the admin media dir inside your regular media url.

So maybe you want MEDIA_URL = http://mysite.com/media/ and
ADMIN_MEDIA_PREFIX = 'http://mysite.com/media/admin/'

> Anyway, want to say thanks again to everyone for chiming in, this is
> one of the friendliest and most helpful user groups I've had the
> pleasure of participating in.

That makes me feel kinda fuzzy.  :)
  -Jeremy

--~--~-~--~~~---~--~~
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: Help with a Caching Strategy

2007-07-05 Thread Jeremy Dunck

On 7/5/07, Clint Ecker <[EMAIL PROTECTED]> wrote:
> It would be super cool to invalidate the cache (or not) at the
> moment I update the data, but it's not mission critical.

How's the data updated?  Need to know how to get the update info to
the cache.  :)

> Long story short, my current approaches haven't yielded any fruit. I'm
> not sure that I can cache one view two different ways by using the
> cache_page function.  Perhaps I need to dig a little deeper into the
> caching mechanisms?

As a hack, you could have a stub view that just decides if it's the
current month or not, then dispatch either of 2 real views, each with
its own cache_page.

For an actual solution, more detail's needed.

How many other parameters from the request come into play?

If a small number of permutations, you could bake all the data (that
is, pull requests into a flat file to be served cheaply later, in
which "invalidating cache" is deleting a file).

If you decide to use the low-level cache due to too many permutations,
this is the general approach:

expensive_thing = cache.get(some_key)
if not expensive_thing:
expensive_thing = expensive_process
   cache.set(some_key, expensive_thing, cache_timeout)

You can, of course, do that as much as you want.

I have some views that do two or 3 phases, in which I cache a whole
resultset, then munge or whittle it depending on parameters and cache
that bit with a more fine-grained key.

Cheers,
  Jeremy

--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread John-Scott

On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> Hmmm, I'm not sure the documentation is actually accurate. When you
> use manage.py to run up development server for Django, it will
> automatically add the parent directory of where the manage.py file is
> located into sys.path for you. Thus, there isn't strictly a need to
> add it to PYTHONPATH to get it to work in the first place.
>
> So, the answer is that YES, for mod_python you must use the PythonPath
> directive to specify the parent directory of where manage.py is
> located in order for your settings file to be found correctly.
>
> Graham

Graham - I was suspicious of that. I remember reading that manage.py
took care of setting all the environment variables for the development
server and interactive shell. But it didn't seem possible for
mod_python to have any idea where our projects are implicitly. Should
we file a doc bug?

On Jul 6, 12:20 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> MEDIA_ROOT is used for uploads (like FileField and ImageField.
> MEDIA_URL should be the service URL matching MEDIA_ROOT; it is also
> used in things like Model.get_FIELD_url where FIELD is the name of an
> ImageField on your model.
>
> Probably, you want your doc root to be some prefix of MEDIA_ROOT (or
> MEDIA_ROOT itself).
> MEDIA_URL would be the portion of the MEDIA_ROOT not included in your
> apache doc root (or '/' if the same).
>
> ADMIN_MEDIA_PREFIX is the URL portion under MEDIA_URL that is
> symlinked to django/contrib/admin/media.  (You don't need to worry
> about this unless you're using the Admin app.)

Jeremy - Thanks for the in-a-nutshell overview. I am in fact using the
admin app, so that was my first hurdle to clear before getting fancy.
I currently have the admin interface working. In my virtual host file
I added:

 DocumentRoot "/var/www/mysite"
 
  SetHandler None
 
 
  SetHandler None
 

In my settings.py, I now have:
MEDIA_ROOT = '/var/www/mysite.com/media/'
MEDIA_URL = 'http://mysite.com/media/'
ADMIN_MEDIA_PREFIX = '/media/'

Does this look about right? /var/www/mysite is empty other than the
'media' subdirectory. I suppose I could have apache alias requests to /
media/ to whatever folder. I'll get fancy after some sleep ;). Once I
get things settled, I'll try to contribute lessons learned to the
wiki.

Anyway, want to say thanks again to everyone for chiming in, this is
one of the friendliest and most helpful user groups I've had the
pleasure of participating in. I was born in a small midwestern city
not far from Lawrence, KS, so I'm exited to get involved with a web
framework of similar origins ;)

Cheers


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



Help with a Caching Strategy

2007-07-05 Thread Clint Ecker

In one of the applications I maintain, I use a view that takes the
following inputs, crunches a lot of data from over the course of a
month, and spits out a view:

def month_detail(request, year, month, check=True):

This could be the current month, the previous month, a month 3 years
ago, etc. The information pertaining to the current month is updated
every 15 minutes (if there's been new data in the past 15 minutes), so
I would like to make that information only cache for 15 minutes at
most.  It would be super cool to invalidate the cache (or not) at the
moment I update the data, but it's not mission critical.  For someone
to visit the site every 15 minutes and get new data for the current
month is just fine.

However, the data for previous month's is done and set in stone pretty
much at the beginning of the next month.  Data for the previous month
might roll in for a few days into the new month, but in general, once
we roll into the new month, it's a done deal.  I would like to cache
those pages forever, or maybe invalidate their caches when the rare
bit comes in after the month is over.

Long story short, my current approaches haven't yielded any fruit. I'm
not sure that I can cache one view two different ways by using the
cache_page function.  Perhaps I need to dig a little deeper into the
caching mechanisms?

How would people with more experience with caching+Django approach
this situation?

Thanks in advance,
Clint

-- 
Clint Ecker
Sr. Web Developer - Stone Ward Chicago
p: 312.464.1443
c: 312.863.9323
---
twitter: clint
skype: clintology
AIM: idiosyncrasyFG
Gtalk: [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
-~--~~~~--~~--~--~---



Re: ubuntu 6.06 deployment issues

2007-07-05 Thread Graham Dumpleton

On Jul 6, 1:24 pm, John-Scott <[EMAIL PROTECTED]> wrote:
> @Vincent - Is specifying the path necessary because I'm using the
> development version of django and not an official installer? In the
> official docs it says you only have to specify the path "if you've
> manually altered your PYTHONPATH to put your Django project on it". I
> didn't make any such adjustment. But it's also unclear to me how else
> a django project be on the PYTHONPATH. I understand that __init__.py
> tells python to load the files in that directory as a module, but
> python would need to know what directory to look for that file...

Hmmm, I'm not sure the documentation is actually accurate. When you
use manage.py to run up development server for Django, it will
automatically add the parent directory of where the manage.py file is
located into sys.path for you. Thus, there isn't strictly a need to
add it to PYTHONPATH to get it to work in the first place.

So, the answer is that YES, for mod_python you must use the PythonPath
directive to specify the parent directory of where manage.py is
located in order for your settings file to be found correctly.

Graham


--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread Jeremy Dunck

On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote:
> (i.e. MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX) are
> supposed to interact with the Apache config. back to the docs...

MEDIA_ROOT is used for uploads (like FileField and ImageField.
MEDIA_URL should be the service URL matching MEDIA_ROOT; it is also
used in things like Model.get_FIELD_url where FIELD is the name of an
ImageField on your model.

Probably, you want your doc root to be some prefix of MEDIA_ROOT (or
MEDIA_ROOT itself).
MEDIA_URL would be the portion of the MEDIA_ROOT not included in your
apache doc root (or '/' if the same).

ADMIN_MEDIA_PREFIX is the URL portion under MEDIA_URL that is
symlinked to django/contrib/admin/media.  (You don't need to worry
about this unless you're using the Admin app.)

--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread John-Scott

On Jul 5, 11:33 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> You want to have the 'django_src' directory linked onto your Python
> path, not the 'django' directory -- the Python path should contain the
> *parent* directories of any modules you want Python to be able to
> find.

According to http://www.djangoproject.com/documentation/install/,
these are the two commands for setting up the development version of
django:
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
ln -s `pwd`/django_src/django SITE-PACKAGES-DIR/django

In my case, my `pwd` would be /home/john-scott/workspace, so this is
where django_src is created and then the subdirectory `pwd`/django_src/
django would be symlinked to /usr/lib/python2.4/site-packages/django.
Am I misunderstanding something? I'm getting sleepy, so anything is
possible ;)


> Media files to be served directly need to be in a location under the
> web server's document root, but templates can be in any location
> that's readable by the user the web server is running as, and it's
> generally a good idea to have as few Django-related files in the
> document root as possible.
>
> Remember that there are a number of different template loaders
> available for Django which can look in different places automatically
> -- the "app directories" one, for example, automatically looks inside
> any installed application's directory for templates.

I guess I was confused by the fact that the settings.py file contains
these comments:
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"

...so I assumed it was 'ok' to store all static media files in a
similar directory (i.e. '/home/john-scott/workspace/mysite/media'). At
this point I realize I'm not at all clear on how the settings in
settings.py (i.e. MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX) are
supposed to interact with the Apache config. back to the docs...


--~--~-~--~~~---~--~~
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: YUI tags

2007-07-05 Thread Todd O'Bryan

Thanks! I'd actually thought about how to do this, but it's nice to have
real code...

On Thu, 2007-07-05 at 13:50 -0500, Jacob Kaplan-Moss wrote:
> Hi Todd --
> 
> You might find writing those "nested" template tags a bit tricky;
> there's a not-very-well-documented method you'll need to pull out the
> sub-tags.
> 
> I've got an example of how you can do these types of nested tags here:
> http://www.djangosnippets.org/snippets/300/
> 
> Good luck!
> 
> Jacob



--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread James Bennett

On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote:
> @Nimrod - You were right about the permissions on /home/john-scott/
> workspace, chmod 755 fixed that. But I still have to have the django
> development code in /opt to get it to load. Any ideas why symlinking
> to /home/john-scott/workspace/django_src/django doesn't work?

You want to have the 'django_src' directory linked onto your Python
path, not the 'django' directory -- the Python path should contain the
*parent* directories of any modules you want Python to be able to
find.

> And where do you typically keep the template and/or admin media files?
> Can these be kept in /home/john-scott/workspace/mysite/{templates|
> admin_media} etc.? Or do these have to be placed under /var/www?

Media files to be served directly need to be in a location under the
web server's document root, but templates can be in any location
that's readable by the user the web server is running as, and it's
generally a good idea to have as few Django-related files in the
document root as possible.

Remember that there are a number of different template loaders
available for Django which can look in different places automatically
-- the "app directories" one, for example, automatically looks inside
any installed application's directory for templates.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread John-Scott

Thanks for the prompt replies.

@Nimrod - You were right about the permissions on /home/john-scott/
workspace, chmod 755 fixed that. But I still have to have the django
development code in /opt to get it to load. Any ideas why symlinking
to /home/john-scott/workspace/django_src/django doesn't work?

@Vincent - Is specifying the path necessary because I'm using the
development version of django and not an official installer? In the
official docs it says you only have to specify the path "if you've
manually altered your PYTHONPATH to put your Django project on it". I
didn't make any such adjustment. But it's also unclear to me how else
a django project be on the PYTHONPATH. I understand that __init__.py
tells python to load the files in that directory as a module, but
python would need to know what directory to look for that file...

And where do you typically keep the template and/or admin media files?
Can these be kept in /home/john-scott/workspace/mysite/{templates|
admin_media} etc.? Or do these have to be placed under /var/www?

Thanks again


--~--~-~--~~~---~--~~
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: Error log interpretation

2007-07-05 Thread Graham Dumpleton

On Jul 6, 9:38 am, Vincent Nijs <[EMAIL PROTECTED]>
wrote:
> Could anyone help me identify if the error message below (from apache log)
> might be a network/apache error or something in my Django/python code. My
> site is deployed using apache and mod_python.
>
> [error] [client ] PythonHandler django.core.handlers.modpython: Traceback
> (most recent call last):, referer:https://mysite.org
> [error] [client ] PythonHandler django.core.handlers.modpython:   File
> "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in
> HandlerDispatch\nresult = object(req), referer:https://mysite.org
> [error] [client ] PythonHandler django.core.handlers.modpython:   File
> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
> 177, in handler\nreturn ModPythonHandler()(req), 
> referer:https://mysite.org
> [error] [client ] PythonHandler django.core.handlers.modpython:   File
> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
> 169, in __call__\nreq.write(chunk), referer:https://mysite.org
> [error] [client ] PythonHandler django.core.handlers.modpython: IOError:
> Write failed, client closed connection., referer:https://mysite.org

The IOError simply indicates that the browser connection was closed
before a response could be completely sent. Did you press the stop or
reload buttons on the browser in the middle of a page load?

Graham


--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread Vincent Nijs

Try adding the following in the location block:

PythonPath "['/home/john-scott/workspace'] + sys.path"

Vincent



On 7/5/07 9:03 PM, "John-Scott" <[EMAIL PROTECTED]> wrote:

> 
> Hello all,
> 
> I'm having some issues getting a basic django project in production
> mode.
> 
> I'm using Ubuntu 6.06 LTS with the default versions of apache, python,
> mod_python, etc.
> - I've checked out the development version of Django in my home
> directory, i.e. /home/john-scott/workspace/django_src and I've
> symlinked it to /usr/lib/python2.4/site-packages/django as per the
> official installation instructions.
> - I've created a Django project in /home/john-scott/workspace/mysite
> following the tutorials exactly.
> 
> The official documentation suggests keeping the django app code
> outside of /var/www for security purposes and to instead keep the code
> in a user directory (the specific example is '/home/mycode').
> Everything works great with the development server. However, I've
> encountered nothing but problems trying to go 'live'. I'm using the
> following virtual host configuration, which again is modeled after the
> official docs:
> 
> 
>  ServerNamemysite.com #obviously not the real url ;)
>  
>   SetHandler python-program
>   PythonHandler django.core.handlers.modpython
>   SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>   PythonDebug On
>  
> 
> 
> With this setup I get the following error:
> ImportError: No module named django
> 
> In another thread (http://groups.google.com/group/django-users/
> browse_thread/thread/e44569d185e36284/) someone said there were
> permission problems but their solution was to place the django_src in /
> opt and change the symlink accordingly. If I follow this, then the
> first problem goes away but then I get the following error:
> EnvironmentError: Could not import settings 'mysite.settings' (Is it
> on sys.path? Does it have syntax errors?): No module named
> mysite.settings
> 
> In the same thread the user also put the projects in /opt as well. The
> real problem seems to be the Apache configuration, so I'm not
> convinced the answer is to throw everything in /opt, especially since
> none of the official docs suggest to do such a thing (IIRC the user in
> that thread didn't have control over apache, so they had to be
> creative).
> 
> I've followed all the official docs quite literally. Is the suggestion
> in the docs to keep your projects in /home/username incorrect? Or is
> there something about the Apache configuration in Ubuntu 6.06 that
> makes deployment a wee bit more complicated than the docs suggest? If
> so, should the official deployment guides have a note about these
> gotchas? Once I get this ironed out in a sane way I'd be happy to add
> a write-up to the SeverArrangements wiki page.
> 
> Thanks,
> John-Scott
> 
> 
> > 

-- 
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: [EMAIL PROTECTED]
Skype: vincentnijs




--~--~-~--~~~---~--~~
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: ubuntu 6.06 deployment issues

2007-07-05 Thread Nimrod A. Abing

Hello,

Your problem could be that the permissions to /home/john-scott do not
allow directory traversal down into this directory for "other" users.
You probably need to do:

$ chmod 0755 /home/john-scott
$ chmod 0755 /home/john-scott/workspace
$ cd /home/john-scott/workspace
$ find -type d | xargs chmod 0755
$ find -type f | xargs chmod 0644

Your home directory probably contains important files that you don't
want to be accessible by "other" users so you might consider creating
a separate user account specifically for Django.

HTH.

On 7/6/07, John-Scott <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I'm having some issues getting a basic django project in production
> mode.
>
> I'm using Ubuntu 6.06 LTS with the default versions of apache, python,
> mod_python, etc.
> - I've checked out the development version of Django in my home
> directory, i.e. /home/john-scott/workspace/django_src and I've
> symlinked it to /usr/lib/python2.4/site-packages/django as per the
> official installation instructions.
> - I've created a Django project in /home/john-scott/workspace/mysite
> following the tutorials exactly.
>
> The official documentation suggests keeping the django app code
> outside of /var/www for security purposes and to instead keep the code
> in a user directory (the specific example is '/home/mycode').
> Everything works great with the development server. However, I've
> encountered nothing but problems trying to go 'live'. I'm using the
> following virtual host configuration, which again is modeled after the
> official docs:
>
> 
>  ServerNamemysite.com #obviously not the real url ;)
>  
>   SetHandler python-program
>   PythonHandler django.core.handlers.modpython
>   SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>   PythonDebug On
>  
> 
>
> With this setup I get the following error:
> ImportError: No module named django
>
> In another thread (http://groups.google.com/group/django-users/
> browse_thread/thread/e44569d185e36284/) someone said there were
> permission problems but their solution was to place the django_src in /
> opt and change the symlink accordingly. If I follow this, then the
> first problem goes away but then I get the following error:
> EnvironmentError: Could not import settings 'mysite.settings' (Is it
> on sys.path? Does it have syntax errors?): No module named
> mysite.settings
>
> In the same thread the user also put the projects in /opt as well. The
> real problem seems to be the Apache configuration, so I'm not
> convinced the answer is to throw everything in /opt, especially since
> none of the official docs suggest to do such a thing (IIRC the user in
> that thread didn't have control over apache, so they had to be
> creative).
>
> I've followed all the official docs quite literally. Is the suggestion
> in the docs to keep your projects in /home/username incorrect? Or is
> there something about the Apache configuration in Ubuntu 6.06 that
> makes deployment a wee bit more complicated than the docs suggest? If
> so, should the official deployment guides have a note about these
> gotchas? Once I get this ironed out in a sane way I'd be happy to add
> a write-up to the SeverArrangements wiki page.
>
> Thanks,
> John-Scott
>
>
> >
>


-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



ubuntu 6.06 deployment issues

2007-07-05 Thread John-Scott

Hello all,

I'm having some issues getting a basic django project in production
mode.

I'm using Ubuntu 6.06 LTS with the default versions of apache, python,
mod_python, etc.
- I've checked out the development version of Django in my home
directory, i.e. /home/john-scott/workspace/django_src and I've
symlinked it to /usr/lib/python2.4/site-packages/django as per the
official installation instructions.
- I've created a Django project in /home/john-scott/workspace/mysite
following the tutorials exactly.

The official documentation suggests keeping the django app code
outside of /var/www for security purposes and to instead keep the code
in a user directory (the specific example is '/home/mycode').
Everything works great with the development server. However, I've
encountered nothing but problems trying to go 'live'. I'm using the
following virtual host configuration, which again is modeled after the
official docs:


 ServerNamemysite.com #obviously not the real url ;)
 
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE mysite.settings
  PythonDebug On
 


With this setup I get the following error:
ImportError: No module named django

In another thread (http://groups.google.com/group/django-users/
browse_thread/thread/e44569d185e36284/) someone said there were
permission problems but their solution was to place the django_src in /
opt and change the symlink accordingly. If I follow this, then the
first problem goes away but then I get the following error:
EnvironmentError: Could not import settings 'mysite.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
mysite.settings

In the same thread the user also put the projects in /opt as well. The
real problem seems to be the Apache configuration, so I'm not
convinced the answer is to throw everything in /opt, especially since
none of the official docs suggest to do such a thing (IIRC the user in
that thread didn't have control over apache, so they had to be
creative).

I've followed all the official docs quite literally. Is the suggestion
in the docs to keep your projects in /home/username incorrect? Or is
there something about the Apache configuration in Ubuntu 6.06 that
makes deployment a wee bit more complicated than the docs suggest? If
so, should the official deployment guides have a note about these
gotchas? Once I get this ironed out in a sane way I'd be happy to add
a write-up to the SeverArrangements wiki page.

Thanks,
John-Scott


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



Difficulty validating ModelMultipleChoiceField

2007-07-05 Thread danylo


I can't get a form to validate and for the life of me, can't figure
out why.

I keep getting an error on the topics.  Regardless of how many I
choose, it returns an "Enter a list of values." error.  It looks like
even though the form returns a list of topics, it doesn't send the
list to the validator, just a single value.

I've also tried converting the topics bit to a MutlipleChoiceField,
but didnt' have any mroe luck with it.

Any suggestions of where to look are much appreciated.  Thanks,

dan


class AddBlogForm(forms.Form):
def __init__( self, *args, **kwargs ):
super( AddBlogForm, self ).__init__( *args, **kwargs )
self.fields['location'] =
GroupedChoiceField(choices=location_drop_tags())
self.fields['topics'] = forms.ModelMultipleChoiceField(
queryset=Tags.objects.exclude(location__exact=True).order_by('-
parent_tag', 'tag'), widget=SortedCheckBox)
owner = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput)
url = forms.URLField(initial='http://', verify_exists=True)
title = forms.CharField(max_length=100)
description = forms.CharField(max_length=500, required=False,
widget=forms.Textarea(attrs={'rows': '3'}))



(this is the widget used for the topic)
class SortedCheckBox(forms.Select):
def render(self, name, value, attrs=None, choices=()):
from django.utils.html import escape
from django.newforms.util import flatatt, smart_unicode
final_attrs = self.build_attrs(attrs, name=name)
output = []
if value is None:
value = ''
str_value = tuple([smart_unicode(v) for v in value])
for t in
self.choices.queryset.filter(parent_tag__isnull=True):
output.append(u'')
option_value = smart_unicode(t.id)
option_label = smart_unicode(t.tag)
selected_html = (option_value in str_value) and u'checked
' or ''
output.append(u'%s' % (option_value, selected_html,
option_label))
for t_child in
self.choices.queryset.filter(parent_tag__tag=t.tag):
option_value = smart_unicode(t_child.id)
option_label = smart_unicode(t_child.tag)
selected_html = (option_value in str_value) and
u'checked ' or ''
output.append(u'%s' % (option_value, selected_html,
option_label))
output.append(u'')
return u'\n'.join(output)


--~--~-~--~~~---~--~~
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: --+++Does anybody have instructions to make a photo app+++--

2007-07-05 Thread Naco

sorry didnt mean to

On Jul 5, 7:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/6/07, Naco <[EMAIL PROTECTED]> wrote:
>
>
>
> Please don't use ---+++ highlighting for the subject of messages when
> writing to this list. Its very impolite.
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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: --+++Does anybody have instructions to make a photo app+++--

2007-07-05 Thread Russell Keith-Magee

On 7/6/07, Naco <[EMAIL PROTECTED]> wrote:
>

Please don't use ---+++ highlighting for the subject of messages when
writing to this list. Its very impolite.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: An idea on DB migration

2007-07-05 Thread Noam Raphael

On 7/6/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> If you haven't already, check out http://www.aswmc.com/dbmigration/
>
> It's quite a good solution for migration.
> I've been writing a wrapper on top of that to handle auto-migration,
> which I'm mostly happy with. Just have to tie some loose ends and I'll
> put it up somewhere to share.

Thanks for the link!

My main concern about this method: I have to use SQL. I don't really
understand SQL, and I'm very happy to let Django write it up for me.
When I write it, I'm never sure if it will exactly fit what Django
expects, or if it will be efficient (Should I define some columns as
indices? As relations?) If my method was available, I wouldn't have to
write a single line of SQL, and I would still be able to do whatever I
want.

Have a good day,
Noam

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



Error log interpretation

2007-07-05 Thread Vincent Nijs
Could anyone help me identify if the error message below (from apache log)
might be a network/apache error or something in my Django/python code. My
site is deployed using apache and mod_python.

[error] [client ] PythonHandler django.core.handlers.modpython: Traceback
(most recent call last):, referer: https://mysite.org
[error] [client ] PythonHandler django.core.handlers.modpython:   File
"/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch\nresult = object(req), referer: https://mysite.org
[error] [client ] PythonHandler django.core.handlers.modpython:   File
"/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
177, in handler\nreturn ModPythonHandler()(req), referer:
https://mysite.org
[error] [client ] PythonHandler django.core.handlers.modpython:   File
"/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
169, in __call__\nreq.write(chunk), referer: https://mysite.org
[error] [client ] PythonHandler django.core.handlers.modpython: IOError:
Write failed, client closed connection., referer: https://mysite.org

Interestingly Django did not send me any emails about this error even though
debug = False. 

Thanks much,

Vincent

--~--~-~--~~~---~--~~
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: --+++Does anybody have instructions to make a photo app+++--

2007-07-05 Thread Naco

thank you for replying so fast

Well im looking for tutorials on building a simple photo app to start
with

i started to mess around with the following in my models.py

from django.db.models import *

# Create your models here.
class photo(Model):
image= ImageField(upload_to="photos/")
title= CharField(maxlength=150)
uploaded=  DateTimeField()



class Admin:
list_display = ('image','title','uploaded')



but here is the catch I want to add a field to add the captions and i
want to show the thumbnails
of the pic. from here on I was lost. because i dont know aboutt th
int.py or the views.py

If you have a more complex photo app ill take it. since I am just
starting to learn the language. Im all confuded
since I am just starting to mess around with making anything. Or if
you can point me out to the right place to read instrucitons ill
appreciate any help. Im looking at the book for reference but think of
me as a slow processor


thanks



--~--~-~--~~~---~--~~
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: Cross Importing Model Problem

2007-07-05 Thread Bryan Veloso

Oh also, I thought OneToOneFields were discouraged in favor of
ForeignKeys with unique=True as per
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model


--~--~-~--~~~---~--~~
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: Cross Importing Model Problem

2007-07-05 Thread Bryan Veloso

Thanks for the help guys. Splitting the models up was mostly a
cosmetic thing for the admin, but these problems quickly kicked me out
of that state. Anyway, yes, the database design is really bad, mostly
because that's not what the game developers are experts at
unfortunately.


--~--~-~--~~~---~--~~
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: Random string template tag

2007-07-05 Thread SmileyChris

Or you could do {{ "class1,class2,class3,class4"|split:","|random }}

(you'd need to make the |split filter too, Django only comes with |
join)

On Jul 4, 3:21 pm, Bryan Veloso <[EMAIL PROTECTED]> wrote:
> > If you want to hardcode the availability of the 'classes' variable in
> > every context (so you don't have to remember to define it every time),
> > you could write a context processor. See
> > django.core.context_processors for examples.
>
> That's probably what I'll need since it'll always have to be there.


--~--~-~--~~~---~--~~
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: An idea on DB migration

2007-07-05 Thread SmileyChris

If you haven't already, check out http://www.aswmc.com/dbmigration/

It's quite a good solution for migration.
I've been writing a wrapper on top of that to handle auto-migration,
which I'm mostly happy with. Just have to tie some loose ends and I'll
put it up somewhere to share.


--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread Doug Van Horn

On Jul 5, 10:13 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> ...
> To prevent this, you need to uniquely identify the page from
> which it was submitted (a hash of the IP address, timestamp the
> form was generated, user info, whatever) ...

You might want to consider a uuid:

import uuid
uuid.uuid4()

That should give you less false positives in identifying duplicate
form submissions.


Doug Van Horn


--~--~-~--~~~---~--~~
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: --+++Does anybody have instructions to make a photo app+++--

2007-07-05 Thread [EMAIL PROTECTED]

Exactly what sort of photo app are you trying to build?
What text is it outputting?
Where are the images?

On Jul 5, 3:25 pm, Naco <[EMAIL PROTECTED]> wrote:
> Im having such a hard time transitioning from ROR to Django and I am
> looking for instructions to make a photo app.
>
> Can anybody help out a newby??
>
> I been experimenting with making the app I been using the Google video
> that Jacob comes out in as a reference but I cant get the images to
> show on the field it only shows the text.
>
> help
> help


--~--~-~--~~~---~--~~
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: No module named _md5

2007-07-05 Thread Horst Gutmann

e-gor wrote:
> so what should i do? :) i'm newby :) there are no md5 module
> requirements in the setting.py
> 
> On 5 июл, 22:13, "nick feng" <[EMAIL PROTECTED]> wrote:
>> It' seems that the md5 is not a middleware, but you have write it in the 
>> setting.py file's middleware setting part.
>>
>> - Original Message -
>> From: "e-gor" <[EMAIL PROTECTED]>
>> To: "Django users" 
>> Sent: Friday, July 06, 2007 2:59 AM
>> Subject: No module named _md5
>>
>>> I have python 2.5.1, django report errors:
>>> Mod_python error: "PythonHandler django.core.handlers.modpython"
>>> Traceback (most recent call last):
>>>  File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
>>> line 193, in Dispatch
>>>result = object(req)
>>>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
>>> modpython.py", line 177, in handler
>>>return ModPythonHandler()(req)
>>>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
>>> modpython.py", line 145, in __call__
>>>self.load_middleware()
>>>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
>>> base.py", line 31, in load_middleware
>>>raise exceptions.ImproperlyConfigured, 'Error importing middleware
>>> %s: "%s"' % (mw_module, e)
>>> ImproperlyConfigured: Error importing middleware
>>> django.middleware.common: "No module named _md5"
>>> When i write import md5 from python command prompt i have no errors.
> 

Another idea: How have you installed Python? If you were using some kind
of package manager, check if there are some additional crypto-related
packages in the same repository :-)

- Horst

--~--~-~--~~~---~--~~
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: displaying values with SelectDateTime widget

2007-07-05 Thread Bob Dively

On Jul 5, 4:20 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I take it you're using a default {{form}} view instead of outputting
> your own?
> If you output your own, it's as simple as using the |date:"" filter.

It's not a formatting problem. I can't figure out how to get the
correct values selected in the three select boxes created by
SelectDateWidget.


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



--+++Does anybody have instructions to make a photo app+++--

2007-07-05 Thread Naco

Im having such a hard time transitioning from ROR to Django and I am
looking for instructions to make a photo app.

Can anybody help out a newby??


I been experimenting with making the app I been using the Google video
that Jacob comes out in as a reference but I cant get the images to
show on the field it only shows the text.


help
help


--~--~-~--~~~---~--~~
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: displaying values with SelectDateTime widget

2007-07-05 Thread [EMAIL PROTECTED]

I take it you're using a default {{form}} view instead of outputting
your own?
If you output your own, it's as simple as using the |date:"" filter.

On Jul 5, 3:09 pm, Bob Dively <[EMAIL PROTECTED]> wrote:
> I'm trying to use the SelectDateTime widget but I can't figure out how
> to get it to correctly display a value retrieved from a database. For
> example:
>
> client = Client.objects.get(Client_ID=client_id)
> ClientForm = forms.models.form_for_instance(client)
> ClientForm.base_fields['Birth_Dat'].widget = SelectDateWidget()
>
> I've been unable to get the resulting HTML to show anything other than
> 01-Jan-2007 as the date. ("Birth_Dat" with no "e" is correct, btw.)
> Any suggestions would be greatly appreciated, as I'm completely
> baffled.


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



displaying values with SelectDateTime widget

2007-07-05 Thread Bob Dively

I'm trying to use the SelectDateTime widget but I can't figure out how
to get it to correctly display a value retrieved from a database. For
example:

client = Client.objects.get(Client_ID=client_id)
ClientForm = forms.models.form_for_instance(client)
ClientForm.base_fields['Birth_Dat'].widget = SelectDateWidget()

I've been unable to get the resulting HTML to show anything other than
01-Jan-2007 as the date. ("Birth_Dat" with no "e" is correct, btw.)
Any suggestions would be greatly appreciated, as I'm completely
baffled.


--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread [EMAIL PROTECTED]

I'll have to check with my QA person to see exactly what they are
doing.  Perhaps they didn't tell me everything and they are hitting
the back button... then going forward again...

I've only gotten this to happen once, and had a bug on that page where
I was saving twice..heh :)

On Jul 5, 11:13 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I am using HttpResponseRedirect... it still seems to allow a
> > duplicate post though if refresh is hit on the page it's been
> > redirected to.
>
> Is this happening when a user clicks the Submit button twice
> before the redirect comes in (thus Django processes two requests
> from the same originating page, rather than from the response-page)?
>
> You can minimize double-submits via a little JavaScript code,
> disabling the submit button in the onclick before submitting.
> However, this doesn't 100% solve the problem, particularly if JS
> is disabled (whether by browser limitation, or by user choice,
> such as the wonderful NoScript plugin for FireFox which I use
> regularly)
>
> To prevent this, you need to uniquely identify the page from
> which it was submitted (a hash of the IP address, timestamp the
> form was generated, user info, whatever) and then only allow that
> identifier to be processed once.  You'd have to keep a model of
> "recent posts".  If the hash is in there, the request you're
> currently trying to process has already been processed.  It would
> be good to have this table auto-purged after some reasonable amt
> of time, such as a couple days or a week.  Huzzah for cron-jobs :)
>
> If you wanted to get fancy and your app had need of it, you could
> hash the submitted data from the form (including the initial
> unique identifier).  This would allow the user to click their
> Back button, return to the form, make changes and submit it a 2nd
> time.  This can be useful in a data-entry scenario where you want
> to ensure that the 2nd submission actually has new data, not the
> same data from accidentally double-clicking the submit button.
> It's nice to have the usage pattern of "fill out the form; submit
> the form; click the back button; change something; submit the
> form; click the back button; "
>
> Just a few ideas,
>
> -tim


--~--~-~--~~~---~--~~
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: No module named _md5

2007-07-05 Thread e-gor

so what should i do? :) i'm newby :) there are no md5 module
requirements in the setting.py

On 5 июл, 22:13, "nick feng" <[EMAIL PROTECTED]> wrote:
> It' seems that the md5 is not a middleware, but you have write it in the 
> setting.py file's middleware setting part.
>
> - Original Message -
> From: "e-gor" <[EMAIL PROTECTED]>
> To: "Django users" 
> Sent: Friday, July 06, 2007 2:59 AM
> Subject: No module named _md5
>
> > I have python 2.5.1, django report errors:
>
> > Mod_python error: "PythonHandler django.core.handlers.modpython"
>
> > Traceback (most recent call last):
>
> >  File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
> > line 193, in Dispatch
> >result = object(req)
>
> >  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> > modpython.py", line 177, in handler
> >return ModPythonHandler()(req)
>
> >  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> > modpython.py", line 145, in __call__
> >self.load_middleware()
>
> >  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> > base.py", line 31, in load_middleware
> >raise exceptions.ImproperlyConfigured, 'Error importing middleware
> > %s: "%s"' % (mw_module, e)
>
> > ImproperlyConfigured: Error importing middleware
> > django.middleware.common: "No module named _md5"
>
> > When i write import md5 from python command prompt i have no errors.


--~--~-~--~~~---~--~~
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: No module named _md5

2007-07-05 Thread nick feng
It' seems that the md5 is not a middleware, but you have write it in the 
setting.py file's middleware setting part.

- Original Message - 
From: "e-gor" <[EMAIL PROTECTED]>
To: "Django users" 
Sent: Friday, July 06, 2007 2:59 AM
Subject: No module named _md5


> 
> 
> I have python 2.5.1, django report errors:
> 
> Mod_python error: "PythonHandler django.core.handlers.modpython"
> 
> Traceback (most recent call last):
> 
>  File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
> line 193, in Dispatch
>result = object(req)
> 
>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 177, in handler
>return ModPythonHandler()(req)
> 
>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 145, in __call__
>self.load_middleware()
> 
>  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 31, in load_middleware
>raise exceptions.ImproperlyConfigured, 'Error importing middleware
> %s: "%s"' % (mw_module, e)
> 
> ImproperlyConfigured: Error importing middleware
> django.middleware.common: "No module named _md5"
> 
> When i write import md5 from python command prompt i have no errors.
> 
> 
> > 
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Filtering foreignkey results with newforms form_for_model

2007-07-05 Thread [EMAIL PROTECTED]

I have an "Event" model that has a foreignkey relationship with
"Club", and I'm using form_for_model to create the form. This spits
out all "Club" entries in a dropdown.

The trick is, "Club" has a boolean field for "approved", and I want to
filter according to that.

So, is there some way to filter it? At the newform level. Should I get
'club.objects.filter(approved=true)' and pass that to form somehow
(maybe form.club = approvedclubs)?

Thanks.


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



No module named _md5

2007-07-05 Thread e-gor

I have python 2.5.1, django report errors:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
line 193, in Dispatch
result = object(req)

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 177, in handler
return ModPythonHandler()(req)

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 145, in __call__
self.load_middleware()

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
base.py", line 31, in load_middleware
raise exceptions.ImproperlyConfigured, 'Error importing middleware
%s: "%s"' % (mw_module, e)

ImproperlyConfigured: Error importing middleware
django.middleware.common: "No module named _md5"

When i write import md5 from python command prompt i have no errors.


--~--~-~--~~~---~--~~
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: YUI tags

2007-07-05 Thread Jacob Kaplan-Moss

Hi Todd --

You might find writing those "nested" template tags a bit tricky;
there's a not-very-well-documented method you'll need to pull out the
sub-tags.

I've got an example of how you can do these types of nested tags here:
http://www.djangosnippets.org/snippets/300/

Good luck!

Jacob

--~--~-~--~~~---~--~~
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: Pickle model fields

2007-07-05 Thread Jens Diemer

I would make a pickle field, too.

I tried this:

-

class Preference(models.Model):

 ...

 def _get_value(self):
 return pickle.loads(self._value)

 def _set_value(self, value):
 self._value = pickle.dumps(value)

 _value = models.TextField()
 value = property(_get_value, _set_value)

 ...

-


In a short test works this seems to work...

Question: Is this a good idea?


-- 
Mfg.

Jens Diemer



A django powered CMS: http://www.pylucid.org


--~--~-~--~~~---~--~~
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: Strange translation/encoding problem

2007-07-05 Thread Emanuele Pucciarelli <[EMAIL PROTECTED]>

Hi,

from django.utils.translation import ugettext as _

My guess is that if you import ugettext, then you should supply a
Unicode string as an argument:

def index(request):
teststring = _(u"Lösung")
[...]

(notice the 'u' before the string).

That works here, at least using an utf-8 source file (# -*- coding:
utf-8 -*- at the start).

Bye,

--
Emanuele


--~--~-~--~~~---~--~~
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: newforms: saving relations via intermediary table

2007-07-05 Thread va:patrick.kranzlmueller

solution:
user_extended_profile.userextendedprofilefavourites_set.all().delete()
before inserting the new related object works.

Am 05.07.2007 um 15:44 schrieb va:patrick.kranzlmueller:

>
> I´m having trouble using newforms with an intermediary table
> (although I´m not sure that my problem relates to newforms anyhow).
>
> models:
> class UserExtendedProfile(models.Model):
>   ...
> class UserExtendedProfileFavourites(models.Model):
>  userextendedprofile = models.ForeignKey(UserExtendedProfile,
> edit_inline=models.TABULAR, num_in_admin=5, max_num_in_admin=5,
> num_extra_on_change=1)
>  ...
>
> views:
> ...
> user_extended_profile.save()
> # set favourites
> user_extended_profile.userextendedprofilefavourites_set = [fav1,
> fav2, fav3]
>
> now, when saving the related favourites, the _old_ favourites are not
> deleted but the new ones are added.
> I thought it´s possible to update the favourites in a way that the
> old ones are deleted and the new ones are added. Am I wrong with my
> assumption or do I use the wrong code?
>
> thanks,
> patrick
>
>
>
>
>
> >


--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread Tim Chase

> I am using HttpResponseRedirect... it still seems to allow a
> duplicate post though if refresh is hit on the page it's been
> redirected to.

Is this happening when a user clicks the Submit button twice 
before the redirect comes in (thus Django processes two requests 
from the same originating page, rather than from the response-page)?

You can minimize double-submits via a little JavaScript code, 
disabling the submit button in the onclick before submitting. 
However, this doesn't 100% solve the problem, particularly if JS 
is disabled (whether by browser limitation, or by user choice, 
such as the wonderful NoScript plugin for FireFox which I use 
regularly)

To prevent this, you need to uniquely identify the page from 
which it was submitted (a hash of the IP address, timestamp the 
form was generated, user info, whatever) and then only allow that 
identifier to be processed once.  You'd have to keep a model of 
"recent posts".  If the hash is in there, the request you're 
currently trying to process has already been processed.  It would 
be good to have this table auto-purged after some reasonable amt 
of time, such as a couple days or a week.  Huzzah for cron-jobs :)

If you wanted to get fancy and your app had need of it, you could 
hash the submitted data from the form (including the initial 
unique identifier).  This would allow the user to click their 
Back button, return to the form, make changes and submit it a 2nd 
time.  This can be useful in a data-entry scenario where you want 
to ensure that the 2nd submission actually has new data, not the 
same data from accidentally double-clicking the submit button. 
It's nice to have the usage pattern of "fill out the form; submit 
the form; click the back button; change something; submit the 
form; click the back button; "

Just a few ideas,

-tim





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



Translate text

2007-07-05 Thread aeby

Hi all,

Is there a way to translate text (and make the msgids appear in the po
files) that does not appear in python source nor in templates. I try
to translate text stored in the database.

Thanks & Greets,
Aeby


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



Strange translation/encoding problem

2007-07-05 Thread spacetaxi

Hi list,

my django is completely utf8-configured. I'm using I18N and my msg-ids
(po-files) are utf8-encoded, too.

But now I've run into a strange problem: Translation of strings
containing non-ascii characters is working great in templates, but it
fails if I try to translate non-ascii strings in a view.

For example, this get's translated without problems:
{% trans "Lösung" %}

But this one fails:
from django.utils.translation import ugettext as _
def index(request):
teststring = _("Lösung")
[...]

This exception is raised when the view is called:
--
Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/django/core/handlers/
base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/django/myproject/../myproject/portal/views.py" in
index
  8. teststring = _("Lösung")
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
__init__.py" in ugettext
  61. return real_ugettext(message)
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
trans_real.py" in ugettext
  274. return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
trans_real.py" in do_translate
  258. return getattr(t, translation_function)(message)

  UnicodeDecodeError at /
  'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in
range(128)
--

Why does it work within templates but not within views?? What am I
doing wrong? Any hint?

(BTW, I'm using the current django trunk.)

TIA
-Stephan


--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread [EMAIL PROTECTED]

I am using HttpResponseRedirect... it still seems to allow a duplicate
post though if refresh is hit on the page it's been redirected to.

On Jul 5, 10:34 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 7/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > In the cases where an existing record is being edited, this doesn't
> > really matter, but when a user adds a new record, and I redirect him
> > to the page to view all of the objects in that table, if he then hits
> > refresh, it adds the record again due to a second form post.
>
> After successfully handling a POST, best practice is to redirect.
> This forces the browser to do a GET, and hitting refresh won't do
> another post.
>
> I think you can redirect to the same URL, if that view handles GET and
> POST differently.


--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread Jeremy Dunck

On 7/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> In the cases where an existing record is being edited, this doesn't
> really matter, but when a user adds a new record, and I redirect him
> to the page to view all of the objects in that table, if he then hits
> refresh, it adds the record again due to a second form post.

After successfully handling a POST, best practice is to redirect.
This forces the browser to do a GET, and hitting refresh won't do
another post.

I think you can redirect to the same URL, if that view handles GET and
POST differently.

--~--~-~--~~~---~--~~
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: Stopping second form post if refresh is hit?

2007-07-05 Thread KpoH

Use HttpResponseRedirect from django.http


[EMAIL PROTECTED] пишет:
> On most of my form posts, I redirect to another page once I save
> whatever data has been posted on the form.  ( I am not using new
> forms, and in some cases I'm even using old fashioned hand rolled
> forms to post from a view. )
>
> In the cases where an existing record is being edited, this doesn't
> really matter, but when a user adds a new record, and I redirect him
> to the page to view all of the objects in that table, if he then hits
> refresh, it adds the record again due to a second form post.
>
> Is there a way to stop this?  I figure there must be, but perhaps I
> wasn't searching with the correct key words.
>
> Thanks for any info.
>   

-- 
Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L.
http://www.asterisksupport.ru
http://www.asterisk-support.com


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

Ahhh, I got it now - Thanks so much Simon! The problem was I had left
out close_fds, so it was still spawning as a child process I think.
With close_fds it works a treat - thank you once again :D

- Ollie

On Jul 5, 3:18 pm, Simon Drabble <[EMAIL PROTECTED]> wrote:
> 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
-~--~~~~--~~--~--~---



Stopping second form post if refresh is hit?

2007-07-05 Thread [EMAIL PROTECTED]

On most of my form posts, I redirect to another page once I save
whatever data has been posted on the form.  ( I am not using new
forms, and in some cases I'm even using old fashioned hand rolled
forms to post from a view. )

In the cases where an existing record is being edited, this doesn't
really matter, but when a user adds a new record, and I redirect him
to the page to view all of the objects in that table, if he then hits
refresh, it adds the record again due to a second form post.

Is there a way to stop this?  I figure there must be, but perhaps I
wasn't searching with the correct key words.

Thanks for any info.


--~--~-~--~~~---~--~~
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: How to know what went wrong with the .save()

2007-07-05 Thread Jeremy Dunck

On 7/5/07, RajeshD <[EMAIL PROTECTED]> wrote:
> Not sure. What RDBMS are you using? I understand about the need to
> retain your DB structure as is but are you allowed to *add* new
> constraints to the DB?

Django does not support multi-column primary key tables.

If you'll be doing insert/update/delete, Django will get confused.

If you only need read-only access, you can create a shim view over the
table, and set the Model's db_table to use the view.

If you need write access, I'm afraid you're on shaky ground with Django.

There's been interest expressed in doing this before, but if you want
to try adding it, it'll be a fairly involved job.

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

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

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



newforms: saving relations via intermediary table

2007-07-05 Thread va:patrick.kranzlmueller

I´m having trouble using newforms with an intermediary table  
(although I´m not sure that my problem relates to newforms anyhow).

models:
class UserExtendedProfile(models.Model):
...
class UserExtendedProfileFavourites(models.Model):
 userextendedprofile = models.ForeignKey(UserExtendedProfile,  
edit_inline=models.TABULAR, num_in_admin=5, max_num_in_admin=5,  
num_extra_on_change=1)
 ...

views:
...
user_extended_profile.save()
# set favourites
user_extended_profile.userextendedprofilefavourites_set = [fav1,  
fav2, fav3]

now, when saving the related favourites, the _old_ favourites are not  
deleted but the new ones are added.
I thought it´s possible to update the favourites in a way that the  
old ones are deleted and the new ones are added. Am I wrong with my  
assumption or do I use the wrong code?

thanks,
patrick





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

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

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: Unicode branch merged into trunk

2007-07-05 Thread RajeshD

Thank you, Malcolm!


--~--~-~--~~~---~--~~
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: How to know what went wrong with the .save()

2007-07-05 Thread RajeshD

On Jul 5, 8:44 am, AnaReis <[EMAIL PROTECTED]> wrote:
> Hi again,>From what I could understand, I would have to recreate the database 
> so
>
> that django could create an ID field for me. Unfortunately that isn't
> possible because I'm using a legacy database and I can't change it.

Right.

> In
> this database, the primary key is the two fields combined, so their
> combination has to be unique. Is there a way for me to do this without
> having to change the database? Just changing the models.py file?

Not sure. What RDBMS are you using? I understand about the need to
retain your DB structure as is but are you allowed to *add* new
constraints to the DB?


--~--~-~--~~~---~--~~
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: Error from JSON serializer

2007-07-05 Thread web-junkie

okay, seems this ensure_ascii=False is useless, without it there's no
error.

On 5 Jul., 14:13, web-junkie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> after updating to the trunk with the merged Unicode branch I get
> errors for my json pages. Everything is normal until I request
> something where it would serialize data with foreign language letters
> which comes as Unicode from the database.
> And as far as I can tell I have done everything it says 
> inhttp://www.djangoproject.com/documentation/unicode/.
>
>  File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
> __init__.py", line 67, in serialize
>s.serialize(queryset, **options)
>
>  File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
> base.py", line 50, in serialize
>self.end_serialization()
>
>  File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
> json.py", line 26, in end_serialization
>simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder,
> **self.options)
>
>  File "/usr/local/lib/python2.4/site-packages/django/utils/simplejson/
> __init__.py", line 139, in dump
>fp.write(chunk)
>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
> position 2: ordinal not in range(128)


--~--~-~--~~~---~--~~
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: How to know what went wrong with the .save()

2007-07-05 Thread AnaReis

Hi again,
>From what I could understand, I would have to recreate the database so
that django could create an ID field for me. Unfortunately that isn't
possible because I'm using a legacy database and I can't change it. In
this database, the primary key is the two fields combined, so their
combination has to be unique. Is there a way for me to do this without
having to change the database? Just changing the models.py file?
Thanks for your help!
Ana

On Jul 5, 8:26 am, AnaReis <[EMAIL PROTECTED]> wrote:
> On Jul 4, 4:35 pm, RajeshD <[EMAIL PROTECTED]> wrote:
>
> > On Jul 4, 12:14 pm, AnaReis <[EMAIL PROTECTED]> wrote:
>
> > > Hi again,
> > > Thanks for the suggestion, but this still isn't working... the
> > > difference between this module and the others that I have already made
> > > is that (besides the fact that the others actually work) this one
> > > involves a table with two primary keys. If it had just one I bet there
> > > would be no problem.
>
> > And you'd win that bet! I should have noticed the two PKs in your
> > model.
>
> > Here's the thing: Django allows only one PK field per object. You
> > should remove the two primary_key=True attributes altogether from your
> > model (letting Django create a PK id field for you.) Then, use the
> > unique_together clause to make the database enforce that the pair
> > (level_name, instrument_name) is always unique. That clause is defined
> > in your Meta class like this:
>
> > unique_together = (('level_name', 'instrument_name'),) # Note that
> > this is a nested tuple
>
> > For added measure you can add a db_index=True to your formerly primary
> > key fields to make querying over them faster.
>
> > Don't forget to wipe out the model entirely from your DB table
> > (assuming you are in development mode with despensible test data) and
> > then syncdb to recreate everything.
>
> Hi,
> Is it possible to do this unique_together field without changing the
> database? It's because I'm using a legacy database and I can't change
> it.
> To create the models I simply used: django-admin.py inspectdb >
> models.py
> If Django creates the PK id field for me, do you mean it will chose
> from one of the fields I will have in the database or will it create a
> new field?
> The model I'm using is this one:
> [models.py]
> class Level(models.Model):
> level_name = models.CharField(primary_key=True, maxlength=20)
> instrument_name = models.CharField(primary_key=True, maxlength=20)
> available = models.TextField()
> tablename = models.CharField(blank=True, maxlength=20)
> def __str__(self):
> (..)
> class Meta:
> db_table = 'Level'
> I'm sorry for all my questions but I'm still learning how to work with
> Django and there are several things that I still don'tknowhow to
> deal with. :)
> And thanks for your help and patience! :)
> Ana


--~--~-~--~~~---~--~~
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: How to know what went wrong with the .save()

2007-07-05 Thread AnaReis

Hi again,
>From what I could understand, I would have to recreate the database so
that django could create an ID field for me. Unfortunately that isn't
possible because I'm using a legacy database and I can't change it. In
this database, the primary key is the two fields combined, so their
combination has to be unique. Is there a way for me to do this without
having to change the database? Just changing the models.py file?
Thanks for your help!
Ana

On Jul 5, 8:26 am, AnaReis <[EMAIL PROTECTED]> wrote:
> On Jul 4, 4:35 pm, RajeshD <[EMAIL PROTECTED]> wrote:
>
> > On Jul 4, 12:14 pm, AnaReis <[EMAIL PROTECTED]> wrote:
>
> > > Hi again,
> > > Thanks for the suggestion, but this still isn't working... the
> > > difference between this module and the others that I have already made
> > > is that (besides the fact that the others actually work) this one
> > > involves a table with two primary keys. If it had just one I bet there
> > > would be no problem.
>
> > And you'd win that bet! I should have noticed the two PKs in your
> > model.
>
> > Here's the thing: Django allows only one PK field per object. You
> > should remove the two primary_key=True attributes altogether from your
> > model (letting Django create a PK id field for you.) Then, use the
> > unique_together clause to make the database enforce that the pair
> > (level_name, instrument_name) is always unique. That clause is defined
> > in your Meta class like this:
>
> > unique_together = (('level_name', 'instrument_name'),) # Note that
> > this is a nested tuple
>
> > For added measure you can add a db_index=True to your formerly primary
> > key fields to make querying over them faster.
>
> > Don't forget to wipe out the model entirely from your DB table
> > (assuming you are in development mode with despensible test data) and
> > then syncdb to recreate everything.
>
> Hi,
> Is it possible to do this unique_together field without changing the
> database? It's because I'm using a legacy database and I can't change
> it.
> To create the models I simply used: django-admin.py inspectdb >
> models.py
> If Django creates the PK id field for me, do you mean it will chose
> from one of the fields I will have in the database or will it create a
> new field?
> The model I'm using is this one:
> [models.py]
> class Level(models.Model):
> level_name = models.CharField(primary_key=True, maxlength=20)
> instrument_name = models.CharField(primary_key=True, maxlength=20)
> available = models.TextField()
> tablename = models.CharField(blank=True, maxlength=20)
> def __str__(self):
> (..)
> class Meta:
> db_table = 'Level'
> I'm sorry for all my questions but I'm still learning how to work with
> Django and there are several things that I still don'tknowhow to
> deal with. :)
> And thanks for your help and patience! :)
> Ana


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



Error from JSON serializer

2007-07-05 Thread web-junkie

Hi,

after updating to the trunk with the merged Unicode branch I get
errors for my json pages. Everything is normal until I request
something where it would serialize data with foreign language letters
which comes as Unicode from the database.
And as far as I can tell I have done everything it says in
http://www.djangoproject.com/documentation/unicode/.


 File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
__init__.py", line 67, in serialize
   s.serialize(queryset, **options)

 File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
base.py", line 50, in serialize
   self.end_serialization()

 File "/usr/local/lib/python2.4/site-packages/django/core/serializers/
json.py", line 26, in end_serialization
   simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder,
**self.options)

 File "/usr/local/lib/python2.4/site-packages/django/utils/simplejson/
__init__.py", line 139, in dump
   fp.write(chunk)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
position 2: ordinal not in range(128)


--~--~-~--~~~---~--~~
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: Best practices to provide Django on a shared host

2007-07-05 Thread Graham Dumpleton

On Jul 5, 5:38 pm, "Fabien Schwob" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm currently hosting  my Django websites on a dedicated server and it
> works fine. I restart Apache when I make modifications since I'm alone
> on the box.
>
> But I've made evangelism for Django and I've convinced some friends to
> use it. So I would like to take a new server and to set up a "Django
> Shared Hosting". What is the best way to do that ?
>
> - One Apache instance by user/website (I've seen that 
> onhttp://www.gypsyhosting.com/) ? But how to do that does someone have
> some links to do that ?
>
> - Using lighttpd and FGCI ?
>
> - Using Apache and FCGI, so the user only need to *touch* the fcgi script.
>
> My goal is to build my shared hosting and to create a document on how
> to do that. So, any help are welcome.

You may want to have a look at mod_wsgi (www.modwsgi.org) and the
following instructions for Django:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

It contains a few different recipes. For what you want, one Django
site per VirtualHost run using mod_wsgi daemon mode would be the best.

To trigger a restart of the process and thus reload any changes, they
can send a SIGINT signal to the httpd process which is owned by them.
One could even have a web page in the application itself which
triggered:

  os.kill(os.getpid(), signal.SIGINT)

This will cause the process to be shutdown and restarted at the end of
the request.

The other alternative is to turn on interpreter reloading, which will
result in the Python sub interpreter being destroyed within the
running process when the WSGI application script file is modified, and
a new sub interpreter created with any changed code. How reliable this
works depends a bit on what third party C extension modules are being
used. Interpreter reloading is controlled by the WSGIReloadMechanism
directive and is documented in:

  http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

A discussion of issues related to interpreter reloading can be found
in section 'Reloading Python Interpreters' in:

  http://code.google.com/p/modwsgi/wiki/ApplicationIssues

If interested in this and have further questions let me know.

Graham


--~--~-~--~~~---~--~~
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: Unicode branch merged into trunk

2007-07-05 Thread Massimiliano Ravelli

Great work Malcolm !
Thank you very much.

On 4 Lug, 14:41, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> Thankyou to this group of early adopters for your early testing feedback.

Well, as an early adopter of unicode branch, I should have reported
that in a few weeks of usage I didn't find any problem. Shame on me !

Regards,
Massimiliano


--~--~-~--~~~---~--~~
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: Building forms by hands

2007-07-05 Thread Russell Keith-Magee

On 7/5/07, Alexander Solovyov <[EMAIL PROTECTED]> wrote:
>
> Hi all.
>
> I want to build forms in HTML by hands, without helpers from django
> (like outputting field with label and etc), but I can't find one thing
> - how I can get value from field (to select appropriate field in
> radioselect, f.e.).

> For example, RadioSelect provides unordered list with choices, but I
> want to get fieldset - and can't select necessary field.

I'm unclear what you're asking here - you say you don't want to use
Django helpers, but they you ask about RadioSelect. Is your problem
with rendering the form, or with getting data from a submitted form?
Can you explain your problem another way, possibly with a more
complete example?

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: Using newforms to create multiple related objects?

2007-07-05 Thread Russell Keith-Magee

On 6/29/07, Michael Sylvan <[EMAIL PROTECTED]> wrote:
>
> Is there a way to do this sort of things cleanly, short of using the
> newforms-admin branch of Django? Or do I have to do something like
> changing the form's fields attribute by hand?

Using formsets from newforms-admin will be the easiest way to do this.
However, if you don't want to go down that path, you can use the
existing forms code without hand coding the id attributes.

When you create the form instance, you can specify a prefix that is
used for the name and id for each input on that form. e.g.,:

MyForm = form_for_model(Phone)

form1 = MyForm(prefix='phone1')
form2 = MyForm(prefix='phone2')
..

will generate two form instances; all the field names and id's for
form1 will be prefixed by 'phone1', and so on. This avoids the
inevitable name/id clash from having multiple instances of the same
form on a page.

This is true of _any_ form, whether created using form_for_model,
form_for_instance, manual definition, or anything else.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: Cross Importing Model Problem

2007-07-05 Thread Nis Jørgensen

Bryan Veloso skrev:

(I am only commenting on the model (database and Django) in this post -
I don't really know enough about imports to help you with that bit)

> I have 2 models for an MMORPG control panel I'm building. Each set of
> data is within it's own app with related models, etc. So here's my
> example. It's run off an existing database so I really can't change
> any of the database fields.
>   
It seems some of the tables are not normalized (see below). Are they set
in stone?

> I have a Character model that imports the Guild model.
>
> class Character(models.Model):
> char_id = models.IntegerField('Character ID',
> primary_key=True)
> account = models.ForeignKey(Account, unique=True,
> db_column='account_id')
> char_num= models.IntegerField('Character Slot')
> name= models.CharField('Name', maxlength=90)
> guild   = models.ForeignKey('Guild',
> db_column='guild_id') 


As far as I can see, this

account = models.ForeignKey(Account, unique=True,
db_column='account_id')

is equivalent to
account = models.OneToOneField(Account, db_column='account_id' )

but with a simpler interface ("account.character" rather than
"account.character_set.all()[0]".

You might want to consider this change - although it might be a bad idea
if you envision multiple characters per account int he future.
> But the app that contains Guild has another model that is linked to
> the Character model.
>
> class GuildMember(models.Model):
> guild   = models.ForeignKey(Guild,
> db_column='guild_id', unique=True, primary_key=True)
> account = models.ForeignKey(Account,
> db_column='account_id', unique=True)
> character   = models.ForeignKey(Character,
> db_column='char_id', unique=True) 
>   
The use of "unique=True" here looks wrong. As written, a Guild has at
most one Character, and a Character has at most one Guild. Is this
really what you want? If so you might again consider using two
OneToOneFields. But I suspect you really mean 'unique_together
(('guild'),('character')).

Anyway, the database design looks quite bad ... the "account" field in
GuildMember seems redundant (assuming it points to the account of the
character). It is not clear whether Character.guild corresponds to
Character.guildmember_set()[0].guild - if they are always the same, the
table structure is not normalized.

I guess the root cause of your problems is that you cannot easily model
a ManyToMany relationship between models in different apps. As Malcolm
suggests, the solution is probably to not have two apps.

Nis



--~--~-~--~~~---~--~~
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: Best practices to provide Django on a shared host

2007-07-05 Thread Fabien Schwob

> Textdrive (Joyent) offers Django hosting.
>
> There is an install script that will setup Django for you:
> http://textusers.com/wiki/Installing_Django

The problem is that I would like to make my own configuration from a
raw Linux distribution (In my case a Ubuntu 6.10 or 7.04). So, with
this link I don't know how are Textdrive server configured.

My goal is for example to provide a tutorial on how to build something
like Gypsyhosting from a clean Ubuntu install.

Thanks

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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: utf-8 and legacy databases

2007-07-05 Thread Malcolm Tredinnick

On Thu, 2007-07-05 at 01:10 -0700, koenb wrote:
> Do I understand correctly that with the unicode branch, databases are
> supposed to be providing and accepting utf-8 data ? This assumption is
> ok for self-constructed databases, but I am interacting with a legacy
> database that is in iso-8859-1 and I can't change that.
> Is there a setting somewhere to indicate what character set the
> database is using ?

No there is no setting for this because it can always be auto-detected
and set. Remember that there is a difference between what the client
side talks and what the database server wants to see ("client" here
means the Python database wrapper). All Django database backends do
conversion to and from the database client's expected character
encoding. This might then be converted to an encoding suitable for the
server or the database or database table in question (some databases
allow per-table encoding, or even per-column).

Obviously, if your database can only store iso8859-1 data,  you will
need to ensure you don't send it any data that cannot be re-encoded to
this character set. There's no really good way to automatically handle
restrictions of that nature -- the correct error handling depends on the
application and user base -- so it is up to the developer to not submit
invalid data. For most backends (I think Oracle is the exception),
Django will not quietly throw away unencodable data. It (or the backend)
will raise an encoding error.

Regards,
Malcolm

-- 
Borrow from a pessimist - they don't expect it back. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: How to know what went wrong with the .save()

2007-07-05 Thread AnaReis



On Jul 4, 4:35 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> On Jul 4, 12:14 pm, AnaReis <[EMAIL PROTECTED]> wrote:
>
> > Hi again,
> > Thanks for the suggestion, but this still isn't working... the
> > difference between this module and the others that I have already made
> > is that (besides the fact that the others actually work) this one
> > involves a table with two primary keys. If it had just one I bet there
> > would be no problem.
>
> And you'd win that bet! I should have noticed the two PKs in your
> model.
>
> Here's the thing: Django allows only one PK field per object. You
> should remove the two primary_key=True attributes altogether from your
> model (letting Django create a PK id field for you.) Then, use the
> unique_together clause to make the database enforce that the pair
> (level_name, instrument_name) is always unique. That clause is defined
> in your Meta class like this:
>
> unique_together = (('level_name', 'instrument_name'),) # Note that
> this is a nested tuple
>
> For added measure you can add a db_index=True to your formerly primary
> key fields to make querying over them faster.
>
> Don't forget to wipe out the model entirely from your DB table
> (assuming you are in development mode with despensible test data) and
> then syncdb to recreate everything.
Hi,
Is it possible to do this unique_together field without changing the
database? It's because I'm using a legacy database and I can't change
it.
To create the models I simply used: django-admin.py inspectdb >
models.py
If Django creates the PK id field for me, do you mean it will chose
from one of the fields I will have in the database or will it create a
new field?
The model I'm using is this one:
[models.py]
class Level(models.Model):
level_name = models.CharField(primary_key=True, maxlength=20)
instrument_name = models.CharField(primary_key=True, maxlength=20)
available = models.TextField()
tablename = models.CharField(blank=True, maxlength=20)
def __str__(self):
(..)
class Meta:
db_table = 'Level'
I'm sorry for all my questions but I'm still learning how to work with
Django and there are several things that I still don't know how to
deal with. :)
And thanks for your help and patience! :)
Ana


--~--~-~--~~~---~--~~
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: Admin module, user account editing and group assignment info

2007-07-05 Thread Angela Sutanto

On 7/4/07, Chris Brand <[EMAIL PROTECTED]> wrote:

> If you go to edit that same user in the Admin, the group should be selected
> in that same multiselect box.
>
> It's as simple as that.

Aha - it did not occur me. I was looking for some gadget proof against
an accidental (re)selection. This solution seems to me quite bit
susceptible...


Thanks for your help, Angela

--~--~-~--~~~---~--~~
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: Best practices to provide Django on a shared host

2007-07-05 Thread Evan H. Carmi

Fabien Schwob wrote:
> Hello,
> 
> I'm currently hosting  my Django websites on a dedicated server and it
> works fine. I restart Apache when I make modifications since I'm alone
> on the box.
> 
> But I've made evangelism for Django and I've convinced some friends to
> use it. So I would like to take a new server and to set up a "Django
> Shared Hosting". What is the best way to do that ?
> 
> - One Apache instance by user/website (I've seen that on
> http://www.gypsyhosting.com/) ? But how to do that does someone have
> some links to do that ?
> 
> - Using lighttpd and FGCI ?
> 
> - Using Apache and FCGI, so the user only need to *touch* the fcgi script.
> 
> My goal is to build my shared hosting and to create a document on how
> to do that. So, any help are welcome.
> 
> Thanks.
> 
Textdrive (Joyent) offers Django hosting.

There is an install script that will setup Django for you:
http://textusers.com/wiki/Installing_Django

Evan


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



One-to-many relations

2007-07-05 Thread mrstone

Hi all

I have a problem I have been struggeling with for a while.

I have two models:

InfoProxy and Permission

A InfoProxy can have several Permissions

class Permission(models.Model):
 info_proxy = models.ForeignKey(InfoProxy,
related_name='permissions')
 permission_type = models.CharField(maxlength=1,
choices=PERMISSION_CHOICES)
 usergroup =   models.ForeignKey(UserGroup)

class InfoProxy(models.Model, UrlItem):
"""
   A proxy pointing to a (Info)Item
"""
info_type = models.ForeignKey(ContentType,
related_name='infoproxies')
info_id = models.PositiveIntegerField()
info_item = generic.GenericForeignKey(ct_field="info_type",
fk_field="info_id")

render_type = models.ForeignKey(ContentType,
related_name='render_infoproxies', blank=True, null=True)
render_id = models.PositiveIntegerField(blank=True, null=True)
render_item = generic.GenericForeignKey(ct_field="render_type",
fk_field="render_id")

created = models.DateTimeField('date created')
modified = models.DateTimeField('date modified')
owner = models.ForeignKey(User)

language_code = models.CharField(maxlength=20)
rank = models.IntegerField( blank=True, null=True)
grade = models.IntegerField( blank=True, null=True)
objects = InfoProxyManager()

I want to query for all object a user has permission to read depending
on groups (code below)
This code works without any problems on developer server. On
mod_python however I (sometimes) get the below error.
If I hit refresh in the browser, it usually works.

I have tried several things like:
All imports are with full paths
Classes put in site-packages
(Maybe something is wrong when loading classes)
I have checked so at least one permission exist on every InfoProxy

Anyone have had a similar problem?
Any hint that can help me try other options?

Any help is very much appreciated.
Sten


--
Error trace
--
  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/
base.py", line 77, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.4/site-packages/jellyspot/server/apps/
locations/proxy/views.py", line 264, in flashes
result_list = ResultList(request, query)

  File "/usr/local/lib/python2.4/site-packages/jellyspot/server/apps/
common/results.py", line 36, in __init__
self.get_results(request)

  File "/usr/local/lib/python2.4/site-packages/jellyspot/server/apps/
common/results.py", line 84, in get_results
raise IncorrectLookupParameters(str(e))

IncorrectLookupParameters: Cannot resolve keyword 'permissions' into
field. Choices are: id, info_type, info_id, render_type, render_id,
created, modified, owner, indexer, language_code, rank, grade


query code

try:
if user and user.is_authenticated():

query = """select uub.usergroup_id  from users_buddy
as ub
left join users_usergroup_buddies as uub on
uub.buddy_id = ub.id  where ub.buddy_id = %s
""" % (user.id)

cursor = connection.cursor()
cursor.execute(query)

group_idents = [item[0] for item in cursor.fetchall()]
group_idents.append(USERGROUP_MEMBERS.id)
else:
group_idents = []

group_idents.append(USERGROUP_EVERYONE.id)


if user and user.is_authenticated():
 qs = self.all().filter( Q(owner__exact=user.id) |
 
Q(permissions__usergroup__in=group_idents)).distinct()
else:
 qs =
self.all().filter(permissions__usergroup__in=group_idents).distinct()

return qs
except Exception, e:
print e
return self.get_empty_query_set()


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



utf-8 and legacy databases

2007-07-05 Thread koenb

Do I understand correctly that with the unicode branch, databases are
supposed to be providing and accepting utf-8 data ? This assumption is
ok for self-constructed databases, but I am interacting with a legacy
database that is in iso-8859-1 and I can't change that.
Is there a setting somewhere to indicate what character set the
database is using ?

Koen


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



Best practices to provide Django on a shared host

2007-07-05 Thread Fabien Schwob

Hello,

I'm currently hosting  my Django websites on a dedicated server and it
works fine. I restart Apache when I make modifications since I'm alone
on the box.

But I've made evangelism for Django and I've convinced some friends to
use it. So I would like to take a new server and to set up a "Django
Shared Hosting". What is the best way to do that ?

- One Apache instance by user/website (I've seen that on
http://www.gypsyhosting.com/) ? But how to do that does someone have
some links to do that ?

- Using lighttpd and FGCI ?

- Using Apache and FCGI, so the user only need to *touch* the fcgi script.

My goal is to build my shared hosting and to create a document on how
to do that. So, any help are welcome.

Thanks.

-- 
Fabien Schwob

--~--~-~--~~~---~--~~
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: Help for side project needed (Django + JavaScript)

2007-07-05 Thread Joe Bloggs
The minimum wage in the UK for people over 22 is £5.35 which at current
exchange rates is $10.70

On 7/5/07, wrb <[EMAIL PROTECTED]> wrote:
>
> 10usd/h? for god's sake
>
> 2007/7/4, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> >
> > Django Users,
> >
> > First let me apologize for this spammy post. I first tried contacting
> > several contractors posted on the Django Project website, but did not
> > have much luck. One person I did get in touch with suggested that I
> > try here as well.
> >
> > I have a game website that I am currently migrating off of Webware to
> > Django, but I could use another set of hands/brains to get things
> > wrapped up over the next 3-6 months.
> >
> > The technology stack is:
> >
> > - Debian (Ubuntu) Linux
> > - Apache
> > - MySQL
> > - Python (Django)
> > - XHTML + CSS
> > - JavaScript (YUI)
> > - CVS
> >
> > High-level Project details:
> >
> > - About 120-160 hours of work remaining
> > - Work can be done remotely
> > - Work when you want (we just need time to sync up via Email and IM)
> > - Looking to keep a slow but steady pace (10-20 hours per week)
> > - My budget is limited (10 USD per hour), so I believe that will limit
> > (by location/cost of living) of who can help
> > - I have a Ubuntu VMWare instance with the entire project, so you
> > won't need to clutter your machine with my software configuration
> >
> > If you are interested, please send me an email directly (let's not
> > bother the whole group) and I will answer any questions you may have:
> >
> > [EMAIL PROTECTED]
> >
> >
> > regards,
> > Shootclub Webmaster
> >
> >
> > >
> >
>
>
> --
> 韦日宝
> wei ribao
>
> >
>

--~--~-~--~~~---~--~~
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: Modify Session in TemplateTag?

2007-07-05 Thread rtconner

Gah dumb groups thinking I was quoting something...

del context['request'].session['some key']
sess = SessionMiddleware()
http = HttpResponse()
sess.process_response(context['request'], http)


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



Modify Session in TemplateTag?

2007-07-05 Thread rtconner

So I realize I'm doing something non-standard here, but still I have
my reasons, and if I can pull this off, it'll make life easier for me
in the future.

.. is it possible to save to the Session within a TemplateTag? I don't
really see how it is, but I'm hoping someone knows something that I
don't.

For fun I hacked this together, which *almost* works. For some reason
it does not immediately modify the session, it waits one page load
before making my changes.

(in Node.render)
>del context['request'].session['some key']
>sess = SessionMiddleware()
>http = HttpResponse()
>sess.process_response(context['request'], http)


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