Capturing common data from all URLs

2009-12-02 Thread Dave Dash
Hi,

I'm working on porting a legacy site (addons.mozilla.org) where all
urls begin with /locale/app/:

e.g.

https://addons.mozilla.org/en-US/firefox/
https://addons.mozilla.org/ja/firefox/addon/5890
https://addons.mozilla.org/en-US/thunderbird

and in some cases, the application is not needed:

http://www.mozilla.com/en-US/about/legal.html

I know I can use django-localeurl to capture the locale, but I'm
wondering if there's a more generic middleware that can capture
anything (and store it in the request object) based on configuration?

Cheers,

-d

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: django.core.mail - DEFAULT_FROM_EMAIL not employed

2009-02-20 Thread Dave Dash

I started experiencing this too... I can't tell if this is Gmail or
not.  I know I send email via SMTP from Gmail masqueraded with other
aliases.  So I feel that something is getting munged.  Either in the
mail library or with Gmail's servers.

On Jan 28, 3:02 am, funkazio  wrote:
> Right! Thanks!
>
> The SERVER_EMAIL setting works properly with a NOT-authenticated smtp
> server, yet using an authenticated server (at least the one I
> tried: Gmail) the SERVER_EMAIL is overridden by the EMAIL_HOST_USER.
> Maybe that should be properly verified with several server and
> modified or documented in case it is not a gmail-specific behaviour.
>
> Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django.core.mail - DEFAULT_FROM_EMAIL not employed

2009-02-20 Thread Dave Dash

I started experiencing this too... I can't tell if this is Gmail or
not.  I know I send email via SMTP from Gmail masqueraded with other
aliases.  So I feel that something is getting munged.  Either in the
mail library or with Gmail's servers.

On Jan 28, 3:02 am, funkazio  wrote:
> Right! Thanks!
>
> The SERVER_EMAIL setting works properly with a NOT-authenticated smtp
> server, yet using an authenticated server (at least the one I
> tried: Gmail) the SERVER_EMAIL is overridden by the EMAIL_HOST_USER.
> Maybe that should be properly verified with several server and
> modified or documented in case it is not a gmail-specific behaviour.
>
> Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Saving a new image via the model

2009-02-19 Thread Dave Dash

Using r9679 (I can svn up if needbe ;) )

How exactly do I save my new resized image?  I couldn't quite find any
documentation on this either.

The "easy" way almost seems to do it by writing out the file on my own
and just setting the imagefield to the filename... but there seems
like there should be a more integrated way.


Thanks,

-d

See  Code:


@login_required
def add_image(request, slug, item_slug):

if request.method == 'POST':
form = NewMenuItemImageForm(request.POST, request.FILES)

if form.is_valid():
handle_uploaded_image(request.FILES['image'])
return HttpResponseRedirect('/')
else:
form   = NewImageForm()

return render_to_response('add_image.html', locals(),
context_instance=RequestContext(request))

import Image, StringIO, md5
def handle_uploaded_image(i):
# resize image
imagefile  = StringIO.StringIO(i.read())
imageImage = Image.open(imagefile)

(width, height) = imageImage.size
(width, height) = scale_dimensions(width, height,
longest_side=240)

imagefile = StringIO.StringIO()
imageImage.resize((width, height)).save(imagefile,'JPEG')
filename = md5.new(imagefile.getvalue()).hexdigest()+'.jpg'

# create MII

mii = MyItemImage()
# mii.image.save(imagefile.getvalue(), filename)
# mii.save()
# imagefile.close()
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django-like PHP framework?

2009-01-05 Thread Dave Dash

I did a lot of symfony stuff on the side about a year ago, and now
it's the framework that I we use for our frontend servers at
Delicious.com.  It was through symfony that I found out about Django,
and started using it quite a bit... so I know a bit about the two
frameworks.  Or rather, I know a lot about symfony, but much of that
is being replaced with stuff I'm learning about Django.

As PHP MVC frameworks go, symfony is great.  It borrows from where it
needs to, to give you a good suite of tools.  The direction it is
heading in is also nice.

The new 1.1/1.2 series supports Doctrine which was a lot nicer than
Propel when Iast looked at the two.

The nice thing about using symfony is the developer of symfony uses
Django from time to time, and borrows from it where appropriate.  I'd
wage that you'd see more in common with Django and symfony than any
other PHP framework.

Cheers,

-d

On Jan 5, 5:31 am, "thi.l...@gmail.com"  wrote:
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How should I handle dynamically generated images?

2008-12-26 Thread Dave Dash

I currently serve up images via the DB vs. filesystem.  I did this in
order to keep the data in one place, but I now regret it.

I'd recommend overriding the delete() of your image class to take care
of deleting the related image from your storage.

Depending on your needs and the amount of data, you may also want to
have a separate process that iterates through your filesystem images
and makes sure they are in the DB.  a cheap way to do this is md5 your
files and use that as an indexed key in your table.

Cheers,

-d

On Dec 25, 12:18 am, Fluoborate  wrote:
> I have a website that generates images (PNG's of graphs), and I want
> those images to show up on the website, but I don't know how to do
> this.
>
> Is this possible:
> 1. Store the image file in an ImageField() in the SQLite 3 database.
> How do I do this?
> 2. Get the image from the database and easily serve it up in my HTML
> template. How do I do this?
>
> I actually think that I might not want to store the images in the
> SQLite database because there will be so many images. However, I do
> want the images to be deleted if the SQLite objects corresponding to
> them are deleted. How do I keep the collection of image files and the
> database of what images it thinks it has in good agreement? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Calculate and store the average rating

2008-12-26 Thread Dave Dash

Hmm... this is slightly different... is BookRatings and Books 1 to 1?

If I store these aggregates as part of the class that it's grouping
by.  Here's how I do it for restaurants:

class RestaurantRating(models.Model):
restaurant = models.ForeignKey(Restaurant)
value  = models.IntegerField(null=True, blank=True)
user   = models.ForeignKey(Profile)
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
db_table = u'restaurant_rating'

def save(self, force_insert=False, force_update=False):
try:
super(RestaurantRating, self).save(force_insert,
force_update)
cursor  = connection.cursor()
query   = "SELECT count(value), avg(value) FROM
restaurant_rating WHERE restaurant_id = %s"
results = cursor.execute(query, (self.restaurant.id,))

for row in cursor.fetchall():
self.restaurant.num_ratings= row[0]
self.restaurant.average_rating = row[1]
self.restaurant.save()

except:
  transaction.rollback()
else:
  transaction.commit()

It's worked well for me, although I haven't used this in production
yet.  Let me know if this works for you.

On Dec 26, 4:48 pm, eldonp2  wrote:
> Is there a way to calculate and store the average rating in this
> example:
>
> RATING_CHOICES = {
>  '3' : 'Excellent',
>  '2' : 'Good',
>  '1' : 'Poor',
>
> }
>
> class Loan(
>  ...
>  book = models.ForeignKey(Book)
>  rating = models.IntegerField(choices=RATING_CHOICES)
>  ...
>
> class BookRatings(...
>  ...
>  book = models.ForeignKey(Book)
>  rating = models.IntegerField(...here I would like the average rating
> from the Loan model...)
>  nums = models.IntegerField(...and here the number of ratings
> done...)
>  ...
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Anyone maintaining a Svn repo for django-registration?

2008-12-16 Thread Dave Dash

I just hg pull the code from time to time.  I've had bad luck running
the latest/greatest of anything.  So now I only upgrade when I need
to.

-d

On Dec 16, 6:23 am, shabda  wrote:
> Django registration has moved from googlecode to Bitbucket, which
> means my projects which are svn:externaled to django-registration
> might not get the latest code. Is anyone maintaining an svn repository
> which is I can svn:external to?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django database SQLite3

2008-12-14 Thread Dave Dash

Is sqlite3 part of yoru windows path?

Otherwise you can run sqlite3 with the path to your db... e.g.

sqlite3 c:\Users\Benjamin\Desktop\mysite\data\website.sqlite

or wherever your sqlite db is stored.

On Dec 14, 5:10 am, ben852  wrote:
> C:\Users\Benjamin\Desktop\mysite\sqlite3
> SQLite3 version 3.6.6.2
> Enter".help" for instructions...
>
> C:\Users\Benjamin\Desktop\mysite\python manage.py dbshell
> Error: You appear not to have the 'sqlite3'program installed or on
> your path
>
> I have the latest version of django (SVNsubversion) and I thought
> SQLite3 was automatically installed with this version.
>
> I installed SQLite3 within the mysite directory but it appears it
> does'nt work (the command "python manage.py dbshell").
> I can't make changes to my database schema (chapter 5).
> In SQLite3, when I execute an ALTER TABLE statement to add a new
> column, I have an SQL error: no such table: books_book (book is a
> class of my model).
>
> Do I have to add a path to another directory?
> Do I have to reinstall SQLite3? or to change of db? How do I do?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Logic for stylesheets

2008-12-10 Thread Dave Dash

I'm curious at what you're trying to ultimately do.

On one of the projects I work on, we put a class on a encapsulating
div that defines future behavior:






and then we can do a special style for

.no_content .content {display: none}

or whatever we end up deciding to do differently.

On Dec 10, 7:36 am, "Daniele Procida" <[EMAIL PROTECTED]>
wrote:
> In a template I have:
>
>     {% placeholder right-column Textarea %}
>
> I'd like the template to load stylesheetb.css rather than
> stylesheeta.css if that content item is empty.
>
> I guess I need some logic around the the styles listed in the ,
> but I don't know what it should be, so I'd be grateful for any suggestions.
>
> Thanks,
>
> Daniele
--~--~-~--~~~---~--~~
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: Reducing the number of my view's database queries

2008-12-07 Thread Dave Dash

Without knowing too much about your code, the only thing I can say,
having had a similar issue, was that select_related witha  specified
depth generally made for more efficient queries.

For fun, I started on some code to output database queries on all my
pages while I'm debugging:


  Queries
  
{{ sql_queries|length }} Quer{{ sql_queries|pluralize:"y,ies" }}
{% ifnotequal sql_queries|length 0 %}
(Show)
{% endifnotequal %}
  
  

{% for query in sql_queries %}
  {{ query.sql|wordwrap:40 }}
({{ query.time }})
{% endfor %}
  


I wrote this code when I was going through my site and making my
queries more efficient.

Another strategy that worked for me, is having an *ideal* SQL query
and then trying to fit that into the Django way of grabbing objects.
I already knew the most efficient query to use, so I had to just hack
around until Django did what I want.

Hope this helps.

On Dec 6, 8:56 pm, erikcw <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm trying to write a model query that will return a queryset along
> with the latest (and earliest) data from 2 related models.
>
> Right now I'm doing something like this:
>
> objects = Model1.objects.filter(user=3).select_related() #about 6,000
> objects
>
> data = {}
> for o in objects:
>     data[o.name] = [o.field1, o.field2]
>     data[o.name].append(o.field3.model2_set.all().latest('created'))
> #get latest row from related model2
>     data[o.name].append(o.model3_set.all().order_by('created')[0])
> #get earliest row from related model3
>
> The problem is that this results in a TON of database queries.  This
> view is taking over a minute to process.  The select_related on the
> first line doesn't seem to be helping since I'm using latest()/
> order_by which generates a new query.
>
> How can I make this more efficient?  Denormalizing the isn't an option
> since model2 and model 3 are many-to-one.
>
> Is there something I can do with extra() in the first query or some
> sort of subquey I can do to eliminate the loop?
>
> Thanks!
> Erik
--~--~-~--~~~---~--~~
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: Removing accents from strings

2008-12-07 Thread Dave Dash

Sorry Karen my mistake for leaving that out, that reTagnormalizer just
filtered everything that wasn't alphanumeric, the full code is below.

Also here's the error from manage.py test

File "/restaurant/models.py", line 33, in
mealadvisor.restaurant.models.normalize
Failed example:
normalize(u' café ')
Expected:
u'cafe'
Got:
u'cafa'


***



import unicodedata, re

reTagnormalizer= re.compile(r'[^a-zA-Z0-9]')

reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
\ufe20-\ufe2f]',re.U)

def remove_diacritics(s):
" Decomposes string, then removes combining characters "
return reCombining.sub('',unicodedata.normalize('NFD',unicode
(s)) )


# tag normalizer
def normalize(tag):
"""
>>> normalize(u'cafe')
u'cafe'
>>> normalize(u'caf e')
u'cafe'
>>> normalize(u' cafe ')
u'cafe'

For now this is wrong I think it's an error with doctest, not the
actual function.

>>> normalize(u' café ')
u'cafe'

>>> normalize(u'cAFe')
u'cafe'
>>> normalize(u'%sss%s')
u''
"""
try:
tag = remove_diacritics(tag)
except:
pass

tag = reTagnormalizer.sub('', tag).lower()
return tag

On Dec 6, 9:42 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Dec 6, 2008 at 9:00 PM, Dave Dash <[EMAIL PROTECTED]> wrote:
>
> > Okay I think that fixes one fundamental issue... I've got a unittest,
> > however that fails for a function:
>
> > def normalize(tag):
> >    """
> >    >>> normalize(u'cafe')
> >    u'cafe'
> >    >>> normalize(u'caf e')
> >    u'cafe'
> >    >>> normalize(u' cafe ')
> >    u'cafe'
> >    >>> normalize(u' café ')
> >    u'cafe'
> >    >>> normalize(u'cAFe')
> >    u'cafe'
> >    >>> normalize(u'%sss%s')
> >    u''
> >    """
> >    try:
> >        tag = remove_diacritics(tag)
> >    except:
> >        pass
>
> >    tag = reTagnormalizer.sub('', tag).lower()
> >    return tag
>
> > It fails on the ' café' and translates it to cafa instead of cafe.
> > THis is only through the unittest framework (doctest) since I can run
> > it from django shell and it works as intended.
>
> > Is this just an issue with doctest?
>
> If I cut and paste your code and take out reTagnormalizer (since you didn't
> post that) and all the tests that seem to depend on what it does vs.
> remove_diacritics, and just test:
>
>    """
>    >>> normalize(u'café')
>    u'cafe'
>    """
> plain Python doctesting it works fine, as does 'manage.py test someapp' (if
> I put the code in somapp's models.py file).
>
> So I can't recreate the error you are reporting based on what you have
> posted.  What's in reTagnormalizer?
>
> Karen
--~--~-~--~~~---~--~~
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: Removing accents from strings

2008-12-06 Thread Dave Dash

Okay I think that fixes one fundamental issue... I've got a unittest,
however that fails for a function:

def normalize(tag):
"""
>>> normalize(u'cafe')
u'cafe'
>>> normalize(u'caf e')
u'cafe'
>>> normalize(u' cafe ')
u'cafe'
>>> normalize(u' café ')
u'cafe'
>>> normalize(u'cAFe')
u'cafe'
>>> normalize(u'%sss%s')
u''
"""
try:
tag = remove_diacritics(tag)
except:
pass

tag = reTagnormalizer.sub('', tag).lower()
return tag

It fails on the ' café' and translates it to cafa instead of cafe.
THis is only through the unittest framework (doctest) since I can run
it from django shell and it works as intended.

Is this just an issue with doctest?



On Dec 6, 4:30 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Dec 6, 2008 at 7:23 PM, Dave Dash <[EMAIL PROTECTED]> wrote:
>
> > I'm experiencing some strange behavior, and I think it has to do with
> > how django deals with utf strings:
>
> > When I write a test.py file:
>
> > import re, unicodedata
>
> > reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
> > \ufe20-\ufe2f]',re.U)
>
> > def remove_diacritics(s):
> >    return reCombining.sub('',unicodedata.normalize('NFD',unicode
> > (s)) )
>
> > and then open the python shell, I get:
>
> > Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> > [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> from test import *
> > >>> remove_diacritics(u'café')
> > u'cafe'
>
> > as intended.
>
> > When I do the same thing with the django shell:
> > $ python manage.py shell
> > Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> > [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)
> > >>> from test import *
> > >>> remove_diacritics(u'café')
> > u'cafA\xa9'
>
> > Which isn't quite what I expected.
>
> > My questions are:
>
> > 1. How do I properly remove accents from strings in Django
> > 2. What is django (this is using trunk) doing to strings differently
> > than python?
>
> > Even typing u'é' in the shell returns different things.
>
> That's a Python bug:http://bugs.python.org/issue1288615 (manage.py shell
> uses Python's code.interact())
>
> I believe it's fixed in 2.6.
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Removing accents from strings

2008-12-06 Thread Dave Dash

I'm experiencing some strange behavior, and I think it has to do with
how django deals with utf strings:

When I write a test.py file:

import re, unicodedata

reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
\ufe20-\ufe2f]',re.U)

def remove_diacritics(s):
return reCombining.sub('',unicodedata.normalize('NFD',unicode
(s)) )


and then open the python shell, I get:

Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import *
>>> remove_diacritics(u'café')
u'cafe'


as intended.

When I do the same thing with the django shell:
$ python manage.py shell
Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from test import *
>>> remove_diacritics(u'café')
u'cafA\xa9'


Which isn't quite what I expected.

My questions are:

1. How do I properly remove accents from strings in Django
2. What is django (this is using trunk) doing to strings differently
than python?

Even typing u'é' in the shell returns different things.

Cheers,

Dave

--~--~-~--~~~---~--~~
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: Where can I find the "What's new" in detail in django's doc 1.0?

2008-11-04 Thread Dave Dash

Here's the changelist:

http://docs.djangoproject.com/en/dev/releases/1.0/

On Nov 4, 7:04 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Where can I find the "What's new" in detail in django's doc 1.0?
--~--~-~--~~~---~--~~
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 on Apache (mod_python) administration cookie problem

2008-11-04 Thread Dave Dash

I had cleared the cookies, I also tried in another browser as well -
same result.

On Nov 3, 10:50 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 4, 5:08 pm, Dave  Dash <[EMAIL PROTECTED]> wrote:
>
> > I am witnessing this issue using manage.py runserver.
>
> > The only useful information I can give is this was working when I was
> > running .97 (or whatever was the trunk a few months back), I recently
> > upgraded to the latest trunk (~1.1) and now continually get this
> > message.
>
> > I suspect something has changed in the last few months and I missed
> > whatever it was.  I'm going to attempt to setup a dummy project and
> > try this again.
>
> > If anybody has some clue, please let me know,
>
> Clear the cookie for the application from your browser cache.
>
> Graham
>
> > Cheers,
>
> > Dave Dash
>
> > On Sep 30, 5:05 pm, Álvaro Justen <[EMAIL PROTECTED]> wrote:
>
> > > Ah, some details:
> > > -> Admin interface runs OK with python manage.py runserver - as of it
> > > is an Apache error, Django's web server isn't affected by this bug.
> > > -> I'm using Debian etch as server: I've installed Apache, PHP and
> > > mod_php with Debian packages, but Django installed manually.
> > > -> Versions:
> > >   * Apache: Server version: Apache/2.2.3
> > >     Server built:   Mar 22 2008 09:29:10
> > >   * PHP: PHP 5.2.0-8+etch11 (cli) (built: May 10 2008 10:46:24)
> > >     Copyright (c) 1997-2006 The PHP Group
> > >     Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
> > >   * Django: 1.0-final-SVN-unknown
>
> > > --
> > >  Cheers,
> > >   Álvaro Justen
> > >   Debian GNU/Linux user
--~--~-~--~~~---~--~~
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 on Apache (mod_python) administration cookie problem

2008-11-03 Thread Dave Dash

I am witnessing this issue using manage.py runserver.

The only useful information I can give is this was working when I was
running .97 (or whatever was the trunk a few months back), I recently
upgraded to the latest trunk (~1.1) and now continually get this
message.

I suspect something has changed in the last few months and I missed
whatever it was.  I'm going to attempt to setup a dummy project and
try this again.

If anybody has some clue, please let me know,

Cheers,

Dave Dash

On Sep 30, 5:05 pm, Álvaro Justen <[EMAIL PROTECTED]> wrote:
> Ah, some details:
> -> Admin interface runs OK with python manage.py runserver - as of it
> is an Apache error, Django's web server isn't affected by this bug.
> -> I'm using Debian etch as server: I've installed Apache, PHP and
> mod_php with Debian packages, but Django installed manually.
> -> Versions:
>   * Apache: Server version: Apache/2.2.3
>     Server built:   Mar 22 2008 09:29:10
>   * PHP: PHP 5.2.0-8+etch11 (cli) (built: May 10 2008 10:46:24)
>     Copyright (c) 1997-2006 The PHP Group
>     Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
>   * Django: 1.0-final-SVN-unknown
>
> --
>  Cheers,
>   Álvaro Justen
>   Debian GNU/Linux user
--~--~-~--~~~---~--~~
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 serve robots.txt for Django?

2008-02-14 Thread Dave Dash

RewriteEngine On
RewriteRule ^robots\.txt$ /static/robots.txt [L]

I think that should work if you have a web served folder of /static

I forget if DH supports Alias

because

Alias robots.txt /path/to/robots.txt will also work.


On Feb 14, 1:24 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I'm using a shared server at Dreamhost, which limits my access to
> certain things. :(
>
> How can I do this with mod_rewrite?
>
> On Feb 14, 4:19 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > If you are using Apache(or probably other servers as well), the best
> > way to do it would be  to just let your web server serve it up, Apache
> > can be set to cause files with certain extensions to be served up as
> > usual instead of going through django(this is instead of/in addition
> > to the usual way of doing it by directory), there is a guide to doing
> > this somewhere, does anyone know the URL?
>
> > On Feb 14, 2:35 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > > I use something like this:
>
> > >   (r'^robots.txt$', 'django.views.static.serve', { 'path' : "/
> > > txt/robots.txt",
>
> > > 'document_root': settings.MEDIA_ROOT,
>
> > > 'show_indexes': False } ),
>
> > > On Feb 14, 10:53 pm, "[EMAIL PROTECTED]"
>
> > > <[EMAIL PROTECTED]> wrote:
> > > > I built a Django site for my blog and want to serve a robots.txt file
> > > > for it. But I can't figure out how to go about doing this since it's a
> > > > static file.
>
> > > > Here is what I have in my urls:
>
> > > > from patrickbeeson.views import robots
> > > > ...
> > > > (r'^robots.txt$', robots),
>
> > > > From the views:
>
> > > > from django.http import HttpResponse
> > > > from django.template import TemplateDoesNotExist
>
> > > > def robots(request):
> > > > try:
> > > > return HttpResponse(open('robots.txt').read(), 
> > > > 'text/plain')
> > > > except TemplateDoesNotExist:
> > > > raise Http404()
>
> > > > The "robots.txt" file is located in my templates directory with other
> > > > templates.
>
> > > > Any suggestions on what I might be doing wrong?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Can't login to /admin/ on production server over FastCGI

2008-02-13 Thread Dave Dash

When I go to /admin/ and login the screen just returns to the login
screen again with no errors or anything.

I have SESSION_COOKIE_DOMAIN set propperly as well and that didn't
help (the faq said it might).

I then tried using the built in server, and I ran that using the same
domain, but port 8000 as the listener.  That worked fine.

In fact, when I went to the production server (fastcgi) that cookie
got me to the admin interface.

So I'm wondering if there's some trick that is preventing the cookie
from getting to me.  I have liveHTTP headers, but I'm nothing looks
too out of the ordinary.  Cookies are sent with the requests just fine
and recieved just fine...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[resolved] OperationalError from sqlite3 (was Re: On nginx+fastcgi server site works except for /admin/ Unhandled Exception)

2008-02-12 Thread Dave Dash

Hi Jarek,

Modifying django.core.servers.fastcgi.py was just what I needed to
find out where my "traffic jam" was.

I had an OperationalError from my sqlite3 database.  I not only had to
update the permissions on sqlite3, but also on its containing
directory.

Worked like a charm.  Hope this helps others.

-d

On Feb 12, 12:31 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Malcolm Tredinnick napisał(a):
>
> > Secondly, any application that throws an UnhandledException must surely
> > be logging the details somewhere (or the maintainer should be taken out
> > for a quick conversation with some of the more hefty participants at the
> > next conference he attends). So look in the error logs for clues.
>
> I'm sorry to say but this is how flup works. The "Unhandled Exception"
> is an output of flup's own error middleware.
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



On nginx+fastcgi server site works except for /admin/ Unhandled Exception

2008-02-12 Thread Dave Dash

I'm getting the dreaded:

Unhandled Exception

An unhandled exception was thrown by the application.


Whenever I try to access /admin on my app under nginx+fastcgi.

To be sure, I tried the development server on the same machine and /
admin/ gave me the django admin prompt as expected.

I'm curious how to debug this.
--~--~-~--~~~---~--~~
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: Database fields not showing up as unicode

2008-02-10 Thread Dave Dash

Malcolm,

It looks like i just found my solution:

http://automatthias.wordpress.com/2006/12/10/mysql-encoding-problems-on-dreamhost/

Apparently all the fields were encoded incorrectly.

On Feb 10, 9:44 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-02-10 at 21:11 -0800, Dave Dash wrote:
> > Hi,
> > I have a legacy database that I've been using in a php app.  In PHP
> > the fields would render as unicode just fine.
>
> There are a lot of variables involved here, so before we go any further,
> please provide some more information:
>
> - What version of MySQL are you running?
> - What version of MySQLdb-python?
> - What version of Django?
> - Which database backend (mysql or msyql_old)?
> - What is the character encoding of the tables concerned in
> MySQL?
>
> Regards,
> Malcolm
>
> --
> Many are called, few volunteer.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Database fields not showing up as unicode

2008-02-10 Thread Dave Dash

Hi,
I have a legacy database that I've been using in a php app.  In PHP
the fields would render as unicode just fine.

In my Django app I get:

PhamâEURO(tm)s

instead of the expected:

Pham's

This happens for accented characters everything.

I'm no good with unicode, it has usually "just worked" but it's not
now.  I've narrowed it down to the model layer, since I can just make
a function that does this:

__unicode__():
return u'é'

and that works just fine, but

__unicode__():
return self.name

(or even force_unicode(self.name)) doesn't work.

I'm using a mysql database, i'm not sure if there's a setting I can
tweak to make this all better.

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



Alternate URL styles for RSS feeds?

2008-02-04 Thread Dave Dash

I have a legacy app with feeds:

/restaurant/{slug}/feed

so I defined in my urls.py:


feeds = {
'restaurant': MenuItems,
}

urlpatterns = patterns('',
# restaurant feed
(
r'^(?Prestaurant)/(.*)/feed',
'django.contrib.syndication.views.feed',
{'feed_dict': feeds}
),
)

That goes to the correct class, but how do I get at the slug?  I tried
using:

class MenuItems(Feed):
"""
e.g. /restaurant/hobees/feed

We need the equivalent of
select menuitems from menuitems, restaurants where restaurant.slug
= slug
"""

def get_object(self, bits):
return Restaurant.objects.get(stripped_title__exact=bits[0])


but I suspect that Restaurant.objects.get was returning None since I
got the following error:

'NoneType' object has no attribute 'get_absolute_url'

Thanks for any help :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---