Re: Apache mod_python config problem

2007-11-18 Thread Nimrod A. Abing

On Nov 18, 2007 11:29 AM, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
> On Nov 18, 2:24 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > Thanks for the help.  I didn't think about checking permissions.  I
> > have the site working now and I think it was a combination of
> > permissions and file paths.  Here's the httpd.conf file that works:
> >
> > 
> > ServerName  music.sensiblestaffing.com
> > DocumentRoot/home/published/www/django/
> > SetHandler  python-program
> > PythonHandler   django.core.handlers.modpython
> > PythonDebug On
> > PythonPath  "['/home/published/www/django', '/home/
> > published/www/django/musicshare', '/usr/lib/python2.5'] + sys.path"
> > SetEnv  DJANGO_SETTINGS_MODULE musicshare.settings
> > 
> >
> > In PythonPath, removing the trailing slash seemed to correct the last
> > issue I had.  I also noticed that www-data must be the owner of the
> > files with 755 permissions.  It also helped to remove all of the .pyc
> > files before restarting apache.
>
> A trailing slash on entries in PythonPath shouldn't really have made a
> difference. A concern though is why you have /usr/lib/python2.5 listed
> in PythonPath as it shouldn't be required and could cause problems if
> that isn't actually the version of Python that mod_python was compiled
> for.
>
> Also, www-data doesn't need to be the owner of any files provided that
> files were readable to other (o+r) and directories were readable and
> searchable to others (o+rx). The only time that www-data would need to
> be owner is where it might need to modify files.

Two reasons I could think of where the same user running Apache would
have to be the owner of the files being accessed is if you are runing
a CGI script using suExec or if your Apache process needs write access
to files and directories.

As for the trailing slash, apparently some versions of Apache (1.3)
ship with a broken mod_dir that causes strange (and sometimes correct)
behavior when a trailing slash is appended to DocumentRoot. See:

http://httpd.apache.org/docs/1.3/mod/core.html#documentroot
-- 
Best Regards,
Nimrod A. Abing

W http://arsenic.ph/
W http://preownedcar.com/
W http://abing.gotdns.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: Apache mod_python config problem

2007-11-16 Thread Nimrod A. Abing

On Nov 17, 2007 12:24 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Obviously "mydomain" has been replaced as not to publish my domain
> name.  As you can see in the exception, sys.path includes the location
> of my app.  It still doesn't appear to find settings.py.

Make sure www-data can read and traverse your
/home/published/www/django directory.

You may need to:

chmod 0755 /home/published/www/django

if that still does not work, travel up to /home/published/www and see
if you have the correct permissions. Do:

chmod 0755 /home/published/www

Keep traversing up the directory structure until you get the correct
permissions.

HTH.
-- 
Best Regards,
Nimrod A. Abing

W http://arsenic.ph/
W http://preownedcar.com/
W http://abing.gotdns.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
-~--~~~~--~~--~--~---



Command line app using Django is always "Idle in Transaction"

2007-11-09 Thread Nimrod A. Abing

Hello everyone,

I have made a command line app that uses the Django ORM and
transaction management. I followed much of what I have learned from
this thread:

http://www.mail-archive.com/django-users@googlegroups.com/msg32122.html

there are other threads where I got "best practice" hints as well but
the one above is the most relevant. The app has been running as a
daemon without any problems up until recently when I tried to upgrade
Postgres on the server. Somehow the upgrade would get stuck when it
tries to run some conversion scripts (from 8.0 to 8.1) Upgrade did not
manage complete until I shut down the daemon. This also happened when
I tried to run syncdb to add new models. syncdb would hang, apparently
waiting for a lock or something and would only continue if I kill the
daemon.

Before I killed the process, I used ps to view what was going on. And
the daemon process would have something like this right below it in ps
listing:

postgres  7911  0.0  0.4  78244  4452 ?Ss   14:12   0:00
postgres: nimrod nimrod [local] idle in transaction

The whole app is a bit lengthy (mostly daemonization and sanity
checks) so I'll just post some pseudocode of the relevant section:

def processItem(item):
logging.info('Processing %s...' % item)

# Do lengthy processing here. Possibly changing item in the process

try:
transaction.enter_transaction_management()
try:
item.save()

except:
logging.error('Error committing database transaction.')
transaction.rollback()
raise

else:
transaction.commit()

finally:
transaction.leave_transaction_management()

def processItemQueue():
items = Item.objects.filter(item_status =
ItemProcessing.ITEM_STATUS_RAW)

if 0 != len(items):
logging.info('Processing queue.')
logging.info('Need to process %d items.' % len(items))
for item in items:
self.processItem(item)

def run():
while app_is_running:
self.processItemQueue()
time.sleep(180) # Sleep for 3 minutes

At the time I wrote this app, I placed the transaction handling code
right where I thought it would be needed. I was under the impression
that transactions were being entered only when I issue the
transaction.enter_transaction_management() call. I'm sure that
postgres goes into "idle in transaction" when the loop sleeps for 3
minutes. And I can confirm that processItem() is not the section
that's causing the problem. As processItem() will only run when there
are items in the queue, I tried running with an empty queue and I
still get "idle in transaction". Nor is it processItemQueue(), I tried
commenting out the call in the loop and still same problem.

Normally this would not be a problem, in fact I see it as a bonus
since the app is guaranteed a transaction lock. But I'm thinking it
will eventually cause serious problems later on so it's better if it
would not idle inside a transaction.

BTW. I tried settings.DISABLE_TRANSACTION_MANAGEMENT = True and
inserted it somewhere before run() is called. Still I get "idle in
transaction".
-- 
Best Regards,
Nimrod A. Abing

W http://arsenic.ph/
W http://preownedcar.com/
W http://abing.gotdns.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: spam

2007-11-06 Thread Nimrod A. Abing

On Nov 7, 2007 1:47 AM, Derek Anderson <[EMAIL PROTECTED]> wrote:
>
> ok, seriously, is there not something we can do about the porn spam?
> some of us read this list at work on machine's we don't own.  the image
> stuff is becoming a serious problem.

Everyday I tag about 1-3 messages using GMail's in-built spam
filtering button. The number has gone down from about 6-10 every day.
I don't think Google groups do filtering on email sent to groups and I
think the spam filters are trained per account (each account gets its
own spam filter training data). My biggest gripe with Google's
in-built spam filter button is that it tags entire "conversations" and
does not seem to allow you to tag individual messages. So if a Groups
subscriber replies to a spam message his email (and email address)
gets included in my spam filter training data.
-- 
Best Regards,
Nimrod A. Abing

W http://arsenic.ph/
W http://preownedcar.com/
W http://abing.gotdns.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: django and postgres

2007-09-27 Thread Nimrod A. Abing

It's a bad idea to use the 'postgres' user account since this account
is the Postgresql *superuser* account. Which means, with this account
it is possible to do some serious damage to the system catalogs. You
should create a separate Postgres user account and create a database
for it.

First switch to the postgres Unix account, enter your current user's
password when prompted:

$ sudo su -s /bin/bash - postgres

Then, when prompted for the password type in the password that you
would like to use for this database user:

$ createuser -S -D -R -E -P 

Then:

$ createdb -E utf8 -O  

Then edit /etc/postgresql/8.2/main/pg_hba.conf and add the following line:

local   password

Save the file, then run:

$ pg_ctlcluster 8.2 main reload

Log out of the Unix account.

On 9/27/07, Bruno Tikami <[EMAIL PROTECTED]> wrote:
> or, if you haven't, add the line
>
> local   all postgres   password
>
> be aware that this will allow the user postgres (once password authenticated) 
> to access all the databases. If you don't want it, change 'all' to you 
> porject's database name .
>
>
>
> On 9/27/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> >
> >
> > On 27-Sep-07, at 1:32 PM, Heba Farouk wrote:
> >
> > > psycopg2.OperationalError: FATAL:  Ident authentication failed for
> > > user "postgres"
> >
> > edit your pg_hba.conf file and set authentication to 'password'
> >
> > --
> >
> > regards
> > kg
> > http://lawgon.livejournal.com
> > http://nrcfosshelpline.in/web/
> >
> >
> >
> >  > >
> >
>



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



Using a Single Sign-on Server with Django

2007-09-24 Thread Nimrod A. Abing

Hello,

Does anyone know of a single sign-on server that can be used with
Django? Similar to the approach taken by Cosign 
or Pubcookie  but without the fluff that is
LDAP and Kerberos. Just a simple database of users and passwords to
authenticate against, but allows multiple Django-based sites hosted on
the same server to connect to authenticate against it. Each site will
have to keep a separate database for its user profile data if needed
but if there exists a system that has profile management then that
would be nice too.

Thanks in advance.
-- 
_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
-~--~~~~--~~--~--~---



Re: How to automatically apply a method to all fields in newforms subclass?

2007-09-17 Thread Nimrod A. Abing

Just revisiting this thread...

On 9/14/07, Doug B <[EMAIL PROTECTED]> wrote:
>
> I think you can make a custom form field to do your validation check
> for you.
>
> def StrippedField(forms.CharField):
> def clean(self,value):
> #do your validation here

While the solution above would work and I have been using that as
well, I found that there were times that I needed to perform some
post-validation stuff on the field data. The fields would be of
different types but the post-validation operations would be the same.
I did not find it entirely appealing to have to create an entire set
of subclasses to do this, i.e.:

SpecialCharField(forms.CharField)
SpecialBooleanField(forms.BooleanField)
etc...

or the alternative way by using clean_FIELDNAME()

So I was looking for a more generic way of iterating through all or
selected fields and applying a method that modifies their contents.

After looking around a bit in ASPN, I decided to go with a method factory:

class StrippedFieldsForm(forms.Form):
stripped_fields = []
def __init__(self, *args, **kwargs):
super(StrippedFieldsForm, self).__init__(*args, **kwargs)
for name in self.fields:
setattr(StrippedFieldsForm, 'clean_%s' % name,
self.clean_field_factory(name))

def clean_field_factory(self, name):
def _strip_field(self):
field = self.fields[name]
label = self.fields[name].label or name
return self.strip_field(name, label + ' is empty.')
return _strip_field

def strip_field(self, field, error_message):
if (self.clean_data.get(field)):
data = self.clean_data[field].strip()
if (0 == len(data)):
raise forms.ValidationError(error_message)
else:
return data
else:
return ''

It looks like a lot of work to implement and seems sort of pointless
as I'm sure that the subclass way is preferred in most cases. But in
my case, I needed to be able to swap out strip_field() with something
else on a case-by-case basis. As always, am open to using a better
solution, but for the moment this works for me. Hope someone finds
this useful.
-- 
_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
-~--~~~~--~~--~--~---



How to automatically apply a method to all fields in newforms subclass?

2007-09-13 Thread Nimrod A. Abing

Hello,

I have several forms that I subclass from a subclass of newforms:

# newforms is aliased as forms
class StrippedFieldsForm(forms.Form)
def strip_field(self, field, error_message):
if (self.clean_data.get(field)):
data = self.clean_data[field].strip()
if (0 == len(data)):
raise forms.ValidationError(error_message)
else:
return data
else:
return ''

class DerivedForm(StrippedFieldsForm):
# ... fields go here ...

# ... for each field I have to do ...
def clean_field1(self):
return self.strip_field('field1', 'Field 1 contains only whitespace.')
def clean_field2(self):
return self.strip_field('field2', 'Field 2 contains only whitespace.')

This gets tedious as there are forms with 10 or more fields.

My question is, is there another way to apply strip_field to *all* or
a select list of fields automatically? My last resort is to override
form.clean() for StrippedFieldsForm.
-- 
_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
-~--~~~~--~~--~--~---



Re: More than one Django version installed - possible?

2007-08-22 Thread Nimrod A. Abing

I used to do this a while back. Off the top of my head what I did was
unpack 0.96 and the svn versions in separate directories. Then using
the PYTHONPATH environment variable you should be able to specify
which version you want to use.

For example:

0.96 is in...
~/Python/libs/django-0.96/django

SVN version is in...
~/Python/libs/django-svn/django

If you want to use 0.96 version:

export PYTHONPATH=~/Python/libs/django-0.96

If you want to use the SVN version:

export PYTHONPATH=~/Python/libs/django-svn

Note that you need to use the directory *containing* the django
directory in PYTHONPATH

Something similar should work if you are using mod_python using the
SetEnv or PythonPath directives. But this time, you should replace ~
with whatever your home directory is.

HTH.

On 8/22/07, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> Is it possible to have installed (and use in different projects) both
> 0.96 and svn trunk? Any hints?
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
>
> >
>


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



Re: automatic form submission

2007-08-08 Thread Nimrod A. Abing

On 8/8/07, cesco <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I need to retrieve automatically some information from an e-commerce
> site.
> The site doesn't offer any API, so the only way to perform the search
> is via the form they provide. The form is submitted via a POST method
> and the URL doesn't change after clicking the search button even if I
> select different search criteria (which are only checkboxes).
> Do you know of any way to automatically or do you have any suggestion
> on to automatically perform the following?
>
> 1. check a specific checkbox in the search form
> 2. submit the search form
> 3. save in a file the html source of the webpage displaying the search
> results
>
> Any help would be very appreciated.

You can use the httplib.HTTPConnection() to do just that. See here:

http://www.python.org/doc/2.4.3/lib/httplib-examples.html

You should be able to substitute httplib.HTTPSConnection() in place of
httplib.HTTPConnection() if your Python's socket library was compiled
with SSL support.

You might also want to look into pycurl if you want to do more advanced stuff:

http://pycurl.sourceforge.net/

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: Templates escaping ampersand

2007-08-07 Thread Nimrod A. Abing

On 8/8/07, Kynatro <[EMAIL PROTECTED]> wrote:
>
> I'm fairly new to dJango and I'm having a problem with the templating
> system. I'm replacing a block in my base template and trying to pass
> over apostrophe characters as their entity codes (), but the
> template system is converting the ampersand to its entity so the end
> result is  in the rendered HTML. Anyone have any ideas on
> what is causing this?

Hard to tell what's happening from the limited details you gave but I
have two guesses:

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

or

http://www.djangoproject.com/documentation/templates/#fix-ampersands

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: MySQL and InnoDB

2007-08-07 Thread Nimrod A. Abing

On 8/8/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> On Aug 6, 4:16 am, Matti Haavikko <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Can you get the same result with "default-storage-engine=InnoDB" in your
> > my.cnf?
> >
> >  - Haavikko
>
> I believe you can but for other various reasons I'm not able to make
> this change globally.
>
> Does anyone know if adding the DATABASE_OPTIONS config setting adds
> any unneeded overhead?

init_command is run every time a connection is established through
MySQLdb.connection.Connection() so anything you put into init_command
will be executed each time a connection is made to the database. "SET
storage_engine=INNODB" would be "unneeded overhead" under normal
circumstances since it sets a system variable that only affects table
creation.

This is why the docs say that you remove init_command from
DATABASE_OPTIONS once you have created your tables.
-- 
_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
-~--~~~~--~~--~--~---



Re: [OT] pydev

2007-08-05 Thread Nimrod A. Abing

On 8/6/07, Derek Anderson <[EMAIL PROTECTED]> wrote:
>
> i was using the ubuntu packages for eclipse and pydev...(why are they so
> far behind?)

That's because they take whatever is the latest version of software
available at a particular point in time during the 6 month development
cycle. Months prior to a release, the freeze everything to whatever
version was included in the current cycle. If one piece of software
releases a new version past this freeze date, the old version will
*still* be part of the release. The new version *may* be "backported"
into the current release but not unless it's a vital piece of the
system or if there is significant user demand for it. Don't hold your
breath for backports though, case in point is Pidgin.
-- 
_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
-~--~~~~--~~--~--~---



Model Examples page, gone?

2007-08-02 Thread Nimrod A. Abing

Hello,

I was just going through the current docs and wanted to look up some
examples and I noticed that the Model Examples page is gone:

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

though it can still be accessed in the older versions of the docs.

http://www.djangoproject.com/documentation/0.95/models/

Has anything changed in the examples?
-- 
_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
-~--~~~~--~~--~--~---



Re: pydev

2007-08-02 Thread Nimrod A. Abing

On 8/2/07, eXt <[EMAIL PROTECTED]> wrote:
>
> Hi
>
>As I said earlier i don't have (and don't remember) these settings.
> But you're right - it was in eclipse.ini. Now I use Eclipse Europa and
> Java 6 on Kubuntu (32 bit) and I don't have any errors (even null
> references mentioned by Nimrod).

It appears to be a random occurence on my setup tied to
autocompletion. There are instances when autocomplete triggers and CPU
usage spikes up, at times it results in a null reference exception.

Anyway, glad to see you got it working already.
-- 
_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
-~--~~~~--~~--~--~---



Re: [OT] pydev

2007-07-31 Thread Nimrod A. Abing

Hello,

What OS and JRE/JDK are you using? I'm on Linux with Eclipse Europa
running on JDK1.6.0_02. I have never experienced any hangs. I run
32-bit Linux on my laptop and 64-bit Linux on the desktop. On both
systems there comes an exception from time to time complaining about
null references and such and the editor tab does not respond but
usually I just close the editor tab and reopen it and it goes away.

FWIW, I also have desktop bling using Compiz-Fusion enabled on the
laptop. In spite of many reports of problems with Compiz and Java apps
I have never had any problems with Eclipse that could be connected to
Compiz.

One more thing, did you try updating your Eclipse install? My install
is fully updated, though I never experienced a total lock-up while
using Eclipse.

On 8/1/07, Derek Anderson <[EMAIL PROTECTED]> wrote:
>
> hey all,
>
> i'm having a heck of a time using pydev (the eclipse python plugin).  it
> keeps randomly locking up eclipse (unresponsive UI + 100% CPU), usually
> when i switch tabs.  anyone else experiencing this?
>
> thanks,
> derek
>
> >
>


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



Re: Using LimitRequestBody to Limit File Uploads

2007-07-29 Thread Nimrod A. Abing

On 7/30/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> The documentation says:
>
> """Similarly, an 'apache' subdirectory should have been created within
> the package and the script file stored there under the name
> 'django.wsgi'."""
>
> Rather than trying to launch straight into setting up Django, you
> might want to get a simple WSGI hello world application going first.
> For more basic instructions read:
>
>   http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
>
> elsewhere on the same site.

Ok, thanks again. After going through postings on modswgi Google Group
as well as your blog, I'm sold :)

I'm looking at the docs and preparing for eventual migration to mod_wsgi now...
-- 
_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
-~--~~~~--~~--~--~---



Re: Using LimitRequestBody to Limit File Uploads

2007-07-29 Thread Nimrod A. Abing

On 7/29/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> > I would love to try that on my development server but I can't seem to
> > find documentation on how to do it:
> >
> > http://code.djangoproject.com/wiki/ServerArrangements
> >
> > Can someone point me in the right direction?
>
> Available from:
>
>   http://www.modwsgi.org
>
> Django specific integration guide at:
>
>   http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

I'm looking at the Django integration guide but I am confused as to
what I do with the following:

> Using this function, a script file for a Django application which is 
> compatible with mod_wsgi would be constructed as follows:
>
> import os, sys
> sys.path.append('/usr/local/django')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()

Where do I put that? views.py?

Thanks in advance.
-- 
_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
-~--~~~~--~~--~--~---



Re: Using LimitRequestBody to Limit File Uploads

2007-07-29 Thread Nimrod A. Abing

On 7/29/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> We hadn't been able to come up with a way of reproducing the problem
> on demand so hadn't yet been able to investigate. Where people had
> seen this exception it was very rare and very random.

I think the following conditions trigger the exception:

1. Set LimitRequestBody to an arbitrary limit, in our case 15728640
2. Upload a file larger than LimitRequestBody using POST to a Django
app. In the test case that caused the error, the file size is 24952238
(based on our logs).

The case above is for only one file of that specific size for that
specific limit.

If I find the time I will set up a few test cases for this error and
see if I can trigger it on demand.

> I'll link this discussion to that issue as it may help finding
> underlying problem in mod_python.
>
> > I get that traceback emailed to me every time an uploaded file hits
> > the limit set by LimitRequestBody.
> >
> > I am using Django 0.96 and this is on the production server.
> >
> > Someone posted something similar on this list last December but the
> > last question by the OP was never really addressed:
> >
> > http://groups.google.com/group/django-users/browse_thread/thread/162a...
> >
> > Has any progress been made with regards to handling 413 from within Django?
>
> FWIW, how mod_python handle the Apache LimitRequestBody directive is
> wrong. I have it one of my TODO lists to log a bug against mod_python
> for it.
>
> The problem is that mod_python doesn't check whether LimitRequestBody
> would be triggered before actually calling the mod_python handler.
> Thus, that the post data exceeds the limit is only found when
> req.read() of mod_python request object is called and a Python
> exception is generated because of an unknown read error. Well at least
> it normally is an unknown read error. In your case you seem to be
> triggered this other Python bug and getting that error instead.
>
> Now, because a read error of some sort is generated, mod_python
> handlers would normally see it as an unexpected exception and it would
> propagate back and result in a 500 Internal Server Error page rather
> than a 413 error back to the client. Whether Django does anything
> different or still sends back a 500 error page I don't know.

The user reported that he just gets "Connection reset by peer."

> In comparison, in mod_wsgi where I uncovered this problem with
> LimitRequestBody, the code checks to see if LimitRequestBody would be
> triggered before calling the WSGI application. If triggered the code
> immediately returns without calling the application, returning the 413
> error. If an ErrorDocument for 413 is defined that would then be
> invoked, else the standard Apache 413 error page would be returned.
>
> In summary, mod_python LimitRequestBody handling is broken. Even when
> fixed, it would result in it being detected before Django is even
> called and thus only custom error page can be one setup using
> ErrorDocument directive of Apache. This ErrorDocument directive would
> reference a Django URL if desired.

I guess that would be an acceptable fall-back behavior.

> Only other choice when using mod_python is not to use Apache
> LimitRequestBody directive and for your actual Django URL handler to
> check Content-Length of request itself and generate an appropriate 413
> error page. You wouldn't be able to apply it in one go for whole
> Django application.

One reason we turned to using LimitRequestBody is to prevent DoS
attacks on our server. IIRC, Django keeps POST uploaded files in
memory. I don't know if this is still the case in SVN trunk, so please
correct me if I am dead wrong :)

Deferring the actual size check to a Django view would be a bit late
(and useless for our intended purpose) because by that time, Django
and mod_python would have handled the request already.

> If not bound to mod_python because of need to use it for custom
> authentication/authorisation handlers connected to Django, you might
> also try using mod_wsgi instead, where the LimitRequestBody directive
> isn't a problem.

I would love to try that on my development server but I can't seem to
find documentation on how to do it:

http://code.djangoproject.com/wiki/ServerArrangements

Can someone point me in the right direction?

> Hope this helps to explain the issue.

Very informative explanation. Thank you :)
-- 
_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
-~--~~~~--~~--~--~---



Using LimitRequestBody to Limit File Uploads

2007-07-28 Thread Nimrod A. Abing

Hello,

I have recently begun testing LimitRequestBody to limit file uploads.
It works but there are some issues. Whenever the uploaded file hits
the limit, I get "Connection reset by peer". Ideally I would like to
be able to redirect the user to an error page but it seems that Django
tries to run but it hits an exception:

Traceback (most recent call last):

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

 File "/opt/ActivePython/lib/python2.4/site-packages/django/db/transaction.py",
line 194, in _commit_on_success
   res = func(*args, **kw)

 File "/home/preownedcar/djangoapps/preownedcar/CoreApp/views.py",
line 1108, in offer_post
   new_data = request.POST.copy()

 File 
"/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 69, in _get_post
   self._load_post_and_files()

 File 
"/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 50, in _load_post_and_files
   self._post, self._files =
http.parse_file_upload(self._req.headers_in, self.raw_post_data)

 File 
"/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 119, in _get_raw_post_data
   self._raw_post_data = self._req.read()

SystemError: Objects/stringobject.c:3518: bad argument to internal function

I get that traceback emailed to me every time an uploaded file hits
the limit set by LimitRequestBody.

I am using Django 0.96 and this is on the production server.

Someone posted something similar on this list last December but the
last question by the OP was never really addressed:

http://groups.google.com/group/django-users/browse_thread/thread/162a66bf92cc5c37/b33c637c502b669e

Has any progress been made with regards to handling 413 from within Django?
-- 
_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
-~--~~~~--~~--~--~---



Re: transaction commit

2007-07-25 Thread Nimrod A. Abing

On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>
> Nimrod,
>
>  NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>  >> >> Yes, I read carefuly your question and thought the answer was
>  >> >> straighforward.   I don't understand why you don't want decorators, 
> but you
>  >> >> could just check the decorator definition to read what it does and copy
>  >> >> it's code.  All you need is decorator name and grep over django 
> sources :)
>  >>
>  NAA> Aren't decorators usable only in views?
>  >>
>  >> Decorators are python feature.  Django views are regular functions, just 
> as
>  >> any other.
>
>  NAA> Sorry I wasn't very clear on that last message, I meant the Django
>  NAA> db.transactions decorator functions. I am thinking they only work when
>  NAA> you use them in a view. When you try to use them elsewhere, e.g. a
>  NAA> Django-based command line app, see below...
>
> No, you're wrong.  Transaction decorators work not only in view functions.
> They work anywhere in the web app, provided transaction middleware is
> included.

Ah, there we go :) but that's for web apps, though I must admit that I
have never really tried adding decorators to non-view methods. But now
that you mention it, I have a few non-view method call that need it.
So thanks for pointing that out.

After mucking around in the Django sources, I eventually figured out
that I needed the calls to enter_transaction_management() and friends
from within the command line app.

>  NAA> At least that's what I think.  I have a project that required a
>  NAA> separately running process (running as daemon) that needed access to
>  NAA> the Django models. Since the code in the daemon is not run in the
>  NAA> context of a view (no triggering of TransactionMiddleware),
>  NAA> transactions decorators do not work. I get:
>  >>
>  NAA> TransactionManagementError: This code isn't under transaction management
>  >>
>  >> Not having read transaction code, can't say what haven't worked in your
>  >> case.  Definitely, something wasn't initialized :)
>
>  NAA> You're right. The app I am talking about is not a web app, rather a
>  NAA> command line app that I made as a supplement to the web app I made
>  NAA> using Django. Since it makes no sense to reinvent the wheel, I just
>  NAA> used Django's ORM system in the command line app. When I tried using
>  NAA> transactions using the transaction decorator functions I get the error
>  NAA> above. Likely cause is that the command line app is not using
>  NAA> middleware, ergo not using TransactionMiddleware, then I needed a way
>  NAA> to initialize and manage transactions manually.
>
> A ticket in my queue is similar, so I understand you perfectly.
>
> Quick glance on django.middleware.transaction shows:
>
> def process_request(self, request):
> """Enters transaction management"""
> transaction.enter_transaction_management()
> transaction.managed(True)
>
> def process_exception(self, request, exception):
> """Rolls back the database and leaves transaction management"""
> if transaction.is_dirty():
> transaction.rollback()
> transaction.leave_transaction_management()
>
> def process_response(self, request, response):
> """Commits and leaves transaction management."""
> if transaction.is_managed():
> if transaction.is_dirty():
> transaction.commit()
> transaction.leave_transaction_management()
> return response
>
> So in cmd line app you have to call
>transaction.enter_transaction_management()
>transaction.managed(True)
> in initialization and
>transaction.leave_transaction_management()
> in the end.  Not tested, but should work.
>
> --
> Andrey V Khavryuchenko
> Django NewGate -  http://www.kds.com.ua/djiggit/
> Development - http://www.kds.com.ua
> Call akhavr1975 on www.gizmoproject.com
>
> >
>


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



Re: transaction commit

2007-07-25 Thread Nimrod A. Abing

Hello Andrey,

>  NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>  >> Yes, I read carefuly your question and thought the answer was
>  >> straighforward.   I don't understand why you don't want decorators, but 
> you
>  >> could just check the decorator definition to read what it does and copy
>  >> it's code.  All you need is decorator name and grep over django sources :)
>
>  NAA> Aren't decorators usable only in views?
>
> Decorators are python feature.  Django views are regular functions, just as
> any other.

Sorry I wasn't very clear on that last message, I meant the Django
db.transactions decorator functions. I am thinking they only work when
you use them in a view. When you try to use them elsewhere, e.g. a
Django-based command line app, see below...

>  NAA> At least that's what I think.  I have a project that required a
>  NAA> separately running process (running as daemon) that needed access to
>  NAA> the Django models. Since the code in the daemon is not run in the
>  NAA> context of a view (no triggering of TransactionMiddleware),
>  NAA> transactions decorators do not work. I get:
>
>  NAA> TransactionManagementError: This code isn't under transaction management
>
> Not having read transaction code, can't say what haven't worked in your
> case.  Definitely, something wasn't initialized :)

You're right. The app I am talking about is not a web app, rather a
command line app that I made as a supplement to the web app I made
using Django. Since it makes no sense to reinvent the wheel, I just
used Django's ORM system in the command line app. When I tried using
transactions using the transaction decorator functions I get the error
above. Likely cause is that the command line app is not using
middleware, ergo not using TransactionMiddleware, then I needed a way
to initialize and manage transactions manually.
-- 
_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
-~--~~~~--~~--~--~---



Re: transaction commit

2007-07-24 Thread Nimrod A. Abing

Hello everyone,

On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
> Yes, I read carefuly your question and thought the answer was
> straighforward.   I don't understand why you don't want decorators, but you
> could just check the decorator definition to read what it does and copy
> it's code.  All you need is decorator name and grep over django sources :)

Aren't decorators usable only in views? At least that's what I think.
I have a project that required  a separately running process (running
as daemon) that needed access to the Django models. Since the code in
the daemon is not run in the context of a view (no triggering of
TransactionMiddleware), transactions decorators do not work. I get:

TransactionManagementError: This code isn't under transaction management

So being able to use transactions manually would be useful.
-- 
_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
-~--~~~~--~~--~--~---



Re: How to use request.GET??

2007-07-18 Thread Nimrod A. Abing

On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> > I was wondering how do I send a 'favorite_color' GET parameter?  Do I
> > have to use a form to do this that sends data by GET or is there
> > another way to do it?
>
> http://example.com/url_to_set_colour_view/?favorite_color=Blue

Also be sure to URL encode any characters in the paramter that require
it. See section 2.2 of RFC1738.

http://www.ietf.org/rfc/rfc1738.txt
-- 
_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
-~--~~~~--~~--~--~---



Re: Spawning Subprocesses under mod_python

2007-07-16 Thread Nimrod A. Abing

On 7/17/07, Giovanni Giorgi <[EMAIL PROTECTED]> wrote:
>
> I have used the subprocess module with success.
> I have used it only on command line based script under Linux, but I
> think it can work inside mod_python.
> If you plan to use it I suggest you to reboot the apache one a day, to
> prevent yourself againt resource and/or memory leaks.

I did some searching on the archives (something I should have done in
the first place, D'oh!) and found threads with similar problems. The
thing is that while spawning subprocesses work fine on command line
Python programs, it looks like it's a big no-no while under mod_python
because lots of funky stuff can happen.

So it looks like I'm off to write a simple XML-RPC server that will to
handle spawning subprocesses.
-- 
_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
-~--~~~~--~~--~--~---



Spawning Subprocesses under mod_python

2007-07-16 Thread Nimrod A. Abing

Hello,

I'm just wondering if anyone has any experiences spawning subprocesses
under mod_python on Linux/Unix. My specific use case is something in
the line of an os.system() call with the exception that I will be
using its replacement using Popen() as detailed here:

http://www.python.org/doc/2.4.3/lib/node243.html

I want to be able to retrieve the results of the subprocess (file
command) as it is printed on STDOUT and STDERR.

I found this thread from 2006 but it talks about spawning a daemon
process from mod_python. My case is a bit different I think as I only
want to execute an external subprocess, capture its output and have
mod_python go on its merry way.

http://www.modpython.org/pipermail/mod_python/2006-February/020225.html

Anyone else with success/horror stories to tell about spawning
subprocesses under mod_python please share :)

Thanks in advance.
-- 
_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
-~--~~~~--~~--~--~---



Re: Question about AddManipulator/ChangeManipulator

2007-07-10 Thread Nimrod A. Abing

On 7/11/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2007-07-10 at 02:40 +0800, Nimrod A. Abing wrote:
> > Hello,
> >
> > I am currently in the process of porting one of my oldforms-based app
> > to use newforms. I have some blocks of code that use
> > AddManipulator/ChangeManipulator methods. My question is, when
> > oldforms is eventually removed, will AddManipulator/ChangeManipulator
> > get removed too?
>
> Add- and ChangeManipulators are completely features of the "old" forms
> structure. Any functionality they provide should be possible to
> replicate in other ways using newforms (and some Python code).
>
> So, yes, if you're porting to newforms, you should be endeavouring to
> remove any references to AddManipulator and friends.

Thanks for clearing that up.
-- 
_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
-~--~~~~--~~--~--~---



Web Framework Shootout

2007-07-10 Thread Nimrod A. Abing

I was looking around the Net for an objective comparison between the
different frameworks (actually looking for objective comparison
between Django and RoR) available out there. I found this one and I
thought it would be good to share:

http://www.alrond.com/en/2007/jan/25/performance-test-of-6-leading-frameworks/

Searched the archives and I was not able to find any messages with
that link. So there you go...

Most of the comments on that blog are in Russian. I found this blog
while taking a look at nginx webserver (part of investigation as to
what hboasia was running). Found it here:
http://wiki.codemongers.com/NginxDjangoFastCGI
-- 
_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
-~--~~~~--~~--~--~---



Re: Question about AddManipulator/ChangeManipulator

2007-07-09 Thread Nimrod A. Abing

Hi,

Actually this project has already been refactored to use newforms and
as I was reviewing it lately I spotted several methods in my views
where AddManipulator was called. I remember I paid no mind to those
calls since I figured these "magic" methods were part of the model
spec and not part of the oldforms spec.

It would be good if the a Django core developer could confirm its
removal in 1.0 though. There are quite a lot of methods calling
AddManipulator for slightly different purposes and rewriting them.

On another note, has anyone here ever done any security audits (reason
I've been reviewing a lot of my code lately) on core Django code? Can
anyone point me to any resources I can find on the subject?

Thanks again.

On 7/10/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
> Since you haven't got an answer yet...
> I'm not a project developer, so I can't say what their intentions are,
> but having worked extensively using oldforms and recently using
> newforms, I doubt very much that the Manipulator framework will hang
> around for anything other than temporary backward compatibility (and
> therefore my guess is that it would be removed before 1.0). Just as
> importantly, newforms are a vast improvement over the manipulator
> framework and so even for the short term you will probably see payoff
> for your efforts.
> I say "upgradde" for a double dose of formness.
>
>  -rob
>
> On Jul 9, 11:40 am, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I am currently in the process of porting one of my oldforms-based app
> > to use newforms. I have some blocks of code that use
> > AddManipulator/ChangeManipulator methods. My question is, when
> > oldforms is eventually removed, will AddManipulator/ChangeManipulator
> > get removed too?
> >
> > Thanks in advance.
> > --
> > _nimrod_a_abing_
> >
> > http://abing.gotdns.com/http://www.preownedcar.com/
>
>
> >
>


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



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



Re: Password Logistics Help Needed

2007-06-27 Thread Nimrod A. Abing

On 6/27/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
> At the moment, the game can only read md5 or plain-text passwords, and
> I know that Django has the hash$salt$hash (or something. :P) way of
> doing it. So I can't just copy the password from the User model to the
> account table since the game will choke on that data. So is there any
> way I can store two sets of the password? One in the user model that
> gets copied as md5 or plain-text to my accounts table?

The usual route I go with when trying to extend on the User model is
to create a new model and link it to the User model. For example:

class UserExt(models.Model):
user = models.ForeignKey(User)
# ... other fields that you need here

def __init__(self, user):
self.user = user
# ... other stuff that you need to do here

# ... other methods you need here

In your case, you can just create a UserExt model, add a password_md5
field, set that field when creating or updating a user record and save
the user_ext object.

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: all on one server release, ballpark?

2007-06-26 Thread Nimrod A. Abing

On 6/26/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> I don't want to sound discouraging, but if the answer is at all critical
> to your operation, you can't trust any numbers you get here. They will
> not have the same usage patterns as yours. Benchmark, benchmark,
> benchmark is the only way.

FWIW, I use this:

http://www.joedog.org/JoeDog/Siege

to do stress and load testing as well as benchmarking.

In most of my cases, even a modest machine (1GB memory, dual-core
Intel [EMAIL PROTECTED]) can handle up to 1,000 hits per minute. By hits I mean
hits to the Apache server running mod_python with the Django app. The
first choking point you're likely to come up with is bandwidth limits.
But as Malcolm said above, your use case may not be the same as
everyone else's and you should benchmark your own app to determine
what your server can handle.

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: Ticket #3297 & Newforms Image Uploading

2007-06-22 Thread Nimrod A. Abing

On 6/23/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> > Can't paste the code from the actual app (am under NDA) but the logic
> > in saving the image from form data is here:
> >
> > http://dpaste.com/12731/
>
> The only problem with this, and probably why I'm looking to use #3297
> (which actually didn't work too well anyway), is because I have as
> many as 15 file upload fields on one page. All the examples I've seen
> only take care of one image on a certain form at a time and I don't
> want to duplicate the code up to 15 times.

BTW, Had a typo in the dpaste code. Line 19 should say:

img_obj.save_image_file(uploaded['filename'], uploaded['content'])

You don't have to duplicate code, well not duplicate too much. That's
why the image validation method in the form is separate from the
*_clean methods. In my app, I had to allow up to four simultaneous
uploads. You have to set a limit to the number of uploads because if
you don't you will be bound to hit the limits of your server anyway.

Create a form with the number of image fields numbered in sequence. For example:

img_fld1
img_fld2
img_fld3
...

Then when you do your processing in your view, simply wrap the code
that saves the images in a loop:

for n in range(0, MAX_NUM_UPLOADS):
img_manip = ImageAttachment.AddManipulator()
img_obj = img_manip.save()
uploaded = clean_data['img_fld%d' % n]
obj.save_image_file(uploaded['filename'], uploaded['content'])

For validation, I haven't tried it yet, but I think you should be able
to implement it using __getattr__ to handle it. That way you don't
have to duplicate validation code.
-- 
_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
-~--~~~~--~~--~--~---



Re: Ticket #3297 & Newforms Image Uploading

2007-06-22 Thread Nimrod A. Abing

On 6/22/07, Dirk van Oosterbosch, IR labs <[EMAIL PROTECTED]> wrote:
> This is what I did for the field validation http://dpaste.com/12715/
>
> the code to save the field data is in the view that uses this form.
> Nice! Would you maybe be willing to share your view code too?

Can't paste the code from the actual app (am under NDA) but the logic
in saving the image from form data is here:

http://dpaste.com/12731/

Oh, and make sure you add the following enctype attribute to your form:


...

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



Re: Development / Production Setup

2007-06-21 Thread Nimrod A. Abing

See: http://dpaste.com/12716/

What you can do is setup a conditional like that in your settings.py
where settings will be loaded based on your current hostname. This is
what I have been doing for quite some time now and seems to work well.

For templates, you have to set URL_PREFIX, MEDIA_PREFIX, BASE_URL and
others in your Context so that you can use them in your templates.
Here is how I use them:

URL_PREFIX - Used in hyperlinks to relative URLs
MEDIA_PREFIX - Used in URLs for media files such as CSS
BASE_URL - Used whenever absolute URLs are needed

On 6/22/07, marknca <[EMAIL PROTECTED]> wrote:
>
> I've been hacking around and googling for a little while now and can't
> seem to track down a solution to what should be a pretty straight
> forward problem.
>
> The situation
> 
> I'm trying to setup a nice workflow between my development environment
> and my production environment. I would like to be able to move changes
> from development to production with a minimum of hassle.
>
> Production setup
> =
> I'm serving all the dynamic pages using Apache/mod_python. All static
> content (images, scripts, styles, etc.) are served from a _different_
> subdomain running lighttpd. This setup seems to work well and is in
> line with what's recommended in the documentation (with the exception
> of the different subdomain).
>
> domain.tld => Django running on Apache/mod_python
> sub.domain.tld => static content served from lighttpd
>
> Development setup
> ===
> I've setup development much the same way. The difference here is the
> server software. My development machine is Mac and my production
> server is running Ubuntu. The development environment is running
> straight from IP. So I've got:
>
> ip:8000 => Django running on manage.py
> ip:80 => static content served from Personal Web Sharing (basically
> Apache)
>
> Django configuration
> 
> I have 2 settings.py files (settings.py.development &
> settings.py.production). One for development and one for production.
> Each has the settings for the servers in the specific environment.
> Right now I simply copy whichever settings.py.* file to settings.py
> for the environment I'm working in at the time.
>
> Problem
> ===
> Templates! I'd like to refer to my local static files when running in
> my development environment. How do I setup the templates to use the
> proper static files.
>
> Right now my templates include lines like:
>
> http://sub.domain.tld/styles/base.css;
> type="text/css" media="screen" />
>
> I'm obviously missing something basic. I'm 99% sure I should be able
> to say something like:
>
>  media="screen" />
>
> I have looked around for a solution but everything seems to point to
> the Site object (which requires a different entry in the database
> which I want to avoid, development should be a near exact mirror of
> production) or passing a variable through a view (these changes should
> be global).
>
> I'm new so please be gentle.
>
> Thanks in advance,
> Mark
>
>
> >
>


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



Re: Ticket #3297 & Newforms Image Uploading

2007-06-21 Thread Nimrod A. Abing

On 6/22/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> RE: http://code.djangoproject.com/ticket/3297
>
> I'm wondering if anybody has actually used this patch for a production
> site. If not, then I'll put off a certain feature of my site until
> later. The patch is really tempting though, so I wanted to get a
> better outlook of experiences before taking the leap.

You can always write the code to process File/Image fields in the view
or just extend your form to handle them properly. I have managed to do
so either by processing in the view or extending the form. As of now,
all processing of all forms occur in the view and validation for file
and image fields in a method of the form.

This is what I did for the field validation http://dpaste.com/12715/
the code to save the field data is in the view that uses this form.

There is also a recent thread discussing this very same issue. There
are also good solutions there so check them out.

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: Hypothetical: Customizable Member Pages

2007-06-20 Thread Nimrod A. Abing

Hello,

Django does not support this out of the box. If you plan to use the
built-in auth module, you can extend it by creating Profile and
UserStyle model which would presumably store details about the user's
profile (fields not already in the default User model) and user's
custom style. Can't tell you which one, but that's how I did it for
one site I made with Django. Not really sure if it's a good idea to
allow users to enter arbitrary HTML code. I mean, just look at what
happened to MySpace and Friendster :) It's better to just allow users
to select from a set of predesigned templates and then allow them to
customize the CSS stylesheets.

HTH.

On 6/21/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> I'd like to build a site in which members have the ability to
> customize the look of their profile using HTML, CSS and template tags
> that we'd provide to the member. So, I want to know if Django supports
> this or not, as well as how difficult it would be to implement. Best
> case scenario would be a customization experience like that of
> Geocities or Yahoo!Pages, but experiences that parallel to say,
> Wordpress.com or MySpace would work too.
>
> This feature is a show-stopper, since the market I'll be gearing this
> to almost requires features like this to be there.  So am I dreaming
> that this can be done? Has anybody else attempted something like this
> yet?
>
> Thanks. :)
>
> ~ Bryan
>
>
> >
>


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



Re: Captcha module Version 1.1 ready for testing

2007-06-15 Thread Nimrod A. Abing

On 6/15/07, Martin Winkler <[EMAIL PROTECTED]> wrote:
>
> Am Thu, 14 Jun 2007 12:00:11 +0800
> schrieb "Nimrod A. Abing" <[EMAIL PROTECTED]>:
>
> > Are you planning to implement a configuration to allow in-memory
> > images?
>
> One thing that annoys me with in-memory images is that you have to
> change your urls.py, and I want the CaptchaField as unobtrusive as
> possible. Furthermore this method needs some kind of session data
> stored somewhere, and therefore also cookies. All this annoys me a bit,
> to be honest.

Heheh, you nailed it right there. My own implementation requires both
a urls.py entry as well as session variables. Modifying urls.py is not
really a big issue with me. However, things get problematic when the
user does not have cookies enabled.

> > Characters that can confuse users have been removed from this set. But
> > some fonts are more legible than others, so it should be possible to
> > configure the characters to use. Are considering implementing this?
>
> Good idea! Although I already have used an incomplete alphabet for
> this, it seems natural that developers want to use their own "alphabet"
> - which might be only digits, and no characters.
> So I made a nice configuration possibility for my captcha module. You
> can define it in your settings.py, and also adjust individual forms, if
> you wish.

That's great!

> > 3. No "twists" are applied to characters. I have found that distorting
> > characters tends to confuse users even more. Will there be a
> > configuration that will disable "twists"?
>
> Yes. You can specify rotation, sizes, vertical positions and other
> values according to your needs. The only thing that is not so elegant
> is: all characters are aligned on top. That means that a lowercase
> character might look as if it is superscript. If you only use uppercase
> and numbers, then this is no problem.
> (BTW: The user can enter only lowercase characters - the captcha test
> is also successful, even if the image also shows uppercase characters)

Yes, that was actually one of the requirements for my project: to make
sure that lazy users are taken into account :)

I will be downloading your module and testing it out soon. If I have
patches for your module, do I send it here on django-users or can I
send to you directly?
-- 
_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
-~--~~~~--~~--~--~---



Re: App.objects.get(user='John') error

2007-06-14 Thread Nimrod A. Abing

On 6/15/07, Vincent Nijs <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have the following model
>
> class App(models.Model):
> user = models.ForeignKey(User, unique=True, editable=False)
>
> In a view I now want to check if a user is indeed in the database table. I
> tried the following
>
> user_exists = Application.objects.get(user='john')
>
> But this give the following error:
>
> invalid input syntax for integer: "john"

If you are using the User model from django.contrib.auth.models then
you can check directly:

user_exists = False
try:
u = User.objects.get(username='john')
user_exists = True
except User.DoesNotExist:
pass # or do something here

or following your code above:

user_exists = False
try:
u = App.objects.get(user_username='john')
except User.DoesNotExist:
pass # or do something here

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: Captcha module ready for testing

2007-06-13 Thread Nimrod A. Abing

Hello,

I am about to try your module and I haven't downloaded it yet but I
have a few questions and some suggestions. I have my own CAPTCHA
module too which is slightly different from yours in some respects:

1. It does not need a dedicated directory to save image files. Images
are created in-memory and sent to the user's browser. So no need for
cleanup scripts or anything else. Are you planning to implement a
configuration to allow in-memory images?

2. The characters used in the generated words can be configured. It
currently defaults to this set:

CDEFHJKLMNPRTUVXY479

Characters that can confuse users have been removed from this set. But
some fonts are more legible than others, so it should be possible to
configure the characters to use. Are considering implementing this?

3. No "twists" are applied to characters. I have found that distorting
characters tends to confuse users even more. Will there be a
configuration that will disable "twists"?

My code is based on the one found here:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440588

I really hope your module gets included in contrib since I really like
the "one standard way" for doing things approach.

On 6/13/07, MartinWinkler <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I just uploaded the captcha module I recently mentioned to
> http://django.agami.at/media/captcha/
>
> Please take a look at it and tell me what you think of it. I really
> hope this module can be put into the trunk on django.contrib some day.
> Maybe one of the lead developers can take a look too - after any rough
> edges are eliminated?
>
> And I am really committed to maintain this module, since it's my
> little baby ;-)
>
> Martin
>
>
> >
>


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



Re: Handling Very Large File Uploads and Cookie-less Visitors

2007-06-13 Thread Nimrod A. Abing

Hello,

Glad to see the issue with large file uploads is being addressed. I'll
have to wait until things settle with regards to this issue and until
the patch finds itself in an official stable release.

As for sessions, sounds like a good idea to implement the defense
against session DoS as middleware. Has someone else worked on this
already? If not, it will make for a good first stab for me at writing
middleware.

On 6/13/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2007-06-13 at 13:53 +0800, Nimrod A. Abing wrote:
> > Hello,
> >
> > Regarding very large file uploads, I know this probably gets asked a
> > lot and I've found one thread that comes close to what the answer I'm
> > looking for:
> >
> > http://groups.google.com/group/django-users/browse_thread/thread/ca95963aaa33ce1e/c69fb3381885f9a7
> >
> > This thread was posted about a year ago and I cannot find any
> > follow-ups to this discussion. I am running Django using mod_python
> > and my question is: What happens when a very large file is uploaded?
> > Does it all get stored in memory or is it stored in a temp file and
> > accessed as a byte stream?
>
> See ticket #2070. The final patch there is awaiting some review time
> from one of the core developers, but should be pretty close to final
> now.
>
> >
> > I want to be able to allow very large file uploads but I want to make
> > sure an upload does not use up all the memory on the machine.
> >
> > Regarding cookie-less visitors or visitors with cookies disabled on
> > their browser or proxy. Django, with the SessionMiddleware, will
> > always create a new session and send a new session id as a cookie to
> > the browser. Even with just the HEAD script from libwww-perl, I am
> > able to get the site to issue new sessions with every HEAD request.
> > What happens if a script kiddie hammers the site with so many HEAD
> > requests?
>
> The difficulty is distinguishing between when the user needs a session
> and when they don't. If your site uses the session middleware and a DOS
> attack of this nature is possible, you need to defend against it at a
> higher layer (web server or firewall). Django doesn't track the IP
> address for session cookies (since they aren't tied to a particular IP
> address), so there's no way to determine the problem exists at the
> Django level.
>
> You could build a middleware that tracks this information fairly easily,
> though, and use that as a defensive layer as well.
>
> > Do dead/unused sessions pile up on the sessions table? Does
> > Django do anything to mitigate this or at least clean up dead/unused
> > sessions automatically?
>
> No. However, there is a script in django/bin called daily_cleanup.py
> that you can put in a cronjob to clean up expired sessions. Again,
> because of lack of IP address tracking or anything of that nature, only
> expired cookies can be cleaned up by this process.
>
> Regards,
> Malcolm
>
>
> >
>


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



Handling Very Large File Uploads and Cookie-less Visitors

2007-06-12 Thread Nimrod A. Abing

Hello,

Regarding very large file uploads, I know this probably gets asked a
lot and I've found one thread that comes close to what the answer I'm
looking for:

http://groups.google.com/group/django-users/browse_thread/thread/ca95963aaa33ce1e/c69fb3381885f9a7

This thread was posted about a year ago and I cannot find any
follow-ups to this discussion. I am running Django using mod_python
and my question is: What happens when a very large file is uploaded?
Does it all get stored in memory or is it stored in a temp file and
accessed as a byte stream?

I want to be able to allow very large file uploads but I want to make
sure an upload does not use up all the memory on the machine.

Regarding cookie-less visitors or visitors with cookies disabled on
their browser or proxy. Django, with the SessionMiddleware, will
always create a new session and send a new session id as a cookie to
the browser. Even with just the HEAD script from libwww-perl, I am
able to get the site to issue new sessions with every HEAD request.
What happens if a script kiddie hammers the site with so many HEAD
requests? Do dead/unused sessions pile up on the sessions table? Does
Django do anything to mitigate this or at least clean up dead/unused
sessions automatically?
-- 
_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
-~--~~~~--~~--~--~---



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

2007-06-10 Thread Nimrod A. Abing

Hello,

Prior to switching to GMail exclusively, I used to use Outlook or
Outlook Express. I had the same problem that you have now, so I
understand where you're coming from. I used to use a  modified
spambayes filter that would modify the Subject field and add a prefix
to it (e.g., SPAM, [LISTNAME]). Sadly, I lost that modification a long
time ago when I switched to Linux and began using procmail for the
same purpose.

Anyway, just want to point out that there is another solution to your
problem and a Pythonic one at that :)

See here:

http://spambayes.sourceforge.net/applications.html

Note that this plugin requires Outlook 2000 and above and will not
work on Outlook Express.

IIRC, I modified it so that it skipped the bayesian filter
(consequently bypassing storage of the bayesian stats for the message
body) whenever spambayes is given an email from a mailing list and
just modified the subject line and sent it on its merry way to my
inbox where it got filtered to the correct folder.

HTH.

On 6/10/07, Mike Schinkel <[EMAIL PROTECTED]> wrote:
>
> Chris Moffitt  wrote:
> >  Not to pile on but if you'd like a google mail account for list
> > purposes,
> that's always an option. It has a very nice way of allowing you to tag
> messages and file them accordingly.  You can also use pop if you want
> to consolidate with your other mail boxes.  Procmail is also a handy
> option..
>
> Here's what I did (it's a nasty hack, but we'll see if it works.) I
> create a user account for my personal domain ([EMAIL PROTECTED])
> and their mail server let me modify the subject like tagging it with
> [django] and it works.  Of course now I have another account at Google
> I have to keep track of, and I have to login and logout between
> multiple Google accounts if I want to interact with the Django-users.
>
> Sigh, this stuff shouldn't be this convoluted.
>
> --
> -Mike Schinkel
> http://www.mikeschinkel.com/blogs/
> http://www.welldesignedurls.org
> http://atlanta-web.org - http://t.oolicio.us
>
>
> >
>


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



Re: passing foreign key via post

2007-06-09 Thread Nimrod A. Abing

On 6/10/07, Car <[EMAIL PROTECTED]> wrote:
>
>
> > Why not create it there? That is the moment you have all the data you
> > need and all you're doing is calling a constructor. The code you've
> > written there is a pretty normal pattern for taking form information and
> > putting it into a model.
>
> Because it forces me to make different view for each model.
> Its very difficult for novice to understand which logic should be
> placed in views, which on models.
> Is there a resource with django-patterns or good programming
> practices ?

What are the chances of those different views only containing minor
variations? If you find yourself duplicating (copy-paste) parts of a
view between views, then it's probably better for you to move oft
duplicated code into a function.

If you don't like putting Model instantiation and initialization in
your views, you can create a static method for each Model. For
example, see:

http://dpaste.com/11939/

which is based on your original code.

As for programming practices, look for the book "Python Programming
Patterns" by Thomas W. Christopher published by Prentice-Hall. I must
caution you though that most of the material there assumes at least
programming experience and at least some knowledge of Python.

For online resources, I find myself coming back to the "Charming
Python" series of articles on IBM developerWorks:

http://www.ibm.com/developerworks/search/searchResults.jsp?searchType=1=dW=dW=charming+python

HTH.
-- 
_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
-~--~~~~--~~--~--~---



Re: Scalability where file uploads are involved

2007-06-08 Thread Nimrod A. Abing

On 6/9/07, ZebZiggle <[EMAIL PROTECTED]> wrote:
>
> If your focus is on images, I can't recommend this utility strong
> enough:
>
> http://www.aurigma.com/

Bookmarked :)

Although we only allow as many as four images per upload session, I
have to entertain the possiblity that my employer will ask for the
ability to upload more than one image. Thanks!
-- 
_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
-~--~~~~--~~--~--~---



Re: Scalability where file uploads are involved

2007-06-08 Thread Nimrod A. Abing

On 6/9/07, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On 6/7/07, Nimrod A. Abing <[EMAIL PROTECTED]> wrote:
> > The only thing I can think of right now is to share a directory on the
> > dedicated media server and have each server in the Django cluster
> > mount that share either through NFS or Samba. But I don't think it's a
> > good idea to do it this way.
>
> We do it this way, and it works just fine. NFS over a dedicated GigE
> link is nearly indistinguishable from a local drive.

What about write deadlocks? How do you deal with them if they occur?
-- 
_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
-~--~~~~--~~--~--~---



Re: Scalability where file uploads are involved

2007-06-07 Thread Nimrod A. Abing

Thanks for this suggestion. Although there would be a slight delay
while the media server syncs up with the Django servers I think this
solution is more feasible.

On 6/8/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2007-06-08 at 00:38 +0800, Nimrod A. Abing wrote:
> > The only thing I can think of right now is to share a directory on the
> > dedicated media server and have each server in the Django cluster
> > mount that share either through NFS or Samba. But I don't think it's a
> > good idea to do it this way.
>
> Or just copy the images across to the target machine. You could either
> do this as part of your model's save() method or initially store them on
> the Django server and have a cronjob periodically copy them across to
> the analogous directory on the image server.

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



Scalability where file uploads are involved

2007-06-07 Thread Nimrod A. Abing

Hello,

I am currently doing research on scaling one of the sites I made using
Django. I have looked at Chapter 21 of the in-progress Django Book. I
plan to follow the track recommending 3 django servers behind perlbal
+ 1 dedicated media server + 1 dedicated database server.

The current setup for the site I am working on uses a single machine
for the whole site. I have Apache + mod_python on one IP address
serving Django requests. For media, I have lighttpd running on another
IP address on the same machine. Postgresql is also running on the same
machine.

This site allows users to upload pictures. Those uploaded pictures are
then served by lighttpd. While this works quite well in our single
machine setup I am dumbfounded as to how to handle file/image uploads
when we finally move to a load-balanced setup with a dedicated media
server.

The only thing I can think of right now is to share a directory on the
dedicated media server and have each server in the Django cluster
mount that share either through NFS or Samba. But I don't think it's a
good idea to do it this way.

Does anyone know how else this can be done?

Thanks in advance.
-- 
_nimrod_a_abing_

http://www.preownedcar.com/
http://abing.gotdns.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: Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

On 5/17/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> > Already done, though under-documented.
> > http://www.djangoproject.com/documentation/templates/#django-contrib-markup
>
> Ah, here, too:
> http://www.djangoproject.com/documentation/add_ons/#markup

Thanks for all the pointers. I am incorporating them into my app now :)
-- 
_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
-~--~~~~--~~--~--~---



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

On 5/17/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, Nimrod A. Abing <[EMAIL PROTECTED]> wrote:
> > Can anyone here provide pointers on how to get flatpages to work
> > properly under Apache and mod_python?
>
> From your custom 404, you'll want to return
> django.http.HttpResponseNotFound rather that HttpResponse.

Ah, that fixed it! Thanks! Also fixed my custom 500 handler to return
HttpResponseServerError.

> Also, are you using flatpage middleware or view?

I am using middleware as described in the docs. I don't see how to use
flatpages as a view in the docs. How do you do that? Also how does one
inject custom Context variables when rendering flatpages?

As for using textile, I am planning on creating a filter for it. But
if someone has already done so already please point the way.

Thanks.
-- 
_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
-~--~~~~--~~--~--~---



Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

Hello,

I am using Django 0.96 and I am currently having problems getting
flatpages middleware to work under Apache with mod_python. I am pretty
sure this is mod_python related since flatpages work fine using the
development server.

I have found at least one thread the mentions this problem, it's from
Aug 2006. The OP said he would take a look to see what the problem was
but did not post a follow-up.

http://groups.google.com/group/django-users/browse_thread/thread/eddadaacfc34aef9/194ee9abebecf6b6?lnk=gst=flatpages=5

The gist of it is that instead of rendering the flatpage it just keeps
rendering the 404 page when I run it on the production server.
However, using the development server flatpages work as expected. If
it helps any, I also have handler404 and handler500 point to a custom
handler.

below is the custom handler404:

def page_not_found(request):
c = getDefaultContext(request)
t = loader.get_template('404.thtml')
return HttpResponse(t.render(c))

Note I am using .thtml extension for templates only because Eclipse
with WTP chokes when editing Django templates.

getDefaultContext() above sets up the Context object containing
important variables used in the templates.

Can anyone here provide pointers on how to get flatpages to work
properly under Apache and mod_python?

One other thing... Is it possible to use Textile for flatpages too?

http://cheeseshop.python.org/pypi/textile

Thanks in advance.
--
_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
-~--~~~~--~~--~--~---