Re: template inheritance

2009-01-11 Thread James Matthews
Not always sometimes you want to show some template code (You have a blog
about web dev) and sometimes you want to nest some code.

On Sun, Jan 11, 2009 at 10:04 PM, Diez B. Roggisch wrote:

> Alex K schrieb:
>
>> While building a website using template inheritance one usually does
>> the following:
>>
>> fetch from database
>> fetch from some more data from database
>> ... << more required computations
>> then at the end render the template with the fetched data
>>
>> Without template inheritance one usually does the following:
>>
>> fetch from database
>> render this part of the site with this fetched data
>> fetch some more data from the database
>> render this other part of the site with the fetched data
>> ...
>> etc
>>
>> The first approach is much more elegant and leads to easier to
>> maintain code. However the user will have to wait till the end of the
>> fetching (long computations) before any rendering can take place. In
>> the second approach however the site loads as we are fetching the data
>> which is more convenient to the user.
>>
>> Am I correct to assume this? Is there a way to get the best of both
>> worlds? Thank you.
>>
>
> I don't think that the question of inheritance or not is really relevant
> here.
>
> It's a matter of how the templating system is written - does it collect all
> the data beforehand, or not, is it potentially using e.g. generators and so
> forth.
>
> And of course how the programmer uses the templating system. does he fetch
> all the data beforehand, or does he use lazy generation approachs - again,
> e.g. generators, or callbacks.
>
> Besides, *usually* the 20-39Kb of a website itself aren't the problem I'd
> say - loading referenced resources is much more of an issue.
>
> And AFAIK the render-mode matters, too. If the site is XHTML-compliant, the
> browser can start the rendering once the HTML is complete - otherwise, it
> might wait until the referenced resources are all loaded to calculate the
> layout.
>
> Diez
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.astorandblack.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get Request Url

2009-01-11 Thread James Matthews
Thank You (I had the same question today)

2009/1/12 burcu hamamcıoğlu 

> Thanks Bruno request.get_full_path() is enough for me .
>
> Best regards
>
> 09 Ocak 2009 Cuma 18:31 tarihinde bruno desthuilliers <
> bruno.desthuilli...@gmail.com> yazdı:
>
>
>>
>>
>> On 9 jan, 17:06, "burcu hamamcıoğlu"  wrote:
>> > Hi everybody,
>> >
>> > do you know how can i get request url in views.py.
>> >
>> > My url pattern is like
>> (r'^wp/rmain2\.aspx','DisplayPacketApplications2'),
>> > But my link is like :
>> http://wap2.cepoyun.com/wp/rmain2.aspx?pid=194=280jhjh
>> >
>> > when i use 'PATH_INFO' i olnly get 'wp/rmain2\.aspx' of the link. How
>> can i
>> > get the full link above ?
>>
>> request.get_full_path() will give you the path + the querystring.
>>
>>
>> http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path
>>
>> But if what you want is to get the 'pid' and 'w' arguments of the
>> querystring, it might be simpler to use request.GET, ie:
>>
>> def youview(request):
>>   pid = request.GET.get(pid)
>>   w = request.GET.get(w)
>>   # you code here
>>
>> Have a look at the FineManuel(tm) for more about the HttpRequest
>> object:
>> http://docs.djangoproject.com/en/dev/ref/request-response/
>> >>
>>


-- 
http://www.astorandblack.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get Request Url

2009-01-11 Thread burcu hamamcıoğlu
Thanks Bruno request.get_full_path() is enough for me .

Best regards

09 Ocak 2009 Cuma 18:31 tarihinde bruno desthuilliers <
bruno.desthuilli...@gmail.com> yazdı:

>
>
>
> On 9 jan, 17:06, "burcu hamamcıoğlu"  wrote:
> > Hi everybody,
> >
> > do you know how can i get request url in views.py.
> >
> > My url pattern is like
> (r'^wp/rmain2\.aspx','DisplayPacketApplications2'),
> > But my link is like :
> http://wap2.cepoyun.com/wp/rmain2.aspx?pid=194=280jhjh
> >
> > when i use 'PATH_INFO' i olnly get 'wp/rmain2\.aspx' of the link. How can
> i
> > get the full link above ?
>
> request.get_full_path() will give you the path + the querystring.
>
>
> http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path
>
> But if what you want is to get the 'pid' and 'w' arguments of the
> querystring, it might be simpler to use request.GET, ie:
>
> def youview(request):
>   pid = request.GET.get(pid)
>   w = request.GET.get(w)
>   # you code here
>
> Have a look at the FineManuel(tm) for more about the HttpRequest
> object:
> http://docs.djangoproject.com/en/dev/ref/request-response/
>
> >
>

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

2009-01-11 Thread steve

You'll find the perfect way for you to approach each stage of it I'm
sure.

I'm always into figuring out Use Cases the very first thing.  I like
to establish at least 4 or 5 different major tasks that a user would
need/want to do, and then get these out of my head into a concrete
form  (currently this means the Treepad outliner in a "use case"
branch).

This first step naturally, without too much mental effort, steers me
next into making decisions about what screens I will need, and what
models I will need to read/write in each of those screens.
 
--
So my first step is 1.) sketching what I need highlevel-wise,

2. ) Then deciding what those urls will be, going into urls.py to
write three or four mappings (for only read operation functions such
as getScores or whatever, i'll worry later about writing the write
operations when I start writing the html forms in the views )

3. ) And then start writing the models I know I will need. When I'm
finished with about 80% of the models I know I will need, I use the
Python shell to check things. When I'm satisfied that all of the
related tables give me the right result on the shell console by
manually running model.objects.all(), etc.., the next step

4. ) I go into views.py and write three or four functions that do some
reading

5.) Then the views - write the tags for retrieving database results.

.. and then I view a Djangocon speaker on youtube and realize how much
I have to learn when it comes to performance, and all of the different
areas to look at:
  check out: http://www.youtube.com/watch?v=D-4UN4MkSyI

  Seriously, not that we will all have sites that demand that type of
bandwidth, but it is definitely educational.



On Jan 11, 7:03 pm, AlexiPoliski  wrote:
> This is a call for opinion based on experience :)
>
> I'm in the process of creating the models for my very first Django
> application in my very first project. I have read the book up to and
> including chapter 7 (everything i need to know to get started).
>
> Naturally I have the design of the system I want fairly well figured
> out, and have moved on to do most of the work for the models
> (primarily as far as the database is concerned).
>
> Currently I am wondering what the next stages are going to be, and I'm
> not too sure what I would like to do as a matter of process. I
> remember reading a section in the book highlighting that you could do
> it either way, depending perhaps on your own programming preference or
> the situation.
>
> I've given it some thought, but I'll keep my current inclination for
> what I would prefer to myself for now; I'm still undecided anyway. If
> the decision is 50/50 and absolutely depends on what you are
> developing, then let me know what cases illustrate the deciding
> factors. I would imagine that experienced developers would have a
> predominant preference by now and THAT is what I would really like to
> hear about :)
>
> ---
> tldr;
> What I would like to ask is, from more experienced Django developers,
> what way do you prefer to create your applications? Models then views
> then templates? Models then templates then views? Or models then views
> AND templates concurrently.
>
> If there has been a discussion that addresses this subject already
> then I would appreciate a link to that just as much.
>
> Thank you,
> -Alex

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

2009-01-11 Thread Alex Kowalczyk
2009/1/12 Jeremy Dunck 

> My general approach is:
>
> URLs first, which helps me think through the various pages users will
> interact with.
> Roughly sketch those pages, think about features and models needed for
> reasonable normalization.
> Code models
> Implement views.
> Implement templates.
> Factor out template tags.
> Performance test, tuning SQL/caching.


Thanks Jeremy much appreciated, I like the look of this approach.
-Alex

--~--~-~--~~~---~--~~
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: why 'No module named safestring'?

2009-01-11 Thread frank Shi

thanks David

On Jan 12, 11:53 am, "David Zhou"  wrote:
> On Sun, Jan 11, 2009 at 10:25 PM, frank Shi  wrote:
>
> > i use django 0.96 ,template render html string.
>
> > from django.utils.safestring import mark_safe
> > context=Context({
> >        'div1':mark_safe(obj),
> >    })
> >    return HttpResponse(template.render(context))
>
> > it's error: No module named safestring?why
> > already install python 2.5
>
> You need to use a more recent version of Django. Safestring was
> introduced after 0.96.  See:
>
> http://code.djangoproject.com/browser/django/trunk/django/utils
>
> vs.
>
> http://code.djangoproject.com/browser/django/tags/releases/0.96/djang...
>
> --
> ---
> David Zhou
> da...@nodnod.net
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Putting pieces back together again

2009-01-11 Thread Mark Jones

I have some fields on my page that have more than one attribute for
simplification, lets say two attributes

answer = {'txt':'something', 'allowblank':0}

laid out on the page as:
{% for answer in quiz_question.answers %}
  
  
{% endfor %}

the first is pulled from an input field, and if !allowblank, needs to
have some text.

I write some OnSubmit() javascript on my page to check this field, and
if it is blank, check the allowblank attribute in the following hidden
field to see if this is OK.  If is isn't ok, I ask the user "you sure
you wanna leave this field blank?"  If the user says "YES, I want to
leave it blank, the JS changes allowblank to 1 and we submit the form.

If the backend gets the form and the field is blank, but the
allowblank is true, then I know the user said OK, no problem, I let it
be blank, otherwise I validate it on the server side (in case they use
noscript like I do) and if allowblank=0 and the field is blank, I send
the form back to them with a checkbox like this

{% for answer in question.answers %}
  
   I
really want to leave this field blank
{% endfor %}

My problem comes about because a nice list of dict objects has been
broken apart by the html form and needs to be reassembled.  While I
can do this like so:

  for i in range(len(qqanswers)-1,0, -1):
  qqanswers[i] = {'txt':answers[i], 'allowblank':int
(allowblank[i])}
  if answers[i] == '' and allowblank[i]:
  del qqanswers[i]

I don't like how ugly this looks.  I tried changing the names of the
input objects to:

answers.txt and answers.allowblank, but that didn't work, I got POST
lists back that were names answers.txt and answers.allowblank that
looked like:



of course all of this ignores the fact that checkboxes that aren't
checked aren't sent back to the server anyway which is where the need
for a more elegant solution comes from in the first place..

Is there a nice elegant way to solve this, or does it just have to be
done the way I've done it..
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



The First Page

2009-01-11 Thread pyramid...@gmail.com

Hello django users
I am slightly confused with starting out
I just want to start with the initial index page
Do i need to create an app for that and then have views.py send me to
the index.html template
OR is this a bad way to do it
how do u handle the url where they just type in the www.website.com

thx

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

2009-01-11 Thread Jeremy Dunck

On Sun, Jan 11, 2009 at 9:03 PM, AlexiPoliski  wrote:
...
> What I would like to ask is, from more experienced Django developers,
> what way do you prefer to create your applications? Models then views
> then templates? Models then templates then views? Or models then views
> AND templates concurrently.

My general approach is:

URLs first, which helps me think through the various pages users will
interact with.
Roughly sketch those pages, think about features and models needed for
reasonable normalization.
Code models
Implement views.
Implement templates.
Factor out template tags.
Performance test, tuning SQL/caching.

--~--~-~--~~~---~--~~
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: Markdown filter piped into custom filter

2009-01-11 Thread Brian Neal

On Jan 11, 11:27 am, Brian Neal  wrote:
> I wrote a filter that searches for patterns in text and replaces them
> with  tags:
>
> {{ comment.text|smilify }}
>
> It does various silly things like replace :-) with an actual smiley
> face image. Seems to work great.
>
> When I combine it with the markdown filter, like this:
>
> {{ comment.text|markdown:"safe"|smilify }}
>
> It seems to escape the HTML that the markdown filter produces. In
> other words if my comment text is ":-)" then the output I get (when
> viewing the raw HTML source of the document) is p src="..." ... />/p
>
> Is it not possible to use the markdown filter like this? Or is the
> markdown filter supposed to mark its output as safe and my filter is
> incorrectly escaping it?
>
> The source for my filter is here:
>
> http://dpaste.com/107803/
>
> Thanks!

Okay I think I figured it out. I studied the existing filters a bit.
You can test the input value to your filter function with "isinstance
(value, SafeData)". If so, you don't need to escape it.
--~--~-~--~~~---~--~~
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: why 'No module named safestring'?

2009-01-11 Thread David Zhou

On Sun, Jan 11, 2009 at 10:25 PM, frank Shi  wrote:
>
> i use django 0.96 ,template render html string.
>
> from django.utils.safestring import mark_safe
> context=Context({
>'div1':mark_safe(obj),
>})
>return HttpResponse(template.render(context))
>
> it's error: No module named safestring?why
> already install python 2.5
>

You need to use a more recent version of Django. Safestring was
introduced after 0.96.  See:

http://code.djangoproject.com/browser/django/trunk/django/utils

vs.

http://code.djangoproject.com/browser/django/tags/releases/0.96/django/utils

-- 
---
David Zhou
da...@nodnod.net

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



Django Development Process

2009-01-11 Thread AlexiPoliski

This is a call for opinion based on experience :)

I'm in the process of creating the models for my very first Django
application in my very first project. I have read the book up to and
including chapter 7 (everything i need to know to get started).

Naturally I have the design of the system I want fairly well figured
out, and have moved on to do most of the work for the models
(primarily as far as the database is concerned).

Currently I am wondering what the next stages are going to be, and I'm
not too sure what I would like to do as a matter of process. I
remember reading a section in the book highlighting that you could do
it either way, depending perhaps on your own programming preference or
the situation.

I've given it some thought, but I'll keep my current inclination for
what I would prefer to myself for now; I'm still undecided anyway. If
the decision is 50/50 and absolutely depends on what you are
developing, then let me know what cases illustrate the deciding
factors. I would imagine that experienced developers would have a
predominant preference by now and THAT is what I would really like to
hear about :)

---
tldr;
What I would like to ask is, from more experienced Django developers,
what way do you prefer to create your applications? Models then views
then templates? Models then templates then views? Or models then views
AND templates concurrently.


If there has been a discussion that addresses this subject already
then I would appreciate a link to that just as much.

Thank you,
-Alex

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



why 'No module named safestring'?

2009-01-11 Thread frank Shi

i use django 0.96 ,template render html string.

from django.utils.safestring import mark_safe
context=Context({
'div1':mark_safe(obj),
})
return HttpResponse(template.render(context))

it's error: No module named safestring?why
already install python 2.5

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



POST still occurs after HttpResponseRedirect

2009-01-11 Thread stryderjzw

Hi,

Here's part of my code:

class NewAssignmentFormPreview(FormPreview):

def done(self, request, form):
assignment = form.save(commit=False)
assignment.save()

...

return HttpResponseRedirect(assignment.get_absolute_url())


I do an HttpResponseRedirect to go to the assignment page after it's
been created.

However, when I do a refresh on that page, it still asks me if I want
to submit POST data and an additional assignment is created. I thought
HttpResponseRedirect is suppose to prevent that.

Any ideas?

Thanks!
Justin
--~--~-~--~~~---~--~~
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: can't get a model in the admin

2009-01-11 Thread Bobby Roberts

> What version of Django are you using?  The use of max_length instead of
> maxlength implies something later than 0.96 but the use of 'class Admin'
> implies something before 1.0.  If you are using 1.0 or later 'class Admin'
> is not how admin defs are specified any more, see the admin doc for the
> current way.
>
> Karen

Hi Karen -

I'm using 1.0.  I took out the class admin and added an admin.py file
as follows:


from learn.testimonials.models import Testimonial
from django.contrib import admin

admin.site.register(Testimonial)



I restarted apache and got this error:

TemplateSyntaxError at /admin/

Caught an exception while rendering: Tried RandomTesti in module
testimonials.views. Error was: 'module' object has no attribute
'RandomTesti'



RandomTesti is a customized template tag I've created for use in the
site.


Can you help me figure this out? What information do you need?

--~--~-~--~~~---~--~~
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: editing multiple records using admin list view

2009-01-11 Thread sateeshk...@gmail.com

Thanks. This is exactly what I wanted.

On Jan 11, 5:36 pm, "Alex Koshelev"  wrote:
> There is an application:http://code.google.com/p/django-batchadmin/
>
> On Sun, Jan 11, 2009 at 1:53 PM, sateeshk...@gmail.com
>
>  wrote:
>
> > Hi,
> >  I want to edit multiple records of users ( say selecting the user
> > records which I want to edit ) and then say if I press
> > activate button, all the records status should change to 'ACTIVE'.
> >  To do this kind of thing, is there any simple tweak in admin model
> > or admin templates ?
> >  If some one has already done this kind of application, please share
> > the information.
>
> >  Right now with out  any tweaks I can only do single record record
> > edit going to record detail page, which is not always easy to do.
>
> > Thank you,
> > Sateesh.
--~--~-~--~~~---~--~~
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: can't get a model in the admin

2009-01-11 Thread Karen Tracey
On Sun, Jan 11, 2009 at 7:19 PM, Bobby Roberts  wrote:

>
> here's my model:
>
> from django.db import models
>
> class Testimonial(models.Model):
>active=models.IntegerField(max_length=11, blank=False)
>testimony=models.CharField(max_length=500)
>name=models.CharField(max_length=75)
>postdate = models.DateTimeField (auto_now_add=True,
> blank=False, db_index=True)
>siteid=models.IntegerField(max_length=3,blank=False)
>
>class Admin:
>list_display = ('name','active','postdate','siteid')
>
>
> The user also has perms in the users to have full control over this
> model... Why can't it be seen in the admin area?


What version of Django are you using?  The use of max_length instead of
maxlength implies something later than 0.96 but the use of 'class Admin'
implies something before 1.0.  If you are using 1.0 or later 'class Admin'
is not how admin defs are specified any more, see the admin doc for the
current way.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Decoupling between projects and app in 4-part tutorial.

2009-01-11 Thread Greg Aumann

On Jan 12, 5:41 am, dahpgjgamgan  wrote:
> In the 4-part tutorial on Django's main site, there's a lot of advice
> on how to decouple apps and projects, but when I look at the import
> statements in most of the tutorial's files, it's always "from
> projectname.appname import ." - not very decoupled for me.

You can leave the mysite off various things. So in the settings file
the INSTALLED_APPS you can put polls instead of mysite.polls. The same
for the import statements. This works because the code is run in the
mysite directory and python automatically finds modules in the
directory the code is running in. In other words python considers the
current working directory to be on the python path.

> Am I missing something, is there a good reason why those imports look
> like that and not simply "from appname... import ..."?

I am wondering why the tutorial teaches this bad practice when there
is so much emphasis in Django on reusable apps. It seems to me that
teaching the better way of leaving off the site directory requires no
code change but only a documentation change to the tutorial.

Even better would be making the backwards incompatible change of
removing the project directory from the python path to encourage
better practice.

But I also am just learning Django so probably have failed to consider
something important.

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



can't get a model in the admin

2009-01-11 Thread Bobby Roberts

here's my model:

from django.db import models

class Testimonial(models.Model):
active=models.IntegerField(max_length=11, blank=False)
testimony=models.CharField(max_length=500)
name=models.CharField(max_length=75)
postdate = models.DateTimeField (auto_now_add=True,
blank=False, db_index=True)
siteid=models.IntegerField(max_length=3,blank=False)

class Admin:
list_display = ('name','active','postdate','siteid')


The user also has perms in the users to have full control over this
model... Why can't it be seen in the admin area?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Decoupling between projects and app in 4-part tutorial.

2009-01-11 Thread dahpgjgamgan

Hi,

In the 4-part tutorial on Django's main site, there's a lot of advice
on how to decouple apps and projects, but when I look at the import
statements in most of the tutorial's files, it's always "from
projectname.appname import ." - not very decoupled for me. Am
I missing something, is there a good reason why those imports look
like that and not simply "from appname... import ..."?

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: Path problem with jsi18n - internationalization

2009-01-11 Thread Ramiro Morales

On Sun, Jan 11, 2009 at 6:43 PM, Tipan  wrote:
>
> Hi Ramiro,
>
> I'm using the latest development version of Django. Apache web server.
> MySqL/Mod_python, all served from same apache on my laptop.
>
> I get a 404 error when I put http:///jsi18n/ into the browser
> URL.
>

That's strange, are you succesfully using another component of Django
i18n infrastructure in the same application?. De you have USE_I18N set to
True in the settings file you are using?

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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: def clean_file works with django server but not with apache

2009-01-11 Thread Alan
Thanks a lot dear Graham.
Alan

On Sun, Jan 11, 2009 at 20:56, Graham Dumpleton
wrote:

>
> Answered at:
>
>  http://groups.google.com/group/modwsgi/browse_frm/thread/6af0cf98b726e5fe
>
> Graham
>
> On Jan 11, 11:59 pm, Alan  wrote:
> > Oops, I found something. I am using apache2 + mod_wsgi and I notice that
> > instead of using my Fink python ('/sw/bin/python') it's using my mac
> python
> > ('/usr/bin/python').
> > I compiled mod_wsgi with fink python, even though I had to put something
> > like:
> >
> > WSGIDaemonProcess webapps user=alan group=staff processes=1 threads=16\
> >
> >  python-path=/sw/lib/python2.5:/sw/lib/python2.5/site-packages
> >
> > in my httpd.conf file.
> >
> > Yet, under the light of these news I still have no idea about how to
> solve
> > my problem. And maybe now it's a new problem: how to make apache2 +
> mod_wsgi
> > use fink python and not system python (for Mac in particular)?
> >
> > Cheers,
> > Alan
> >
> >
> >
> > On Sun, Jan 11, 2009 at 12:47, Alan  wrote:
> > > Hi List,
> > > I have this problem now. It's about a form in my models.py that works
> as
> > > expected when testing with django server but when testing with apache
> sever
> > > (all in the same machine, mac osx leopard) it does not work as desired.
> >
> > > class GridJobForm(forms.Form):
> >
> > > file = forms.FileField(help_text="(Mandatory)")
> >
> > > title = forms.CharField(max_length=255, required=False, help_text=
> > > "(Optional)")
> >
> > > def clean_file(self):
> >
> > > file = self.cleaned_data['file']
> >
> > > print file.content_type
> >
> > > if len(file) > gridMaxFileSize * 1024 * 1024: #bytes
> >
> > > raise forms.ValidationError('File size must not exceed %s
> Mb.'% gridMaxFileSize)
> >
> > > msg1 = 'File upload must be a valid ZIP/TGZ/BZ2 archive.'
> >
> > > msg2 = 'Could not unzip file.'
> >
> > > msg3 = 'Could not uncompress file.'
> >
> > > msg4 = 'Bad zip file'
> >
> > > #print file.content_type application/x-tar
> >
> > > if file.content_type == 'application/zip':
> >
> > > try:
> >
> > > zip = zipfile.ZipFile(file) #StringIO( file['content']
> ) )
> >
> > > except:
> >
> > > raise forms.ValidationError(msg2)
> >
> > > bad_file = zip.testzip()
> >
> > > zip.close()
> >
> > > del zip
> >
> > > if bad_file:
> >
> > > raise forms.ValidationError(msg4)
> >
> > > elif file.content_type in ['application/x-gzip',
> > > 'application/x-tar', 'application/octet-stream']:
> >
> > > try:
> >
> > > tarfile.open(fileobj=file) #< problem with apache?
> >
> > > except:
> >
> > > raise forms.ValidationError(msg3)
> >
> > > else:
> >
> > > raise forms.ValidationError(msg1)
> >
> > > return self.cleaned_data['file']
> >
> > > It happens when I submit a tgz file to my apps under apache and the
> code
> > > enters in "elif file.content_type in ['application/x-gzip'...". When it
> > > "try" 'arfile.open(fileobj=file)' it fails and raises msg3.
> >
> > > I have no idea how to debug this and can't figure out how come it
> happens.
> > > I tried big and small files (thinking it could be something related
> > > to InMemoryUploadedFile).
> >
> > > I did just another thing: I removed the "try" to see what django debug
> > > would report under apache and I got this:
> >
> > > AttributeError at /ccpngrid/
> >
> > > 'NoneType' object has no attribute 'startswith'
> >
> > > Any help would be very appreciated. Many thanks in advance.
> >
> > > Cheers,
> > > Alan
> >
> > > --
> > > Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> > > Department of Biochemistry, University of Cambridge.
> > > 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> > > >>http://www.bio.cam.ac.uk/~awd28<<
> >
> > --
> > Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> > Department of Biochemistry, University of Cambridge.
> > 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> >
> > >>http://www.bio.cam.ac.uk/~awd28<<
> >
>


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

--~--~-~--~~~---~--~~
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: def clean_file works with django server but not with apache

2009-01-11 Thread Graham Dumpleton

Answered at:

  http://groups.google.com/group/modwsgi/browse_frm/thread/6af0cf98b726e5fe

Graham

On Jan 11, 11:59 pm, Alan  wrote:
> Oops, I found something. I am using apache2 + mod_wsgi and I notice that
> instead of using my Fink python ('/sw/bin/python') it's using my mac python
> ('/usr/bin/python').
> I compiled mod_wsgi with fink python, even though I had to put something
> like:
>
> WSGIDaemonProcess webapps user=alan group=staff processes=1 threads=16\
>
>          python-path=/sw/lib/python2.5:/sw/lib/python2.5/site-packages
>
> in my httpd.conf file.
>
> Yet, under the light of these news I still have no idea about how to solve
> my problem. And maybe now it's a new problem: how to make apache2 + mod_wsgi
> use fink python and not system python (for Mac in particular)?
>
> Cheers,
> Alan
>
>
>
> On Sun, Jan 11, 2009 at 12:47, Alan  wrote:
> > Hi List,
> > I have this problem now. It's about a form in my models.py that works as
> > expected when testing with django server but when testing with apache sever
> > (all in the same machine, mac osx leopard) it does not work as desired.
>
> > class GridJobForm(forms.Form):
>
> >     file = forms.FileField(help_text="(Mandatory)")
>
> >     title = forms.CharField(max_length=255, required=False, help_text=
> > "(Optional)")
>
> >     def clean_file(self):
>
> >         file = self.cleaned_data['file']
>
> >         print file.content_type
>
> >         if len(file) > gridMaxFileSize * 1024 * 1024: #bytes
>
> >             raise forms.ValidationError('File size must not exceed %s Mb.'% 
> > gridMaxFileSize)
>
> >         msg1 = 'File upload must be a valid ZIP/TGZ/BZ2 archive.'
>
> >         msg2 = 'Could not unzip file.'
>
> >         msg3 = 'Could not uncompress file.'
>
> >         msg4 = 'Bad zip file'
>
> >         #print file.content_type application/x-tar
>
> >         if file.content_type == 'application/zip':
>
> >             try:
>
> >                 zip = zipfile.ZipFile(file) #StringIO( file['content'] ) )
>
> >             except:
>
> >                 raise forms.ValidationError(msg2)
>
> >             bad_file = zip.testzip()
>
> >             zip.close()
>
> >             del zip
>
> >             if bad_file:
>
> >                 raise forms.ValidationError(msg4)
>
> >         elif file.content_type in ['application/x-gzip',
> > 'application/x-tar', 'application/octet-stream']:
>
> >             try:
>
> >                 tarfile.open(fileobj=file) #< problem with apache?
>
> >             except:
>
> >                 raise forms.ValidationError(msg3)
>
> >         else:
>
> >             raise forms.ValidationError(msg1)
>
> >         return self.cleaned_data['file']
>
> > It happens when I submit a tgz file to my apps under apache and the code
> > enters in "elif file.content_type in ['application/x-gzip'...". When it
> > "try" 'arfile.open(fileobj=file)' it fails and raises msg3.
>
> > I have no idea how to debug this and can't figure out how come it happens.
> > I tried big and small files (thinking it could be something related
> > to InMemoryUploadedFile).
>
> > I did just another thing: I removed the "try" to see what django debug
> > would report under apache and I got this:
>
> > AttributeError at /ccpngrid/
>
> > 'NoneType' object has no attribute 'startswith'
>
> > Any help would be very appreciated. Many thanks in advance.
>
> > Cheers,
> > Alan
>
> > --
> > Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> > Department of Biochemistry, University of Cambridge.
> > 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> > >>http://www.bio.cam.ac.uk/~awd28<<
>
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
>
> >>http://www.bio.cam.ac.uk/~awd28<<
--~--~-~--~~~---~--~~
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: Path problem with jsi18n - internationalization

2009-01-11 Thread Tipan

Hi Ramiro,

I'm using the latest development version of Django. Apache web server.
MySqL/Mod_python, all served from same apache on my laptop.

I get a 404 error when I put http:///jsi18n/ into the browser
URL.

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



template inheritance

2009-01-11 Thread Jo

While building a website using template inheritance one usually does
the following:

fetch from database
fetch from some more data from database
... << more required computations
then at the end render the template with the fetched data

Without template inheritance one usually does the following:

fetch from database
render this part of the site with this fetched data
fetch some more data from the database
render this other part of the site with the fetched data
...
etc

The first approach is much more elegant and leads to easier to
maintain code. However the user will have to wait till the end of the
fetching (long computations) before any rendering can take place. In
the second approach however the site loads as we are fetching the data
which is more convenient to the user.

Am I correct to assume this? Is there a way to get the best of both
worlds? Maybe using generators? Thank you.

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



Markdown filter piped into custom filter

2009-01-11 Thread Brian Neal

I wrote a filter that searches for patterns in text and replaces them
with  tags:

{{ comment.text|smilify }}

It does various silly things like replace :-) with an actual smiley
face image. Seems to work great.

When I combine it with the markdown filter, like this:

{{ comment.text|markdown:"safe"|smilify }}

It seems to escape the HTML that the markdown filter produces. In
other words if my comment text is ":-)" then the output I get (when
viewing the raw HTML source of the document) is p/p

Is it not possible to use the markdown filter like this? Or is the
markdown filter supposed to mark its output as safe and my filter is
incorrectly escaping it?

The source for my filter is here:

http://dpaste.com/107803/

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: Path problem with jsi18n - internationalization

2009-01-11 Thread Ramiro Morales

On Sun, Jan 11, 2009 at 2:48 PM, Tipan  wrote:
>
> I'm having a problem accessing Javascript Translation catalog whilst
> converting my site to multi-language. As suggested in the docs, I have
> added the following to my applications top level urls file.
>
>
> js_info_dict = {
>'packages': ( 'myapp.myproject',),
> }
>
> (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
>
> However, when I render my template the url to jsi18n generates a "url
> not found" error in Firebug. The docs say /path/to/jsi18n, but I'm not
> sure how to reconcile this properly with my app.
>
> 
>
> Can anyone give me a pointer - I'm sure I'm missing the obvious, but
> can't see it at the moment.

What version of Django are you using?, which web server? what deployment
method? Does the web server show a 404 error in its logs when the /jsi18n/
URL is accessed from the browser? What happens if you manually open with
your browser the http:///jsi18n/ URL?.

Regards,

-- 
 Ramiro Morales

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



Path problem with jsi18n - internationalization

2009-01-11 Thread Tipan

I'm having a problem accessing Javascript Translation catalog whilst
converting my site to multi-language. As suggested in the docs, I have
added the following to my applications top level urls file.


js_info_dict = {
'packages': ( 'myapp.myproject',),
}

(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),

However, when I render my template the url to jsi18n generates a "url
not found" error in Firebug. The docs say /path/to/jsi18n, but I'm not
sure how to reconcile this properly with my app.



Can anyone give me a pointer - I'm sure I'm missing the obvious, but
can't see it at the moment.

Thanks, T
--~--~-~--~~~---~--~~
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: Where are all the Django jobs?

2009-01-11 Thread Jon Loyens

Django is starting to gain more traction and I do believe we'll start
to see a bit more of a hockey stick effect on it's adoption over the
coming months.  1.0 being released last year and (at least part-wise)
adoption by the Google AppEngine have both been great PR events for
Django but I'd also argue that Django doesn't have it's Twitter or
BaseCamp yet i.e. a killer application that grabs the mindshare of
startup CTO and CEOs that seemingly make them choose Rails.

At Thinktiv, while we're a professional services company thats
officially platform agnostic, we've chosen Django as our in-house
framework of choice for development.  Django suits the majority of our
customers applications very well (generally interesting presentations
and visualization of structured data and media).  Whenever we've had
customers where we get to influence the framework used, we'll sell
Django into the account.  However, we've had customers comeback and
want to build on Rails for the exact opposite reason from this thread:
lack of people in the Austin area who know Python/Django to take on
the maintenance work after we've done the initial application build.
So it seems like we've got a bit of a chicken/egg problem.

Our organization is going continue to evangelize Django in our
community.  The more that the Django-community sells its virtues in
our various consulting gigs the more opportunity we'll get to use the
framework we love.  To further Malcolm's point above, be a good
programmer first.  Good programmers should be able to pick up (or
already know) multiple platforms, frameworks, languages quickly.
Being a first rate programmer who's technology agnostic will open up a
huge number of opportunities where you'll get to be the person who
influences what gets used in various situations.  It's in those
situations that you'll get to grab your favorite tool: Django.

Jon Loyens
Thinktiv, Inc.

On Jan 11, 1:14 am, Malcolm Tredinnick 
wrote:
> On Sat, 2009-01-10 at 15:38 -0700, David Lindquist wrote:
> > First, I understand that the world economy is in a slump, and that  
> > the job market as a whole has not fared well of late. But even before  
> > the recent downturn, I noticed that there are precious few jobs in  
> > Django development (yes, I know about DjangoGigs.com). A simple  
> > keyword search on popular job boards shows that the number of Ruby on  
> > Rails jobs outnumber Django easily by a factor of 10 or 20. True,  
> > Rails has been around longer, but not by much (a year maybe?).
>
> > So my question to the group is: if Rails has been widely adopted in  
> > the enterprise, why hasn't Django? Do you think Django will catch on?  
> > Or do you think it will be more of a "boutique" framework?
>
> There are some slight problems with your methodology. Large companies
> adopting something like Django aren't necessarily going to be posting to
> djangogigs.com or places like that. They'll already have competent
> programmers in-house to do the work. Or they'll hire through more
> traditional channels. So it might well be that Django is more heavily
> used in large organisations than Rails and all the Rails jobs you see
> being advertised are because there are lots more gigs at the smaller
> end.
>
> I have no evidence to support this either way, but it's always tough to
> estimate "the number of people using X" by the job advertisements
> without a lot more controlling of factors.
>
> It's probably a mistake to base your entire career for any period of
> time on only doing Django work unless you have some long-term contract
> or permanent position already lined up. But it's not a bad skill to have
> in your bag of tools, since many other problems that contractors are
> asked to solve can be solved using that particular skill. Keep in mind
> that keyword searches only find offerings where the client/employer has
> already picked the solution and is trying to backfill a lack of skills
> and hoping desperately that adding more people or bringing in new people
> won't make things worse than they are (hiring contractors is very
> risky). There are many other positions where the hirer is in a position
> of having a problem and after a solution. That's where the experienced,
> all-around consultant can often add genuine value.
>
> Over the years, Python job advertisements have lagged behind other,
> trendier areas. It's led to some perception problems, particularly when
> trying to "sell" Python-based solutions to more conservative outfits.
> But you can only hold one job at a time, so all you need is one job
> opening in an area you can work in and you're fine. Do you want to be a
> quality craftsman in an area where the quality can be identified
> (Python), or just one of tens or hundreds of thousands in an area like
> Rails or Java or C#?
>
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" 

Re: setting cookies following comment post

2009-01-11 Thread Eric Abrahamsen

Solving my own problem... This wasn't nearly as hard as I thought,
here's the solution that worked for me:

urls.py
#
from datetime import datetime, timedelta
from django.conf.urls.defaults import *
from django.contrib.comments.views import comments
...others...

def remember_wrapper(fn):
"Set a cookie for commenters who want their personal info to be
remembered."
def wrapper(request,*args,**kwargs):
resp = fn(request,*args,**kwargs)
if resp.status_code == 302: # 302 must mean successful
post
if request.POST.get("remember",False):
cookie_val = "%s,%s,%s" % (request.POST.get
("name",''),request.POST.get("email",''),request.POST.get("url",''))
exp = datetime.now() + timedelta(days=30)
resp.set_cookie('mysite_comment',cookie_val,expires=exp.strftime
('%a, %d %b %Y %H:%M:%S'))
else:
resp.delete_cookie('mysite_comment')
return resp
return wrapper

urlpatterns = patterns("",
...many...
(r'^comments/post/$',remember_wrapper(comments.post_comment)),
(r'^comments/', include('django.contrib.comments.urls')),
...and more...
)

The views that display comment forms check for this cookie, and use
the information to populate the form. I suppose that could be done as
a context processor.

Hope someone finds that useful,
Eric

On Jan 4, 12:03 pm, Eric Abrahamsen  wrote:
> Hi there,
>
> I'm adding a "remember me" checkbox tocommentforms, so that regular  
> commenters can avoid having to enter their personal information, if  
> they want. I was originally thinking of making this a function  
> attached to the comment_was_posted signal, but it will have to be  
> implemented using cookies, which need to be set on the outgoing  
> response, which isn't available in signal handlers...
>
> I'm wondering if anyone else has made a functionality like this using  
> thecommentcontrib app, and how they went about doing it. There  
> doesn't seem to be any point in the process where I could get hold of  
> the response.
>
> Thanks!
> Eric
--~--~-~--~~~---~--~~
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: forms/widgets media: position of 'class' directive

2009-01-11 Thread Ramiro Morales

On Sun, Jan 11, 2009 at 10:33 AM, Artem Skvira  wrote:
>
> Hi all,
>
> I've stumbled upon strange behaviour in django: when declaring form/
> widget with class Media, ie.:
>
> class AddressForm(ModelForm):
>streetNo = forms.CharField()
>...
>
>class Meta:
>...
>
>class Media:
>js = ('prototype.js', )
>
> I get tons of javascript inclusions rendered to page, for each
> character in 'prototype.js', ie.
> 
> 
> 
>
> etc
>
> However, when I move 'class Media:' to the top of the class everything
> works ok.
> Seems to be a bug to me.

I can't reproduce this. I've pasted at http://dpaste.com/107769/
a patch against Django forms regression tests that adds a test
demonstrates this works as expected.

Can you try to massage that new test to see if, adding details from
your own case to it, you can reproduce what you are seeing?.

Of course, the only way I could reproduce what you report is
using:

js = 'prototype.js'

-- 
 Ramiro Morales

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



forms/widgets media: position of 'class' directive

2009-01-11 Thread Artem Skvira

Hi all,

I've stumbled upon strange behaviour in django: when declaring form/
widget with class Media, ie.:

class AddressForm(ModelForm):
streetNo = forms.CharField()
...

class Meta:
...

class Media:
js = ('prototype.js', )

I get tons of javascript inclusions rendered to page, for each
character in 'prototype.js', ie.




etc

However, when I move 'class Media:' to the top of the class everything
works ok.
Seems to be a bug to me.



--~--~-~--~~~---~--~~
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: debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Malcolm Tredinnick

On Sun, 2009-01-11 at 03:41 -0800, Flo Ledermann wrote:
> Hi all,
> 
> I just bumped into a problem I can't resolve: after adding the {%
> debug %} template tag to one of my templates (no other changes), I get
> the following error message:
> 
> TemplateSyntaxError at /art/
> 
> Caught an exception while rendering: 'ascii' codec can't encode
> character u'\u2019' in position 19: ordinal not in range(128)
> 
> I haven't used the debug tag before, and googleing the error message
> didn't bring up anything useful for me, so I am turning to the group
> for help. I paste the stack trace and a subset of my settings below.

Looking at the traceback, I'm going to guess that the debug tag isn't
handling non-ASCII characters correctly. It doesn't get used too much,
so it may have survived all this time with such a bug in it. A bit
embarassing (for me).

If you open a ticket in Trac and assign it to me (mtredinnick), I'll
look at it in a day or two. Not going to do it right now, since it's
just after midnight here and I'm about to go to sleep.

Regards,
Malcolm



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



Re: def clean_file works with django server but not with apache

2009-01-11 Thread Alan
Oops, I found something. I am using apache2 + mod_wsgi and I notice that
instead of using my Fink python ('/sw/bin/python') it's using my mac python
('/usr/bin/python').
I compiled mod_wsgi with fink python, even though I had to put something
like:

WSGIDaemonProcess webapps user=alan group=staff processes=1 threads=16\

 python-path=/sw/lib/python2.5:/sw/lib/python2.5/site-packages

in my httpd.conf file.

Yet, under the light of these news I still have no idea about how to solve
my problem. And maybe now it's a new problem: how to make apache2 + mod_wsgi
use fink python and not system python (for Mac in particular)?

Cheers,
Alan

On Sun, Jan 11, 2009 at 12:47, Alan  wrote:

> Hi List,
> I have this problem now. It's about a form in my models.py that works as
> expected when testing with django server but when testing with apache sever
> (all in the same machine, mac osx leopard) it does not work as desired.
>
> class GridJobForm(forms.Form):
>
> file = forms.FileField(help_text="(Mandatory)")
>
> title = forms.CharField(max_length=255, required=False, help_text=
> "(Optional)")
>
>
> def clean_file(self):
>
> file = self.cleaned_data['file']
>
> print file.content_type
>
> if len(file) > gridMaxFileSize * 1024 * 1024: #bytes
>
> raise forms.ValidationError('File size must not exceed %s Mb.'% 
> gridMaxFileSize)
>
> msg1 = 'File upload must be a valid ZIP/TGZ/BZ2 archive.'
>
> msg2 = 'Could not unzip file.'
>
> msg3 = 'Could not uncompress file.'
>
> msg4 = 'Bad zip file'
>
> #print file.content_type application/x-tar
>
> if file.content_type == 'application/zip':
>
> try:
>
> zip = zipfile.ZipFile(file) #StringIO( file['content'] ) )
>
> except:
>
> raise forms.ValidationError(msg2)
>
> bad_file = zip.testzip()
>
> zip.close()
>
> del zip
>
> if bad_file:
>
> raise forms.ValidationError(msg4)
>
> elif file.content_type in ['application/x-gzip',
> 'application/x-tar', 'application/octet-stream']:
>
> try:
>
> tarfile.open(fileobj=file) #< problem with apache?
>
> except:
>
> raise forms.ValidationError(msg3)
>
> else:
>
> raise forms.ValidationError(msg1)
>
> return self.cleaned_data['file']
>
> It happens when I submit a tgz file to my apps under apache and the code
> enters in "elif file.content_type in ['application/x-gzip'...". When it
> "try" 'arfile.open(fileobj=file)' it fails and raises msg3.
>
> I have no idea how to debug this and can't figure out how come it happens.
> I tried big and small files (thinking it could be something related
> to InMemoryUploadedFile).
>
> I did just another thing: I removed the "try" to see what django debug
> would report under apache and I got this:
>
> AttributeError at /ccpngrid/
>
> 'NoneType' object has no attribute 'startswith'
>
> Any help would be very appreciated. Many thanks in advance.
>
> Cheers,
> Alan
>
>
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> >>http://www.bio.cam.ac.uk/~awd28<<
>



-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

--~--~-~--~~~---~--~~
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: deploying in server and templates folder is wrong:

2009-01-11 Thread Alan
Many thanks Steve. I thought I had designed my apps bulletproof for local
setups but I clearly failed.
Thanks a lot again.

Cheers,
Alan

On Sat, Jan 10, 2009 at 21:47, Steve Potter  wrote:

>
>
>
> On Jan 10, 3:44 pm, Alan  wrote:
> > Hello List,
> > So, using django server por development and my apps were working fine.
> Now
> > that I got apache2 + mod_wsgi working (on Mac Leopard), when trying to
> > access a page, I always get a error saying "TemplateDoesNotExist" and I
> can
> > see why, it's looking for templates in $HOME folder (eg.
> > "/Users/alan/templates/index.html" but it is in "
> > /Users/alan/workspace/webapps/templates") and obviously they are not
> there.
> >
> > Any idea of what is going wrong here? Any help would be very appreciated.
> >
> > Many thanks in advance.
> >
> > Alans.
>
> You need to edit your settings.py file and change your TEMPLATE_DIRS
> to point to the new location.
>
> Steve
>
> >
>


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

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



def clean_file works with django server but not with apache

2009-01-11 Thread Alan
Hi List,
I have this problem now. It's about a form in my models.py that works as
expected when testing with django server but when testing with apache sever
(all in the same machine, mac osx leopard) it does not work as desired.

class GridJobForm(forms.Form):

file = forms.FileField(help_text="(Mandatory)")

title = forms.CharField(max_length=255, required=False, help_text=
"(Optional)")


def clean_file(self):

file = self.cleaned_data['file']

print file.content_type

if len(file) > gridMaxFileSize * 1024 * 1024: #bytes

raise forms.ValidationError('File size must not exceed %s Mb.' %
gridMaxFileSize)

msg1 = 'File upload must be a valid ZIP/TGZ/BZ2 archive.'

msg2 = 'Could not unzip file.'

msg3 = 'Could not uncompress file.'

msg4 = 'Bad zip file'

#print file.content_type application/x-tar

if file.content_type == 'application/zip':

try:

zip = zipfile.ZipFile(file) #StringIO( file['content'] ) )

except:

raise forms.ValidationError(msg2)

bad_file = zip.testzip()

zip.close()

del zip

if bad_file:

raise forms.ValidationError(msg4)

elif file.content_type in ['application/x-gzip', 'application/x-tar',
'application/octet-stream']:

try:

tarfile.open(fileobj=file) #< problem with apache?

except:

raise forms.ValidationError(msg3)

else:

raise forms.ValidationError(msg1)

return self.cleaned_data['file']

It happens when I submit a tgz file to my apps under apache and the code
enters in "elif file.content_type in ['application/x-gzip'...". When it
"try" 'arfile.open(fileobj=file)' it fails and raises msg3.

I have no idea how to debug this and can't figure out how come it happens. I
tried big and small files (thinking it could be something related
to InMemoryUploadedFile).

I did just another thing: I removed the "try" to see what django debug would
report under apache and I got this:

AttributeError at /ccpngrid/

'NoneType' object has no attribute 'startswith'

Any help would be very appreciated. Many thanks in advance.

Cheers,
Alan


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

--~--~-~--~~~---~--~~
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: editing multiple records using admin list view

2009-01-11 Thread Alex Koshelev

There is an application:
http://code.google.com/p/django-batchadmin/


On Sun, Jan 11, 2009 at 1:53 PM, sateeshk...@gmail.com
 wrote:
>
> Hi,
>  I want to edit multiple records of users ( say selecting the user
> records which I want to edit ) and then say if I press
> activate button, all the records status should change to 'ACTIVE'.
>  To do this kind of thing, is there any simple tweak in admin model
> or admin templates ?
>  If some one has already done this kind of application, please share
> the information.
>
>  Right now with out  any tweaks I can only do single record record
> edit going to record detail page, which is not always easy to do.
>
> Thank you,
> Sateesh.
> >
>

--~--~-~--~~~---~--~~
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: debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Flo Ledermann

Oh, I should probably add that I am using

# coding=utf-8

on some of my source files, because they contain unicode default
values etc.

Flo


--~--~-~--~~~---~--~~
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: reusable apps and dependencies

2009-01-11 Thread uber.ubiwanken...@gmail.com

Thank you both,
one more thing...
I think it's a very common situation, isn't it?
I mean, if you don't use apps inside your project, you have to manage
the case of different versions of the same app.
But I found only few posts about that, I wonder why?
Do I have to put django-cms in every project? Is it the right choice?

You have the same problem, don't you? How do you do?

Thanks so much!
Giorgio


On Jan 10, 8:49 pm, eXt  wrote:
> On 10 Sty, 20:15, "uber.ubiwanken...@gmail.com" 
> wrote:
> > Sorry, I'm afraid I was not too clear.
> > What I have to do? How I have to put the new version?
> > How can I have both versions of django-cms?
>
> Use virtualenv! It is what you need :)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Flo Ledermann

Hi all,

I just bumped into a problem I can't resolve: after adding the {%
debug %} template tag to one of my templates (no other changes), I get
the following error message:

TemplateSyntaxError at /art/

Caught an exception while rendering: 'ascii' codec can't encode
character u'\u2019' in position 19: ordinal not in range(128)

I haven't used the debug tag before, and googleing the error message
didn't bring up anything useful for me, so I am turning to the group
for help. I paste the stack trace and a subset of my settings below.

Thanks in advance for any hints,

Flo Ledermann

-

Original Traceback (most recent call last):
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\debug.py", line 71, in render_node
result = node.render(context)
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\defaulttags.py", line 54, in render
output = [pformat(val) for val in context]
  File "C:\lib\Python2.5.2\lib\pprint.py", line 59, in pformat
return PrettyPrinter(indent=indent, width=width,
depth=depth).pformat(object)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 111, in pformat
self._format(object, sio, 0, 0, {}, 0)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 129, in _format
rep = self._repr(object, context, level - 1)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 195, in _repr
self._depth, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 207, in format
return _safe_repr(object, context, maxlevels, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 251, in _safe_repr
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 292, in _safe_repr
rep = repr(object)
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\loader_tags.py", line 17, in __repr__
return "" % (self.name,
self.nodelist)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in
position 19: ordinal not in range(128)


-


ABSOLUTE_URL_OVERRIDES
{}
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
AUTH_PROFILE_MODULE
'mainsite.Actor'
BANNED_IPS
()
CACHE_BACKEND
'locmem://'
CACHE_MIDDLEWARE_KEY_PREFIX
''
CACHE_MIDDLEWARE_SECONDS
600
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
'postgresql_psycopg2'
DATETIME_FORMAT
'N j, Y, P'
DATE_FORMAT
'N j, Y'
DEBUG
True
DEBUG_PROPAGATE_EXCEPTIONS
False
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
DEFAULT_INDEX_TABLESPACE
''
DEFAULT_TABLESPACE
''
DISALLOWED_USER_AGENTS
()
FILE_CHARSET
'utf-8'
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_TEMP_DIR
None
FIXTURE_DIRS
()
FORCE_SCRIPT_NAME
None
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INTERNAL_IPS
()
JING_PATH
'/usr/bin/jing'
LANGUAGES
(('ar', 'Arabic'), ('bn', 'Bengali'), ('bg', 'Bulgarian'), ('ca',
'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de',
'German'), ('el', 'Greek'), ('en', 'English'), ('es', 'Spanish'),
('et', 'Estonian'), ('es-ar', 'Argentinean Spanish'), ('eu',
'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'),
('ga', 'Irish'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he',
'Hebrew'), ('hr', 'Croatian'), ('is', 'Icelandic'), ('it', 'Italian'),
('ja', 'Japanese'), ('ka', 'Georgian'), ('ko', 'Korean'), ('km',
'Khmer'), ('kn', 'Kannada'), ('lv', 'Latvian'), ('lt', 'Lithuanian'),
('mk', 'Macedonian'), ('nl', 'Dutch'), ('no', 'Norwegian'), ('pl',
'Polish'), ('pt', 'Portugese'), ('pt-br', 'Brazilian Portuguese'),
('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl',
'Slovenian'), ('sr', 'Serbian'), ('sv', 'Swedish'), ('ta', 'Tamil'),
('te', 'Telugu'), ('tr', 'Turkish'), ('uk', 'Ukrainian'), ('zh-cn',
'Simplified Chinese'), ('zh-tw', 'Traditional Chinese'))
LANGUAGES_BIDI
('he', 'ar', 'fa')
LANGUAGE_CODE
'en-us'
LANGUAGE_COOKIE_NAME
'django_language'
LOCALE_PATHS
()
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
MONTH_DAY_FORMAT
'F j'
PASSWORD_RESET_TIMEOUT_DAYS
''
PREPEND_WWW
False
PROFANITIES_LIST
''
ROOT_URLCONF
'kunstwien.urls'
SECRET_KEY
''
SEND_BROKEN_LINK_EMAILS
False
SERVE_STATIC
True
SESSION_COOKIE_AGE

Re: which class does ####__iexact belong to, where #### is the attribute of a model?

2009-01-11 Thread bruno desthuilliers

On 10 jan, 18:56, rabbi  wrote:
> Hi,
> I'm trying to write a generic filter function do something like
> following:
>MyModel.objects.filter(   getattr(???,my_dict['search_field']
> +'__iexact')=my_dict['search_value']   )
>
> But I don't know what to put in place of '???'
> Where does 'field__iexact' actually come from?

Nowhere.

> Is it part of MyModel or somewhere else?

Nope, it's only a keyword argument - nothing else than a litteral
name, really. As Christian already mentioned, the solution here is to
build the name as a string, use this string as a key in a dict, then
pass the dict to filter using the **youdicthere calling convention.
You can read the Python tutorial's part on function arguments and
function calls for more in-depth explanations.


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



editing multiple records using admin list view

2009-01-11 Thread sateeshk...@gmail.com

Hi,
  I want to edit multiple records of users ( say selecting the user
records which I want to edit ) and then say if I press
activate button, all the records status should change to 'ACTIVE'.
  To do this kind of thing, is there any simple tweak in admin model
or admin templates ?
  If some one has already done this kind of application, please share
the information.

  Right now with out  any tweaks I can only do single record record
edit going to record detail page, which is not always easy to do.

Thank you,
Sateesh.
--~--~-~--~~~---~--~~
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: dynamic mod wsgi

2009-01-11 Thread Graham Dumpleton



On Jan 11, 7:59 pm, Ben Eliott  wrote:
> Hi Graham,
> Just following up on this thread. I replied with some details, but  
> maybe you missed those, or maybe i missed your reply. Or maybe this  
> isn't worth it and i should stop being lazy and just write out the  
> VirtualHost files :)

I missed the posts. It was a festive time of year, plus have been
exceedingly busy.

If the only thing this web server is going to host is the Django
instances, you are possibly better of not using VirtualHost at all,
but use mod_rewrite to implement virtual hosts. See:

  http://groups.google.com/group/modwsgi/browse_frm/thread/c29dde8fbef68e0b#

They never came back with final configuration which incorporated
static media hosting distinct for each site, but not too much work.
Perhaps post a followup to that thread if you want to work through
static media aliases that are needed so each instance can have its own
separate media files.

Also perhaps use that thread if you want to discuss how to extend that
scheme such that a pool of daemon processes is available and so you
can have dynamic assignment to one of the daemon process groups from
the pool.

Discussion on the mod_wsgi list where that thread is in general better
for me as it then comes in my mail box and don't miss it, where as
just browse here occasionally so don't always pick up posts.

Graham

> On 23 Dec 2008, at 01:13, Graham Dumpleton wrote:
>
>
>
> > Have some further questions about what you want to do.
>
> > Do you want a separate daemon process for each distinct Django site,
> > or are you happy with one really fat process which contains each
> > Django site in a separate sub interpreter of that process?
>
> > How much memory does each Django site instance take up?
>
> > How many different site instances would you have?
>
> > Are all the site instances distinguishable by server name alone?
>
> > Graham
>
> > On Dec 23, 9:00 am, Graham Dumpleton 
> > wrote:
> >> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>
> >>> Hi Graham,
> >>> I've finally managed to get back to the wildcard subdomains &  
> >>> mod_wsgi
> >>> today. Unfortunately the discussion thread you mentioned has
> >>> disappeared and after a few hours i still seem to be doing a good  
> >>> job
> >>> of getting nowhere.
>
> >> I can still access thread with no problems.
>
> >>> Although you mentioned using mod_rewrite to get hold of the url
> >>> variable, it looks like the %{SERVER} variable in mod_wsgi might  
> >>> take
> >>> care of this already?
>
> >>> My main issue seems to be to accessing the %{SERVER} (or relevant
> >>> mod_rewrite) variable in the .wsgi script, to specify a particular
> >>> settings file.
>
> >>> Within a VirtualHost i have:
> >>> WSGIApplicationGroup %{SERVER}
> >>> WSGIDaemonProcess %{SERVER} ...threads etc
> >>> WSGIProcessGroup %{SERVER}
>
> >> The %{SERVER} value is only magic when used with WSGIApplicationGroup
> >> directive.
>
> >>> So this is probably hoplessly wrong also, but if you can give some
> >>> further pointers that would be most kind.
>
> >> Can you post a more complete example of your Apache configuration
> >> showing what you are trying to achieve.
>
> >> Sorry I didn't get back to you last time, it was a hectic few weeks.
> >> Things have settled down somewhat now, so I'll go back over your
> >> original post and work out again what it is you were trying to do.
>
> >> Graham
>
> >>> Thanks and Regards,
> >>> Ben
>
> >>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>
>  On Dec 9, 8:05 pm, Ben Eliott  wrote:
> > Graham,
> > Thank you for coming back personally to such a lowly wsgi  
> > question! I
> > started reading your email and thinking the answer was 'no', then
> > ended up thinking 'definitely maybe'. I'll keep an eye out in case
> > you
> > post more, otherwise i'll follow those links and your directions  
> > and
> > hope to report back with some progress.
>
>  I'll definitely try and say more later when get a chance.
>
>  Just do be aware of one thing. By using a single WSGI script file  
>  for
>  multiple sites, you loose the ability with mod_wsgi daemon mode to
>  touch the WSGI script file and cause a single site to be  
>  reloaded. One
>  would normally use this as a way of reloading a single site without
>  the need to restart the whole of Apache. When sharing the single  
>  WSGI
>  script file across sites, touching the WSGI script file will  
>  restart
>  all sites using that WSGI script file. If they share the code  
>  this may
>  actually be want you want, so not a problem, but worth mentioning.
>
>  In this arrangement, if you did want to reload one site, for  
>  example
>  because you change its settings file, you would need to use 'ps' to
>  identify process(es) in that daemon process group, based on 

Re: Model Updates. use save() or signals

2009-01-11 Thread Malcolm Tredinnick

On Sun, 2009-01-11 at 01:53 -0800, Matt Welch wrote:
> I appreciate it. Thank you.
> 
> I tried the examples you said and ran into one problem on the first
> ( happened in the second, but fixed ).
> 
> On Jan 11, 3:12 am, Malcolm Tredinnick 
> wrote:
> > On Sun, 2009-01-11 at 00:11 -0800, juice wrote:
> > > > > I then figured it may run into a loop of saving the same model, so i
> > > > > was going to use signals but ran into the same issue that it would
> > > > > still need to be in the save function.
> >
> > > > Are you talking about the infinite loop problem here? I don't understand
> > > > this paragraph.
> >
> > > Yes sir, after talking with webology, he also pointed out it would end
> > > up in an infinite loop. So i went looking into signals.
> >
> > I think you may have thrown out the baby with the bathwater there. All
> > you should have to do is check if the location you retrieve is the same
> > as the current one and, if so, don't do the update. Like this:
> >
> > def save(self, *args, **kwargs):
> >oa = Article.objects.filter(location=self.location)
> >if oa and oa[0] != self:
> >   oa = oa(location=0)
> >   oa.save()
> >super(Article, self).save(*args, **kwargs)
> >
> 
> This returned 'QuerySet' object is not callable, so i changed
> Article.objects.filter -> Article._default_manager.filter(), still
> returning the same problem with the update.

Oh. This is because I'm an idiot and wasn't concentrating. The lines

oa = oa(location=0)
oa.save()

are bogus. "oa" is a queryset, not an object. It should be 

obj = oa[0]
obj.location = 0
obj.save()

Regards,
Malcolm



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



Re: django-admin.py not working on Vista

2009-01-11 Thread Cody

Hi Rex, I came across this same problem and fixed it by editing the
registry like this:

Go to HKEY_CLASSES_ROOT and find .py
Change its (Default) setting to Python.File

Mine was set to py_auto_file when I associated the extension through
Windows.

Anyway, that got django-admin.py running right.

-Cody

On Jan 10, 12:25 am, Rex  wrote:
> On Jan 9, 11:51 pm, "Karen Tracey"  wrote:
>
>
>
> > On Fri, Jan 9, 2009 at 10:55 PM, Rex  wrote:
>
> ...
> > > I Googled around, and the only thing I found was this comment:
>
> > > "you have to change the file association from (cant remember) to "%1″
> > > %* and it should work"
> > > Source:
> > >http://i.justrealized.com/2008/04/08/how-to-install-python-and-django...
>
> > > Does anyone understand what this means?
>
> > I do, but I don't have Vista so I can't give you step-by-step instructions
> > for changing the file associations there.  On earlier levels you would do
> > something like Start->Settings->Control Panel->Folder Options, then select
> > "File Types" tab, then find .py in the list, click "Advanced" button, select
> > the "open" action and click the "Edit" button,  and put that "%1″ %* string
> > at the end replacing whatever follows the actual "c:\path\to\python.exe".  I
> > have no idea if the procedure under Vista is similar or substantially
> > different.
>
> > Karen
>
> Thanks Karen. Unfortunately, those instructions don't seem to apply to
> Vista. I also tried poking around in Control Panel > Default Programs,
> but nothing is turning up there either.
>
> Does anyone know how this is done on Vista?
>
> 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: Model Updates. use save() or signals

2009-01-11 Thread Matt Welch

I appreciate it. Thank you.

I tried the examples you said and ran into one problem on the first
( happened in the second, but fixed ).

On Jan 11, 3:12 am, Malcolm Tredinnick 
wrote:
> On Sun, 2009-01-11 at 00:11 -0800, juice wrote:
> > > > I then figured it may run into a loop of saving the same model, so i
> > > > was going to use signals but ran into the same issue that it would
> > > > still need to be in the save function.
>
> > > Are you talking about the infinite loop problem here? I don't understand
> > > this paragraph.
>
> > Yes sir, after talking with webology, he also pointed out it would end
> > up in an infinite loop. So i went looking into signals.
>
> I think you may have thrown out the baby with the bathwater there. All
> you should have to do is check if the location you retrieve is the same
> as the current one and, if so, don't do the update. Like this:
>
>         def save(self, *args, **kwargs):
>            oa = Article.objects.filter(location=self.location)
>            if oa and oa[0] != self:
>               oa = oa(location=0)
>               oa.save()
>            super(Article, self).save(*args, **kwargs)
>

This returned 'QuerySet' object is not callable, so i changed
Article.objects.filter -> Article._default_manager.filter(), still
returning the same problem with the update.

> I've fixed a couple of other problems with your initial code. In
> particular, if you're just inserting stuff into the normal save path,
> you need to be able to handle the force_update and force_insert
> arguments to save. Simplest way (since you don't care what the arguments
> are) is to just pass through *args and **kwargs like I've done above.
>
> You could even fine tune this a little bit by using a more specific
> queryset (excluding the "self" element) and even using the update()
> method. Behold the power of a fully operational Death Star ... er ...
> here's a different way of writing it, I mean:
>
>         def save(self, *args, **kwargs):
>            Article.objects.filter(location=self.location).
>               exclude(pk=self.pk).update(location=0)
>            super(Article, self).save(*args, **kwargs)

ran into the same objects "'QuerySet' object is not callable", but was
easily fixed with the _default_manager and worked great. Wasn't aware
you could do the .update(), making in chainable. But this worked:

def save(self, *args, **kwargs):

Article._default_manager.filter(location=self.location).exclude
(pk=self.pk).update(location=0)
super(Article,self).save(*args, **kwargs)


>
> Without testing it, I think that should work correctly even when self.pk
> is None (i.e. when you haven't saved for the first time). If not, you
> might need to not pass in the exclude() bit if self.pk is None, but test
> that out.
>
> > So with the help there and here, i moved onto signals.py. By trial and
> > error, I hope to get going, but have run into a roadblock.
>
> > If in the signals.py I put "from stories.models import Article", i
> > receive ImportError: cannot import name Article. Now my reasoning
> > behind this maybe wrong as well, so a little explanation there. I want
> > to import the model so I can do my query on all objects to find the
> > previous one with the old location...( or I think that is how I should
> > handle it)
>
> Since you don't show the code, and since my crystal ball is in for
> repairs this year, it's hard to tell what is wrong with your code. :-)
>
> My guess would be circular imports, which can be solved by not importing
> Article directly, but by writing
>
>         from stories import models as story_models
>
>         def my_signal_handler():
>            story_models.Article.objects.filter(...) # etc...
>
> I tend to import models from applications as something like
> _models as a habit these days, but you can drop the "as..."
> bit if you're only importing that one application model file there.
>
> Seehttp://groups.google.com/group/django-users/msg/a9ab126db3341fd3for
> an explanation I wrote last week about this type of thing.
>
> Still, signals feel like overkill for this situation. You've found the
> infinite loop case, so just walk around it in the code. Don't break out
> an entirely different shaped hammer.
>
> Regards,
> Malcolm

Thanks again for all your help,

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



Live Contacts Python API Problem

2009-01-11 Thread afrobeard

Hi,

I was wondering if anyone has taken a look at Live Contacts API at
http://msdn.microsoft.com/en-us/library/bb463989.aspx

I can get through step 1 i.e. Delegated Authentication. An exception
is being raised when urllib2 calls the open function. The nature of
the Error is 403 forbidden exception. Live Contacts API Errors are
defined on http://msdn.microsoft.com/en-us/library/bb463952.aspx

The only relevant post I could on any forum find related to this was:-
1. 
http://social.msdn.microsoft.com/Forums/en-US/wliddev/thread/06cdf66d-2c86-4536-ab8e-af448eec909d/


I'm really grateful for your help. Thanks. The code starts after this
paragraph. WindowsLiveLogin.py itself is availible at Microsoft's
download page http://msdn.microsoft.com/en-us/library/cc287637.aspx


def hotmail_importer_endpoint(request):
from uni.site.profile.views import WindowsLiveLogin

action = request.POST.get('action', None)
wll.setDebug(True)

if not action:
#Show Form or Login Link
url_text = wll.getConsentUrl("Contacts.Invite")
return HttpResponse('''
Click here to initiate authorization
'''%url_text)
else:
fs = {}
for post_var in request.POST:
if post_var in request.POST:
#fs[post_var].value should actually be equal to
request.POST[post_var] as Microsoft implemented it. I just changed the
code in WindowsLiveLogin.py to reflect this fast.
fs[post_var] = request.POST[post_var]
consent_token = wll.processConsent(fs)
#   The consent_token contains delt, reft, skey, exp, offer,
lid
#   Delegation Token
#   Refresh Token
#   session key
#   offer
#   exp
#   lid
token = consent_token
to_signed_64 = lambda x: x < 2**63 and x or x - 2**64
url = 'https://livecontacts.services.live.com/@c...@%s/REST/
LiveContacts/Contacts' % to_signed_64(int(token.getLocationID(), 16))
headers = {'Authorization': 'DelegatedToken dt="%s"' %
urllib.unquote(token.getDelegationToken())}
values = {}
data = urllib.urlencode(values)
req = urllib2.Request(url, data, headers)
response = urllib2.build_opener().open(req)
the_page = response.read()
--~--~-~--~~~---~--~~
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: Model Updates. use save() or signals

2009-01-11 Thread Malcolm Tredinnick

On Sun, 2009-01-11 at 00:11 -0800, juice wrote:
> > > I then figured it may run into a loop of saving the same model, so i
> > > was going to use signals but ran into the same issue that it would
> > > still need to be in the save function.
> >
> > Are you talking about the infinite loop problem here? I don't understand
> > this paragraph.
> 
> Yes sir, after talking with webology, he also pointed out it would end
> up in an infinite loop. So i went looking into signals.

I think you may have thrown out the baby with the bathwater there. All
you should have to do is check if the location you retrieve is the same
as the current one and, if so, don't do the update. Like this:

def save(self, *args, **kwargs):
   oa = Article.objects.filter(location=self.location)
   if oa and oa[0] != self:
  oa = oa(location=0)
  oa.save()
   super(Article, self).save(*args, **kwargs)

I've fixed a couple of other problems with your initial code. In
particular, if you're just inserting stuff into the normal save path,
you need to be able to handle the force_update and force_insert
arguments to save. Simplest way (since you don't care what the arguments
are) is to just pass through *args and **kwargs like I've done above.

You could even fine tune this a little bit by using a more specific
queryset (excluding the "self" element) and even using the update()
method. Behold the power of a fully operational Death Star ... er ...
here's a different way of writing it, I mean:

def save(self, *args, **kwargs):
   Article.objects.filter(location=self.location).
  exclude(pk=self.pk).update(location=0)
   super(Article, self).save(*args, **kwargs)

Without testing it, I think that should work correctly even when self.pk
is None (i.e. when you haven't saved for the first time). If not, you
might need to not pass in the exclude() bit if self.pk is None, but test
that out.

> So with the help there and here, i moved onto signals.py. By trial and
> error, I hope to get going, but have run into a roadblock.
> 
> If in the signals.py I put "from stories.models import Article", i
> receive ImportError: cannot import name Article. Now my reasoning
> behind this maybe wrong as well, so a little explanation there. I want
> to import the model so I can do my query on all objects to find the
> previous one with the old location...( or I think that is how I should
> handle it)

Since you don't show the code, and since my crystal ball is in for
repairs this year, it's hard to tell what is wrong with your code. :-)

My guess would be circular imports, which can be solved by not importing
Article directly, but by writing

from stories import models as story_models

def my_signal_handler():
   story_models.Article.objects.filter(...) # etc...

I tend to import models from applications as something like
_models as a habit these days, but you can drop the "as..."
bit if you're only importing that one application model file there.

See http://groups.google.com/group/django-users/msg/a9ab126db3341fd3 for
an explanation I wrote last week about this type of thing.

Still, signals feel like overkill for this situation. You've found the
infinite loop case, so just walk around it in the code. Don't break out
an entirely different shaped hammer.

Regards,
Malcolm



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



Re: dynamic mod wsgi

2009-01-11 Thread Ben Eliott

Hi Graham,
Just following up on this thread. I replied with some details, but  
maybe you missed those, or maybe i missed your reply. Or maybe this  
isn't worth it and i should stop being lazy and just write out the  
VirtualHost files :)
Ben

On 23 Dec 2008, at 01:13, Graham Dumpleton wrote:

>
> Have some further questions about what you want to do.
>
> Do you want a separate daemon process for each distinct Django site,
> or are you happy with one really fat process which contains each
> Django site in a separate sub interpreter of that process?
>
> How much memory does each Django site instance take up?
>
> How many different site instances would you have?
>
> Are all the site instances distinguishable by server name alone?
>
> Graham
>
> On Dec 23, 9:00 am, Graham Dumpleton 
> wrote:
>> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>>
>>> Hi Graham,
>>> I've finally managed to get back to the wildcard subdomains &  
>>> mod_wsgi
>>> today. Unfortunately the discussion thread you mentioned has
>>> disappeared and after a few hours i still seem to be doing a good  
>>> job
>>> of getting nowhere.
>>
>> I can still access thread with no problems.
>>
>>> Although you mentioned using mod_rewrite to get hold of the url
>>> variable, it looks like the %{SERVER} variable in mod_wsgi might  
>>> take
>>> care of this already?
>>
>>> My main issue seems to be to accessing the %{SERVER} (or relevant
>>> mod_rewrite) variable in the .wsgi script, to specify a particular
>>> settings file.
>>
>>> Within a VirtualHost i have:
>>> WSGIApplicationGroup %{SERVER}
>>> WSGIDaemonProcess %{SERVER} ...threads etc
>>> WSGIProcessGroup %{SERVER}
>>
>> The %{SERVER} value is only magic when used with WSGIApplicationGroup
>> directive.
>>
>>> So this is probably hoplessly wrong also, but if you can give some
>>> further pointers that would be most kind.
>>
>> Can you post a more complete example of your Apache configuration
>> showing what you are trying to achieve.
>>
>> Sorry I didn't get back to you last time, it was a hectic few weeks.
>> Things have settled down somewhat now, so I'll go back over your
>> original post and work out again what it is you were trying to do.
>>
>> Graham
>>
>>> Thanks and Regards,
>>> Ben
>>
>>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>>
 On Dec 9, 8:05 pm, Ben Eliott  wrote:
> Graham,
> Thank you for coming back personally to such a lowly wsgi  
> question! I
> started reading your email and thinking the answer was 'no', then
> ended up thinking 'definitely maybe'. I'll keep an eye out in case
> you
> post more, otherwise i'll follow those links and your directions  
> and
> hope to report back with some progress.
>>
 I'll definitely try and say more later when get a chance.
>>
 Just do be aware of one thing. By using a single WSGI script file  
 for
 multiple sites, you loose the ability with mod_wsgi daemon mode to
 touch the WSGI script file and cause a single site to be  
 reloaded. One
 would normally use this as a way of reloading a single site without
 the need to restart the whole of Apache. When sharing the single  
 WSGI
 script file across sites, touching the WSGI script file will  
 restart
 all sites using that WSGI script file. If they share the code  
 this may
 actually be want you want, so not a problem, but worth mentioning.
>>
 In this arrangement, if you did want to reload one site, for  
 example
 because you change its settings file, you would need to use 'ps' to
 identify process(es) in that daemon process group, based on what
 display-name option was set to, and send all those processes in  
 that
 daemon process group a SIGINT using the 'kill' command.  
 Alternatively,
 you would need to setup a background thread which monitored  
 something
 like the distinct settings file for each site and have the process
 itself send a SIGINT to itself. This would be a variation on
 background reloader described in:
>>
  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_ 
 ...
>>
 More later.
>>
 Graham
>>
> Thanks and Regards,
> Ben
>>
> On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:
>>
>> On Dec 9, 6:53 pm, "ben.dja...@googlemail.com"
>>  wrote:
>>> Hi, I'm converting to the excellent mod_wsgi and wondering if  
>>> it's
>>> possible to make a single httpd virtual host/wsgi file to manage
>>> wildcard subdomains.
>>
>>> Basically I have an app where i'm creating a new instance for  
>>> each
>>> client and using subdomains. So client1.example.com and
>>> client2.example.com both point to the same app, but their own
>>> settings.py/django instance.
>>
>>> So far so fine.  I've been happily converting to mod_wsgi  
>>> 

Re: Model Updates. use save() or signals

2009-01-11 Thread juice

> > I then figured it may run into a loop of saving the same model, so i
> > was going to use signals but ran into the same issue that it would
> > still need to be in the save function.
>
> Are you talking about the infinite loop problem here? I don't understand
> this paragraph.

Yes sir, after talking with webology, he also pointed out it would end
up in an infinite loop. So i went looking into signals.

So with the help there and here, i moved onto signals.py. By trial and
error, I hope to get going, but have run into a roadblock.

If in the signals.py I put "from stories.models import Article", i
receive ImportError: cannot import name Article. Now my reasoning
behind this maybe wrong as well, so a little explanation there. I want
to import the model so I can do my query on all objects to find the
previous one with the old location...( or I think that is how I should
handle it)

thanks again

matt

On Jan 11, 1:21 am, Malcolm Tredinnick 
wrote:
> On Sat, 2009-01-10 at 22:26 -0800, juice wrote:
> > I am having trouble with setting up a pre_save signal. I want to be
> > able to set a location in a model instance, but only have 1 entry at
> > any time. I thought about just overriding the save, and adding an
> > update something like:
>
> > def save(sefl):
> >    oa = Article.objects.filter(location=self.location)
> >    oa = oa[0]
> >    oa = oa(location=0)
> >    oa.save()
> >    super.save()
>
> > Something so that it will find the old object with that location, set
> > it to 0, then continue with the new updated one. This is having
> > problems on the queryset operations.
>
> Define "problems". It did nothing? It raised an exception? Your computer
> caught on fire? It will use understand what the underlying issue is.
>
> One thing that does jump out is you'll almost certainly need to handle
> the oa == self case, since that will infinitely loop, by the looks of it
> (once you fix the various syntax errors in the above).
>
> > I then figured it may run into a loop of saving the same model, so i
> > was going to use signals but ran into the same issue that it would
> > still need to be in the save function.
>
> Are you talking about the infinite loop problem here? I don't understand
> this paragraph.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---