Re: Quick but authenticated static file content.

2007-02-12 Thread ScottB

On Feb 11, 12:06 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:

> The files will be stored on a general
> filesystem (probably on a large SAN array but I appreciate advice on
> alternatives that can be shared by multiple servers).

An alternative to SAN would be MogileFS (from the same people as
perlbal and memcachd).  It lets you distribute files over cheap disks
that can scale out with your other servers.  It offers redundancy
across servers instead of using RAID.

http://www.danga.com/mogilefs/

> 1. What's the current best practice/preferred web server for serving
> lots of static content (upload and download) quickly and efficiently?
> Is Tux the way to go?

LightTPD (aka Lighty) is a popular web server for static content.  Its
used by some big players such as YouTube and Wikipedia.

http://lighttpd.net/

> 2. I understand that most static content servers get a lot of their
> speed because they can't handle dynamic content. How do I ensure they
> will properly call the authentication&authorization system before
> starting the download/upload?

I don't have any experience of this, but Lighty has a module called
mod_secdownload that lets you handle authentication/authorization in
your application then generates a unique url and redirects the client
to download (fast) from that url.

http://trac.lighttpd.net/trac/wiki/Docs%3AModSecDownload

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



Re: Registration confirmation view

2007-02-12 Thread ScottB

On Feb 11, 3:42 pm, "voltron" <[EMAIL PROTECTED]> wrote:
> I plan on using newForms and the auth module for my site. All of the
> examples I have seen involve extracting form data and creating a user
> in the database immediately, how can I "shortcircuit" this process to
> allow one to confirm ones registration per email?
>
> What is the preferred "Djangoic" way? I was thinking along the lines
> of creating the user-account, disabling it immediately and sending out
> to the given email address a "hash" of the password , this hash must
> be sent back to the server for comparism per email, I would have to
> parse the mail for this value.

There's a good article on B-List about this:

http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration

I've done something similar, but using newforms.  You're on the right
track:

1 - create the user, disable the account, generate and store an
activation token (e.g. in a UserProfile model)
2 - send an email to the user containing a confirmation link with the
token
3 - user clicks link in email to activate account (e.g. http://
www.example.com/accounts/confirm/voltron/a1b2c3d4e5/ )
4 - once confirmed, enable the account

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



Re: Cooki Problem

2007-02-12 Thread ScottB

On Feb 12, 8:06 am, "samira" <[EMAIL PROTECTED]> wrote:
> I want to have two
> kind of cookie: permanent and temporary. Temporary cookie should be
> deleted when browser close. I don't want to use
> "SESSION_EXPIRE_AT_BROWSER_CLOSE" because that will delete all part of
> cookies but I want to temporary part to delete. Can you know how I
> shall do that?

You could leave the main session cookie so it doesn't get deleted, but
add your own temporary cookie to the HttpResponse object returned by
one of your views.  Just call set_cookie on the HttpResponse object;
if you don't specify an age, the cookie you set will expire when the
browser window is closed.  You can read the cookie back in your views
using request.cookies.

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

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



Re: correct limit_choices_to syntax

2007-02-13 Thread ScottB

On Feb 13, 8:06 am, Benedict Verheyen <[EMAIL PROTECTED]>
wrote:
> def get_rooms():
> return Room.objects.exclude(id__in=[patient.room.id for patient in
> Patient.objects.filter(room__isnull=False)])

> I tried limit_choices_to = {'id_in': get_rooms} but this gives me:
> TypeError at /patient/aanpassen/94/
> Cannot resolve keyword 'id_in' into field
>
> limit_choices_to = {'id': get_rooms}
>
> So how can i specify my limited choices?

I think you need to pass the actual values (i.e. the rooms), rather
than a function that returns them.  Also 'id_in' needs two
underscores.  So maybe:

limit_choices_to = {'id__in': get_rooms()}

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



Re: Cooki Problem

2007-02-14 Thread ScottB

On Feb 14, 7:00 am, "samira" <[EMAIL PROTECTED]> wrote:
> we can have two ways to store data in cookie: Session for permanent
> and cookie for temporary. Am I right?

Not exactly.  Data stored in session is held on the server.  The
session middleware uses a cookie to give the client a session id so
that the session data can be tied back to that client.  By default the
session cookie stays on the client for a couple of weeks, rather than
being removed when the browser is closed.

You can add your own cookies to the client to store whatever
information you need.  By default they will be removed when the
browser is closed.  These cookies are not related to the session.

> I used "response.setcookie" but
> my problem not solve yet :( can you tell me how create httpResponse
> object?

Every view function returns an HttpResponse of some sort.  You can add
your cookies to the response before returning it.

For example, if you had:

def index(request):
return render_to_response('index.html')

You could add a cookie before returning the response:

def index(request):
response = render_to_response('index.html')
response.set_cookie('test', value='test cookie was set')
return response

In this or another view you can then get the cookie back using:
request.COOKIES['test']

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



Re: Django over modpython

2007-02-19 Thread ScottB

For VPS hosted based in the UK, I can highly recommend Xtraordinary
Hosting.  I have a basic VPS with them and it's super fast.

http://www.xtrahost.co.uk/xenvps

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



Re: login_required decorator

2007-02-20 Thread ScottB

Hi Frank.

> is there any reason that the login_required decorator doesn't have the
> login_url parameter?

If you want to set the login url to something other than the default /
accounts/login/ you add this to your settings.py:

from django.contrib.auth import LOGIN_URL
LOGIN_URL = '/accounts/signin/'

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



Re: Newforms: Setting field width?

2007-02-21 Thread ScottB

> All my form elements on a newforms form are rather tiny. Is there any
> way to specify the width of these fields?

By default no length is specified for inputs, so they will be whatever
size the browser defaults to.

It's not the prettiest, but if you specify the widget to use, you can
set attributes for that widget, such as "size" for a TextInput.

class SignupForm(forms.Form):
username = forms.CharField(widget=widgets.TextInput(attrs={'size':
100}))

Another way would be to set the sizes using css.

#myform input { width: 100em; }

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



Re: passing a md5 digest string into URL

2007-02-27 Thread ScottB

Hi Giuseppe.

> As i said, i need to pass in my URL a  variable, wich is the
> result of a md5 digest.
> (no private information... only a validation key).
>
> Obviously i tried with
> (r'^users/activate_user/(?P)/', 'views.register'),
> (r'^users/activate_user/(?P[a-zA-Z0-9%\-]+=)/',
> 'views.register'),
> but it doesn't work: Django always return 404.

It works for me if the code ends with a single equals sign.
e.g.
http://localhost/users/activate_user/abc123=/

If you're stuck, maybe you could post a couple of example urls that
give you 404 errors.

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



Re: HttpResponsePermanentRedirect by POST

2007-03-01 Thread ScottB

> How do I do a HttpResponsePermanentRedirect by POST method with
> params?
> Any ideas?

Not sure I understand the question.

Your view can return an HttpResponsePermanentRedirect, telling the
client to go to another url.  However, you can't cause the client to
post values to that url.

You could probably cause the client to post by returning a page which
contains a hidden form and some JavaScript that submits the from on
load.  But that's bad and wrong.  Hopefully you can find a cleaner way
to do what you want.

If you need to pass some information to a different page, you could
store it in session, return your redirect then read it from the
session when the client requests another view.

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



Re: Using Authentication Framework

2007-03-01 Thread ScottB

Hi Matt.

> The problem is that it then trys to serve the css from the wrong url -
> in the server window I get
>
>  "GET /accounts/site_media/default.css HTTP/1.1" 404 2644
>
> whereas the correct path is /site_media/default.css

I think you want the url for your media directory to be full, rather
than relative.

Instead of:

site_media/default.css

use:

/site_media/default.css

That way it won't be affected by the location from which your page is
served.  Whether you are in the root or in accounts, the css will
still come from /site_media.

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



Re: Getting up and running

2007-03-02 Thread ScottB

On Mar 2, 5:49 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I keep getting the following error when i syncdb
>
> raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e
> django.core.exceptions.ImproperlyConfigured: Error loading psycopg2
> module: No module named psycopg2

It looks like you don't have the psycopg2 package installed.  Psychopg
lets Python talk to the Postgres database and it's what Django uses
when your settings file has database engine set like:

DATABASE_ENGINE = 'postgresql_psycopg2'

To check if it's installed you can go in to Python and do:

import psycopg2

If you get an error, it's not installed.  I use Ubuntu and Debian, so
I installed using apt-get python-psycopg2.  If you're using Fink,
there's probably a package for it.  Alternatively, download and
install.  Once installed you should have a psycopg2 directory in
Python's site-packages.  In my case this is at:

/usr/lib/python2.4/site-packages/psycopg2

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



Re: Thoughts about rendering errors below the form field?

2007-03-06 Thread ScottB

Hi Vertigo.

On Mar 6, 9:05 am, "Vertigo" <[EMAIL PROTECTED]> wrote:
> The default HTML rendering of form errors, with method as_table() at
> least, is to display them above the form field. Am I the only one
> concerned with this? :-)

I wanted the error before the form field, but after the label.  I also
prefer to use divs for the layout instead of tables, so I wrote an
as_div() method for the form.  Rather than reimplement _html_output(),
I just call it with some different format strings like:

self._html_output(u'%(label)s %(errors)s %(field)s%(help_text)s', u'%s', '', u'%s', False)

This produces html like this:


Email address:
This field is required.

Enter a valid email address so we can email you to
confirm your account.


Visually it looks something like:

Email address: (<- label)
This field is required. (<- error message)
[] (<- input field)
Enter a valid email address...(<- help text)

So you can change things more to your liking with a single line of
code (the call to _html_output()).  To be consistent, I made a class
called CustomBaseForm which derives from newforms.Form, then all my
forms derive from my base class.

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



Re: Video uploading and converting - queue system?

2007-03-08 Thread ScottB

Hi Henrik.

On Mar 7, 10:47 pm, "Henrik Lied" <[EMAIL PROTECTED]> wrote:
> So I've been thinking about a queue-system. How I should do this I'm
> not sure about. I was thinking about adding an extra field to the
> model (encoded = models.BooleanField), and setup a python script which
> returns all the non-encoded entries. This script then executes the
> os.system()-command, and sets encoded to True.
> I guess I'd have to setup a simple crontab that would run this script
> every 10-20 minute.

I think you're on the right track with this.  I have used a similar
approach in a few situations.  I think it is much more robust to add a
record to a queue and have a separate process do the long running
tasks.  The interface can then check the queue and display the status
of the tasks.

It's more robust in that if you servers have a high load and it takes
5 minutes to encode the video, you don't have to worry about the http
request timing out.  Instead, the user can see their video is
"processing" and continue with other things.  If it fails to convert
the video for some reason, you can show it as "failed" and maybe give
a "try again" option.

If you expect conversion will normally be fast, you can show the user
a progress indicator and use an Ajax call to poll the server and
update the display when it's done.

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



Re: Video uploading and converting - queue system?

2007-03-08 Thread ScottB

Hi Henrik.

On Mar 7, 10:47 pm, "Henrik Lied" <[EMAIL PROTECTED]> wrote:
> So I've been thinking about a queue-system. How I should do this I'm
> not sure about. I was thinking about adding an extra field to the
> model (encoded = models.BooleanField), and setup a python script which
> returns all the non-encoded entries. This script then executes the
> os.system()-command, and sets encoded to True.
> I guess I'd have to setup a simple crontab that would run this script
> every 10-20 minute.

I think you're on the right track with this.  I have used a similar
approach in a few situations.  I think it is much more robust to add a
record to a queue and have a separate process do the long running
tasks.  The interface can then check the queue and display the status
of the tasks.

It's more robust in that if you servers have a high load and it takes
5 minutes to encode the video, you don't have to worry about the http
request timing out.  Instead, the user can see their video is
"processing" and continue with other things.  If it fails to convert
the video for some reason, you can show it as "failed" and maybe give
a "try again" option.

If you expect conversion will normally be fast, you can show the user
a progress indicator and use an Ajax call to poll the server and
update the display when it's done.

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



Re: Bit torrent class

2007-03-14 Thread ScottB

Hi Hubi.

On Mar 10, 12:07 pm, "Hubi" <[EMAIL PROTECTED]> wrote:
> i'm looking for bit torrent class for Django which can scrape
> information (seed, peer) about the torrent file from trackers.

I'm not sure if there is a Python module/library that does this, but
if not it should be pretty easy to get what you need from one of the
BitTorrent clients.  BitTorrent is mostly written in Python, so you'll
just need to figure out which parts are getting information from the
trackers and use that code in your project.

http://dessent.net/btfaq/#linux
http://wiki.theory.org/BitTorrentTrackerProtocol

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



Re: Template Problem

2007-03-14 Thread ScottB

Hi Samira.

On Mar 11, 11:56 am, "samira" <[EMAIL PROTECTED]> wrote:
> Hi every Body, can any body help me? I want to have two folders for my
> templates. One it for general template and other for template related
> to member for example. How I can extend from general folder in
> member ?

Not sure if this is what you mean, but you can extend files in
different directories.

e.g.
{% extends 'base.html' %} -- base.html in same directory
{% extends 'subdir/base.html' %} -- base.html in a subdirectory
{% extends '../base.html' %} -- base.html in parent directory
{% extends '../sibling/base.html' %} -- base.html in another directory
at the same level

You could also have multiple template directories in your settings.py:

TEMPLATE_DIRS = (
'/path/to/templates',
'/path/to/templates/member',
)

Then when you use extends, I believe Django will look in the different
template directories to find the base.  You would probably use
different filenames e.g. base.html and member_base.html.

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



Re: Deployment with Subversion

2007-03-15 Thread ScottB

Hi Vincent.

On Mar 14, 5:16 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Does anyone have tricks to make this process a bit more efficient and
> not catastrophic in case we forget to copy the settings.py file?

I use conditionals inside my settings.py so that one lot of paths/
settings get used on the dev server and another lot get used on the
live server.  You could check automatically if the machine is the dev
server and if not, use the settings for the live server.  That way the
settings get overwritten intentionally.

e.g.

# Check if we are running on the dev server.
# Defaults to using live settings in case live server name changes.
DEV_HOSTNAME = 'dev-server'
from socket import gethostname
LIVE = gethostname() != DEV_HOSTNAME

if LIVE:
DATABASE_ENGINE = 'postgresql_psycopg2'
...etc
else:
DATABASE_ENGINE = 'sqlite3'
...etc

One thing to consider when serving a working copy is all those .svn
directories could be accessible via your web server.  Assuming your
code isn't within your web server's root (which it shouldn't be),
there's probably not much that can go wrong.  Still, it might be worth
checking if you can see anything interesting with something like:

http://www.example.com/myapp/.svn/text-base/

I normally prefer an svn export instead of serving a working copy, for
that reason.

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



Re: How to use Django session without browser cookies support

2007-03-17 Thread ScottB

On Mar 15, 8:33 pm, Atilla <[EMAIL PROTECTED]> wrote:
> What I can think of the top of my head is writing a middleware that
> replaces all your internal URLs in the output, appending to them the
> session ID variable.

Note that your session IDs will be sent in the referrer header and can
be seen by any external sites you link to.  You might want to use a
view to redirect users to external sites and make it so links to the
redirect view do not contain a session id in the url.  That way,
external sites will see your users came from a page like:

http://www.example.com/app/redirect/?url=http://www.externalsite.com

instead of seeing them coming from a page with session id like:

http://www.example.com/app/sessionid123456

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



Re: referrers: to django or not?

2007-03-19 Thread ScottB

Hi Bram.

On Mar 17, 2:17 pm, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> "in the last 7 days your blog/item/whatever has been visited from:
> 7 xhttp://somewebsite.com
> 5 xhttp://someotherwebsite.com

Beware of opening yourself up to referrer spam.  Spam bots can request
pages on your site and pass their own website as the referrer.  This
gets you to list a link to their site.

http://en.wikipedia.org/wiki/Referer_spam

> Should I be thinking Django (and perhaps middleware) or should I be
> thinking about parsing apache logs via a cron?

I suppose it depends how concerned you are about performance.  Apache
is logging the information anyway, so it saves you a write to the
database.  If you are updating stats every day or hour instead of
every request, you could use cron to parse the logs and generate some
static info for your templates to include.  It's probably also a good
candidate for caching.

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



Re: Subversion: How do you set up multiple branches of the same project on the same machine?

2007-03-19 Thread ScottB

Hi Aidas.

On Mar 19, 2:18 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]>
wrote:
> I have a symlink from trunk/someproject to site-packages/someproject
> on my machine.
>
> I need to launch the branched version of the project at the same time.
> So intuitively I create a symlink from branches/somebranch/someproject
> to site-packages/someproject2 to get it to the python path.

Do your projects really need to be in site-packages?  Are they normal
self-contained projects, or does something else import them?

I'm thinking you could have:

/home/me/dev/someproject/
/home/me/dev/someproject2/

Then either use manage.py runserver for each one (with different
ports), or configure Apache/Lighty/whatever to access those two
projects under different urls.  That way, both can run simultaneously.

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



Re: SESSION_EXPIRE

2007-03-21 Thread ScottB

On Mar 19, 6:00 pm, "tyman26" <[EMAIL PROTECTED]> wrote:
> Where do I set the 'SESSION_EXPIRE_AT_BROWSER_CLOSE = True'?  I added
> this to the "settings" file and sync'd the database, but when I close
> the browser the session still stays intact.  Do I have to add this
> when the session is created?

When the session is created, a cookie is set in the user's browser.
If SESSION_EXPIRE_AT_BROWSER_CLOSE is False (the default), the cookie
is set to expire in two weeks.  If it is True, the cookie does not
have an expiry date and so will not be saved by the browser when it
closes.

It sounds like you have an unexpired cookie in your browser for a
session that was created before you changed the setting.  Delete the
cookie in your browser and try again.

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



Re: New Forms/Newbie Question

2007-03-21 Thread ScottB

Hi Jim.

On Mar 19, 8:41 pm, "JimR" <[EMAIL PROTECTED]> wrote:
> how do I retrieve/store the correct key/id for the
> attribute information? I generate a drop-down with the valid
> selections "home," "mobile," etc.) and then want to store it's
> associated id
...
> FORM:
> class RegistrationForm(forms.Form):
> ...
> phone_type = forms.ChoiceField(choices=[(c.description,
> c.name) for c in TelecommuncationType.objects.all()])

There might be a better way, but this is what I did in a similar
situation:

I had a MultipleChoiceField with CheckboxSelectMultiple widget so
users select one or more checkboxes, in my case to specify areas of a
site.

The choices parameter is a list of (area.id, area.name) set like:

# populate choices within form
self.fields['areas'].choices = [(area.id, area.name) for area in
site.areas.all()]

Once the form is submitted and validated, I access clean_data['areas']
to get a list of the ids of all the selected areas.  To get the
objects for these ids I use in_bulk (because there are potentially
several of them).

# populate invitation object within form
invitation.areas = self.site.areas.in_bulk(self.clean_data['areas'])

So for your RegistrationForm, perhaps the choices for phone_type would
be (c.id, c.name).  Then you can set the type of a
TelecommunicationsNumber from a completed form with something like:

tele_num.type =
TelecommunicationsType.objects.get(pk=form.clean_data['phone_type'])

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



Re: Problem importing models in custom data import scripts

2007-03-21 Thread ScottB

Hi Nathan.

On Mar 21, 12:37 am, "Nathan Harmston" <[EMAIL PROTECTED]>
wrote:
> My Project is called pynomics and the app alignments.
> ~/pynomics/alignments/models.py
>
> so in my "Parser.py", I try to import the models file
> from pynomics.alignments.models import *
>
> but I get the following error when I try to run it:
> Traceback (most recent call last):
>   File "Parser.py", line 1, in ?
> from pynomics.pyalignments.models import Interval
> ImportError: No module named pynomics.pyalignments.models

Python can't find the pynomics module to import because it is not in
the search path.

A simple workaround would be to add the path that contains pynomics
(i.e. your home directory) to sys.path in your Parser.py.

import sys
sys.path.append("/home/nathan/")

You can also add the path to a PYTHONPATH environment variable or put
a symlink to pynomics in your site-packages directory (which is
somewhere like /usr/lib/python2.4/site-packages).

> However the import seems to work when I import it in views.py.

Yeah, Django sets it up in the path for you if you do manage.py
runserver.

The next error you'll probably get is about DJANGO_SETTINGS_MODULE not
being set.  This means the Django framework doesn't know where to find
the settings for database connection, etc.

Again in your Parser.py script, try:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'pynomics.settings'

Sorry if I'm a bit vague - I'm new to Python and this is just what
I've figured out.

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



Re: 'module' object has no attribute 'handler404'

2007-03-21 Thread ScottB

Hi konstantin.

On Mar 21, 2:38 am, "akonsu" <[EMAIL PROTECTED]> wrote:
> i have no handler404 defined in my application, so when a 404 is
> raised the server returns internal server error and an error message
> saying 'module' object has no attribute 'handler404' is written in to
> the log. how to make it use the default 404 view?

I added a 404.html file to my templates directory (also a 500.html)
and now Django displays them (assuming Debug = False).  You can use
the standard template inheritance, etc, so your error pages match the
rest of the site.

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



Re: Fwd: Different subdomain for each application (again)

2007-03-25 Thread ScottB

Hi Tom.

On Mar 24, 2:42 pm, Tom Smith <[EMAIL PROTECTED]> wrote:
> A while ago Doug and Eivind asked about using subdomains for each app.
>
> I'd like to do this, but in the example they had a stab at they were
> using Apache whereas I'm using Lighttpd...

One thing you might like to consider is having Lighty map the
subdomain in to the url where it can be matched against your
urlpatterns.

In the Lighty config you can use a regex to match the host.  If the
regex has captures, these are available to be passed to FastCGI using
%1, %2, etc (captures in the rewrite rule are $1, $2, etc).  So in the
Lighty config you can use something like:

$HTTP["host"] =~ "([\w\d-]+)?\.?example\.com" {
... snip ...
url.rewrite-once = (
... snip ...
"^(/.*)$" => "/extraset.fcgi/%1$1",
)
}

Now if you go to blog.example.com, the URL Django gets is /blog.
If you go to blog.example.com/2006/, Django gets /blog/2006/.

This makes it easy to match the subdomain in urlpatterns:

urlpatterns = patterns('',
(r'^blog/$', include('project.blog.urls'),
... etc

The blog app doesn't know anything about the prefix in the url and
doesn't need to know it is running on a subdomain.  The user never
sees the /blog prefix because this happens within the webserver.  I've
had this working, so let me know if you need any more details.

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



Re: django as a platform for a commercial SaaS project?

2007-03-25 Thread ScottB

Hi Walter.

On Mar 24, 3:59 pm, "walterbyrd" <[EMAIL PROTECTED]> wrote:
> If I wanted to create commercial quality hosted software, would django
> be the best solution? The sort of things I have in mind would be very
> database oriented, and involve a lot of forms and reports. I would
> like to be able to easily customize the software.
>
> As much as I dislike microsoft, I wonder if I would be more productive
> with ASP.NET?

For what it's worth, I spent the last couple of years developing in
ASP.NET and the last couple of months developing in Django and I find
I'm much more productive in Django.

It's hard to say if Django is the "best solution" for your particular
app, but there aren't any obvious reasons why it wouldn't do a good
job in a SaaS situation.  Using newforms is definitely a timesaver
when your app has a lot of forms and Django doesn't seem to have any
problems with scalability.  If you have specialised requirements for
security or audit/repudiation type stuff you'll need to figure out how
to do what you want, but that's true of any web framework and mostly
comes down to your design.

Scott

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