Re: Has anything changed with Sagepay/protx apart from the name?

2009-07-14 Thread Kip Parker

No, I did not. Oh dear. Thanks for pointing this out Karen.

I am now off to the Satchmo group to post the same message, in case
anyone was wondering what it was all about.

Kip.

On Jul 14, 1:47 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Tue, Jul 14, 2009 at 7:42 AM, Kip Parker <k...@friendchip.com> wrote:
>
> > I noticed whilst researching which payment gateway to use that Protx
> > has become Sagepay. Anyone know if they've just changed the name (so
> > that the Protx payment module still works OK) or if they've changed
> > the product at all (so the Protx module doesn't)?
>
> Did you ask this on the right list?  I can't recall ever hearing either of
> these names mentioned before, so I'm not sure they have anything to do with
> Django?
>
> 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
-~--~~~~--~~--~--~---



Has anything changed with Sagepay/protx apart from the name?

2009-07-14 Thread Kip Parker

I noticed whilst researching which payment gateway to use that Protx
has become Sagepay. Anyone know if they've just changed the name (so
that the Protx payment module still works OK) or if they've changed
the product at all (so the Protx module doesn't)?

Kip.
--~--~-~--~~~---~--~~
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: LDAP support in Django?

2009-06-05 Thread Kip Parker

There's a lot of useful stuff on djangosnippets for LDAP and Active
Directory too:

http://www.google.co.uk/search?q=+LDAP+site%3Ahttp%3A%2F%2Fwww.djangosnippets.org

On Jun 5, 6:17 pm, Adam Stein  wrote:
> Just google django and ldap.  That's how I found how to set up Django
> authentication to use an LDAP server (works great).
>
>
>
> On Fri, 2009-06-05 at 08:52 -0700, Mike Driscoll wrote:
> > Hi,
>
> > Can someone tell me if Django has LDAP support builtin or as a plugin
> > of some sort? Or do I need to write all that myself? I saw references
> > to LDAP in the svn docs and I've found some snippets of code with the
> > ldap module and Django 0.96 as well as a blog post or two on rolling
> > your own LDAP integration.
>
> > Anyway, your advice would be welcome. I'm getting rather fed up with a
> > certain other Python web framework's poor documentation and unhelpful
> > community.
>
> > Thanks,
>
> > Mike
> > --
>
> Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> Disclaimer: Any/All views expressed
> here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
--~--~-~--~~~---~--~~
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: FileField uploading into an user-specific path

2009-04-29 Thread Kip Parker

upload_to can be a callable - 
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield.

On Apr 29, 4:59 am, "Carlos A. Carnero Delgado"
 wrote:
> Oops, too quick to press reply :o
>
> On Tue, Apr 28, 2009 at 11:53 PM, Carlos A. Carnero Delgado >
> destination_file = open('somewhere based on the user', 'wb+')
>
> >  for chunk in request.FILES['audio_file'].chunks():
> >      destination_file.write(chunk)
> >  destination_file.close()
>
> with this method you are manually handling the file, stepping over
> Django's FileField. You should make adjustments & corrections to
> account for that.
>
> Also note that 'audio_file' is just the name of the field, it should
> be named with your field name, of course. Remember also to include
> request.FILES when creating your form object after a POST.
>
> HTH,
> Carlos.
--~--~-~--~~~---~--~~
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: Change the url

2009-01-08 Thread Kip Parker

You can use reverse()  in your get_absolute_url method, it works the
same as the url template tag in using your url patterns to generate
the url.

http://docs.djangoproject.com/en/dev/topics/http/urls/?from=olddocs#reverse

On Jan 8, 12:58 pm, Praveen  wrote:
> Hi Briel i am totally confused now.
> My senior told me to write get_absolute_url
>
> so i wrote get_absolute_url like this
> class Listing_channels(models.Model):
>     list_channel = models.CharField(max_length = 20)
>     visibility = models.BooleanField()
>
>     def __unicode__(self):
>         return self.list_channel
>
>     def get_absolute_url(self):
>         return u'/category/listing_view/%i/' % self.id
>
> and in html template i am calling
>
> {%if listing_result %}
>     {% for n in listing_result %}
>          {{n.list_channel}} li>
>     {% endfor %}
> {% else %}
>     not available
> {% endif %}
> 
>
> so its working fine.
>
> so now i have two mechanism one is your as you told me to write and
> second one is
> get_absolute_url() function.
>
> Now my confusion is if we have another same class event_channel and
> event and many more classes like this then i will have to write
> get_absolute_url() for each class
> and if go with you then there i need to change only in urls.py that i
> think fine.
>
> so i should go with get_absolute_url? give me the best and solid
> reason so i could make understand to senior, and you know the senior
> behave..
>
> Briel wrote:
> > Using urls with names will solve your problem.
>
> > Basically if you change your urls.py like this:
>
> >     url(
> >         r'^category/listing_view/(?P\w+)/$',
> >        'mysite.library.views.listing_view',
> >        name = 'name_for_this_view'
> >     ),
>
> > What I have done is to add a name to the url for convenience I also
> > used the url() function. This name can now be used instead of the link
> > to your view. So if you were to change the site structure, when
> > changes would be made to your urlconf, django would then be able to
> > figure things out for you. In this version your new link would look
> > like this:
>
> > {{n.list_channel}}
>
> > In the docs you can read about it at
> > url():http://docs.djangoproject.com/en/dev/topics/http/urls/#url
> > naming:http://docs.djangoproject.com/en/dev/topics/http/urls/#id2
>
> > Good luck.
> > -Briel
>
> > On 8 Jan., 12:41, Praveen  wrote:
> > > Hi Malcolm i am very new bie of Django. i read through
> > > get_absolute_url but do not know how to use.
> > > What you have given the answer i tried with that and its working fine
> > > but my senior asked me what will happen if i change the site name then
> > > every where you will have to change url
> > > mysite.library.views.listing_view.
>
> > > so they told me to use get_absolute_url
>
> > > i wrote get_absolute_ul in models.py
> > > def get_absolute_url(self):
> > > return "/listing/%i/" % self.id
> > > and i am trying to use in my html page template but i don't know how
> > > to use
>
> > >  {{n.list_channel}} > > li>
>
> > > then again same problem. first time when some one click on link it
> > > works fine but second time it appends the link 
> > > likehttp://127.0.0.1:8000/category/listing_view/3/3
>
> > > Please give me some idea
>
> > > On Jan 8, 3:37 pm, Praveen  wrote:
>
> > > > Thank you so much Malcolm.
> > > > every one gives only the link and tell to read but your style of
> > > > solving the problem is amazing. how you explained me in a nice way
> > > > that i can never ever find in djangoproject.com.
> > > > Thanks you so much malcom
>
> > > > On Jan 8, 3:23 pm, Malcolm Tredinnick 
> > > > wrote:
>
> > > > > I'm going to trim your code to what looks like the relevant portion of
> > > > > the HTML template, since that's where the easiest solution lies.
>
> > > > > On Thu, 2009-01-08 at 02:02 -0800, Praveen wrote:
>
> > > > > [...]
>
> > > > > > list_listing.html
>
> > > > > > 
> > > > > > Sight Seeings
> > > > > > 
> > > > > > {%if listing_result %}
> > > > > > {% for n in listing_result %}
> > > > > > {{n.list_channel}}
> > > > > > {% endfor %}
> > > > > > {% else %}
> > > > > > not available
> > > > > > {% endif %}
> > > > > > 
> > > > > > 
>
> > > > > [...]
>
> > > > > > I am displaying Listing_channels and Listing on same page. if some 
> > > > > > one
> > > > > > click on any Listing_channels the corresponding Listing must display
> > > > > > on same page. that is why i am also sending the Listing_channels
> > > > > > object to list_listing.html page. if some one click first time on
> > > > > > Listing_channels it shows the 
> > > > > > urlhttp://127.0.0.1:8000/category/listing_view/1/
> > > > > > but second time it appends 1 at the end and the url becomes
> > > > > >http://127.0.0.1:8000/category/listing_view/1/1
>
> > > > > The above code fragment is putting an element in the template that 
> > > > > looks
> > > > > like
>

Re: Frustration with custom Inline forms

2008-11-17 Thread Kip Parker

There's a problem with the exclude statements above, you've got tuple-
trouble, missing trailing commas:

exclude = ('a55_id')  should be ('a55_id',) or ['a55_id']

easy mistake, search for "tuple" in this group and you'll see you have
company.

Kip.



On Nov 17, 2:01 pm, Ben Gerdemann <[EMAIL PROTECTED]> wrote:
> Ok, so I just noticed that the a55_id field which is the primary key,
> was declared as an IntegerField instead of an AutoField which is why
> it was showing up on the inline form, but I still can't get any of the
> other fields excluded from the inline form so the problem is still
> there.
>
> Also, if it helps for understanding Pais = Parents and Visitas =
> Visits in Portuguese.
>
> Thanks again for any and all help.
>
> Cheers,
> Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin site problem

2008-11-17 Thread Kip Parker

You need to turn it into a string, this will do it:

def __unicode(self):
   return '%s' % self.integer_column


On Nov 17, 12:41 pm, Vicky <[EMAIL PROTECTED]> wrote:
> I found the problem.. I used :
>
>                             def __unicode__(self):
>
> function in my model. so it a can return only sting values. So if i
> need to return a column of type integer or contains a foreign key how
> should i do it??
>
> On Nov 17, 4:28 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>
> > Vicky wrote:
> > > I tried to add some values to my table from admin site. Table has 3
> > > columns one of integer type and other two of string type. When i tried
> > > to save my entries it giving an error as:
>
> > >              "coercing to Unicode: need string or buffer, int found"
>
> > > How to solve it?
>
> > That all depends on what your model looks like?
> > /L
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Uploaded Files -> Don't appear in folder, but no errors

2008-10-27 Thread Kip Parker

To get a new object from a ModelForm you just save it, so the view
should be something like:

def uploadImage(request):

  if request.method == 'POST': #if submitted
form = UploadNewImageForm(request.POST, request.FILES)

if form.is_valid():
ir = form.save()
   rw = ResourceWrapper(name = form.cleaned_data['name'])
   rw.save()
   return HttpResponseRedirect('/Main_page/') # Redirect after
POST


form.save() will put the image in the right place.

Kip.

On Oct 26, 7:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I've been having some problems with FileField. I can create and save
> objects with the FileField file, but the file is never placed in any
> directory. Essentially, the database has the correct values, but no
> files are copied into the correct directory. I am using django-1.0.
>
> A temporary file is created in memory if the file is < 2.5M, and a
> temporary file is written to disk in /tmp/ if it is bigger. I have
> confirmed this. Do I have to specifically trigger the save to the hard
> disk to get the file to appear in my MEDIA_ROOT subfolder? From the
> documentation it appeared that this should be done automatically.
>
> Settings:
> MEDIA_ROOT = '/home/paul/proj/djangotest/uploads/'
>
> Model:
>
> class ImageResource(models.Model):
>   wrapper = models.ForeignKey(ResourceWrapper)
>   image = models.FileField(upload_to='images/')
>   notes = models.CharField(max_length=200)
>
> class ResourceWrapper(models.Model):
>   #incomplete class, for versioning later
>   name = models.CharField(max_length=200)
>   creationDate = models.DateField(auto_now_add=True)
>
> Form:
>
> class UploadNewImageForm(ModelForm):
>   name = forms.CharField(max_length=200)
>   class Meta:
>     model = ImageResource
>
> View:
>
> def uploadImage(request):
>
>   if request.method == 'POST': #if submitted
>     form = UploadNewImageForm(request.POST, request.FILES) # A form
> bound to the POST data
>
>     if form.is_valid(): # All validation rules pass
>
>       # Process the data in form.cleaned_data
>
>       #create a meta resource object
>       rw = ResourceWrapper(name = form.cleaned_data['name'])
>       rw.save()
>
>       #this is either a TemporaryFile or MemoryFile depending on its
> size when I debug
>       img = form.cleaned_data['image']
>
>       ir = ImageResource(wrapper=rw,
>                          notes = form.cleaned_data['notes'],
>                          image = img, ##maybe the problem is here???
>                          )
>       ir.save()
>
>       #redirect to the main page
>       return HttpResponseRedirect('/Main_page/') # Redirect after POST
>
> Any ideas? This is frustrating because there are no error messages to
> point me in the right direction, and everything else seems to work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Model design: OOP or Database-centric approach?

2008-10-23 Thread Kip Parker

Neither seem right to me. I'm not quite sure what the application
does, but it seems likely that a person only belongs to one family, in
which case you'll need a foreign key like this.

class Adult(models.Model):
name = models.CharField(maxlength=30)
partner = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
email = models.EmailField()
family = models.ForeignKey(Family)

also the Kinder and the adult classes are similar, so you might like
to look at using inheritance, perhaps from a person class that looks
like

class Person(models.Model):
name = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
family = models.ForeignKey(Family)

On Oct 23, 11:39 am, dustpuppy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm starting off with Django and trying my first (toy) project. It's a
> Kris Kindle application (called "Secret Santa"? by some). Not exactly
> earth-shattering, but I want to start with something small.
>
> I'm unsure what approach to use when designing my model.
>
> The entities I am dealing with are Family, Adult and Kinder.
>
> Normally for a standalone application (using Java or Python), I would
> design a class Family, with fields/attributes representing arrays/
> lists of objects of the classes Adult and Kinder.
> (Apologies if my OOP terminology is mixed-up - I'm originally a C/Perl
> programmer!)
>
> I've started my Django design that way:
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> class Family(models.Model):
>     name = models.CharField(maxlength=30)
>     children = models.ManyToManyField(Kinder)
>     adults = models.ManyToManyField(Adult)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         pass
>
> On the other hand, for any previous Web development I've done (with
> PHP or Perl), I would have define just 2 entities, Adult and Kinder,
> and simply included family as a string attribute of each.
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> I actually think the former would be easier to program, e.g. in terms
> of getting access to the lists of adults directly from the database,
> instead of having to retrieve it from a Family object first.
>
> Which of these would be the more appropriate way to do it in Django?
>
> Thanks in advance for taking the time to respond.
>
> Kind regards,
> Cormac.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using mod_python with Lighttpd - advice on the best set up

2008-09-30 Thread Kip Parker

Sounds good, how did you get it to do that?

On Sep 30, 1:03 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
> Apache can also start/restart your FastCGI process(es) as needed.
>
> Erik
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using mod_python with Lighttpd - advice on the best set up

2008-09-30 Thread Kip Parker

After both your replies and some googling I'm starting to lean towards
a FastCGI set up of some sort. The only thing that worries me is
dealing with FastCGI crashes, I guess you need a process watcher for
each site/FastCGI instance, what's that like to maintain in practice?

On Sep 29, 8:53 pm, Prairie Dogg <[EMAIL PROTECTED]> wrote:
> Conventional wisdom is that mod_python eats a little more
> memory than a correctly configured mod_wsgi.
>
> Here are some nice posts about using mod_wsgi in low memory
> environments:
>
> http://groups.google.com/group/modwsgi/browse_thread/thread/d21c33497...http://www.technobabble.dk/2008/aug/25/django-mod-wsgi-perfect-match/
>
> Another bit of conventional wisdom is that nginx > lighttpd
> because  of a memory leak in lighttpd, but my favorite
> endorsement of nginx was Will Larson's.  He chose
> nginx because it was Russian and "therefore exotic":
>
> http://lethain.com/entry/2007/jul/17/dreamier-dream-server-nginx/
>
> That, by the way was a blog post that helped me get my
> production servers up about a year ago using one of the
> techniques you were asking about called "reverse proxying"
> where requests for static media are handled up-front
> by a lightweight server and all other requests are sent through
> to apache / mod_whatever for the heavy lifting.
>
> On Sep 29, 1:37 pm, Kip Parker <[EMAIL PROTECTED]> wrote:
>
> > Thanks Frank, that's very interesting. A lack of complaining users is
> > much to be desired. Have you ever used this set up for multiple sites?
> > I have about 20 sites running, and there may well be more in the
> > future.
>
> > It would be excellent also to know what you found painful about
> > mod_python.
>
> > All the best,
>
> > Kip.
>
> > On Sep 29, 6:23 pm, Frantisek Malina <[EMAIL PROTECTED]> wrote:
>
> > > I wrote a post for you on my 
> > > blog:http://vizualbod.com/articles/nginx-fastcgiwsgi-django-deployment
>
> > > I've tried mod_python and it was a pain.
>
> > > Frankhttp://vizualbod.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: image path in CSS - won't work???

2008-09-30 Thread Kip Parker

A good start is to check you can view 
http://yoursite.com/site_media/img/menu.jpg
directly, if you get an error it will probably point you in the right
direction.

On Sep 30, 10:13 am, Bobo <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm having a very strange problem with my Django project. I’ve a menu
> with several links but I want to make a hover effect with it and for
> that I use pictures.
>
> The problem is that my path in my CSS won’t work and the pictures
> aren’t loaded and therefore not shown in the menu.
>
> My structure looks like this:
>
> Djangoapps > myDjangoApp > urls.py
> Djangoapps > myDjangoApp > skema > views.py
>
> Djangotemplates > base.html (in here lie my menu section and it’s also
> here I load the css file default.css)
>
> Html > site_media > css > default.css
> Html > site_media > img > a_hover.jpg
> Html > site_media > img > menu.jpg
>
> In my css file I have this code:
> #menu {
>         width:100%;
>         padding-top:20px;
>         padding-bottom:20px;
>         background-color:#003399;
>         color:#FF;
>         text-align:center;
>         font-family:Verdana, Arial, Helvetica, sans-serif;
>         font-size:11px;
>         font-variant:small-caps;
>         background-image: url('/site_media/img/menu.jpg');}
>
> #menu a {
>         color:#FF;
>         text-decoration:none;
>         padding:10px;
>         padding-top:20px;
>         padding-bottom:20px;
>         font-weight:bold;}
>
> #menu a:hover {
>         border-bottom:1px solid #ff;
>         border-left:1px solid #728d40;
>         border-right:1px solid #e9ffb7;
>         padding-left:9px;
>         padding-right:9px;
>         color:#00;
>         background-color:#FF;
>         background-image:url(../img/menu.jpg);
>         font-weight:bold;
>
> The problem here is the two lines:
> background-image: url('/site_media/img/menu.jpg');
> and
> background-image:url(/site_media/img/menu.jpg);
>
> I know they are different but that’s because I’ve tried so many
> different combinations, like /site_media/img/menu.jpg but also ../img/
> menu.jpg and so forth.
>
> I’m simply run out of ideas but hopefully you can give me an answer on
> what the heg it’s wrong.
> I should say that the base.html correctly load the css file in and all
> other css classes are correct and applied to the tables and div’s.
>
> Thank you
> - Emil
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using mod_python with Lighttpd - advice on the best set up

2008-09-29 Thread Kip Parker

Thanks Frank, that's very interesting. A lack of complaining users is
much to be desired. Have you ever used this set up for multiple sites?
I have about 20 sites running, and there may well be more in the
future.

It would be excellent also to know what you found painful about
mod_python.

All the best,

Kip.

On Sep 29, 6:23 pm, Frantisek Malina <[EMAIL PROTECTED]> wrote:
> I wrote a post for you on my 
> blog:http://vizualbod.com/articles/nginx-fastcgiwsgi-django-deployment
>
> I've tried mod_python and it was a pain.
>
> Frankhttp://vizualbod.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using mod_python with Lighttpd - advice on the best set up

2008-09-29 Thread Kip Parker

Having had a few problems with memory usage on my Django sites, I've
realised a problem with my current set up is that apache is serving
media files as well as doing all the mod_python django stuff.

The recommended solution I keep coming across is to serve media files
from a separate lightweight server, lighttpd seems to be favourite.
There are lots of different ideas though as to how to set it up, I'm
hoping someone will have advice on the best approach.

Possibilities seem to be:
1. passing media requests to lighttpd from apache
2. Passing non-media requests to apache from lighttpd
3. Running a proxy that decides whether to pass requests to lighttpd
or apache.

1. seems to be a dead-end as everything is still going through Apache,
but I'd appreciate any tips or advice from anyone who's tried a set up
like this.

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



Re: Absolute URL vs Relative URL, or ~ ?

2008-09-16 Thread Kip Parker

On Sep 16, 5:42 pm, Dana <[EMAIL PROTECTED]> wrote:
> Kip, don't you mean {{ model.get_image_url }}?
>

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



Re: Absolute URL vs Relative URL, or ~ ?

2008-09-16 Thread Kip Parker

No, nothing to do with HTTP_HOST, that comes from the server.

The point of the sites framework is to differentiate between different
sites, so a * site would be pointless.

If I were you I'd sort out my templates so that instead of
/some/media/location/css/styles.css
you have
{{MEDIA_URL}}/css/styles.css

and instead of
img src="/some/media/location/{{model.image}}"
you have
img src="{{model.image.url}}}"

then you just have to change your MEDIA_URL setting and you're almost
there.

Kip.

On Sep 16, 2:46 pm, est <[EMAIL PROTECTED]> wrote:
> Thank you Kip.
>
> Call me stupid but does site framework have something to do with HTTP
> HOST header?
>
> But in my case the site is for ANYSITE, no matter you visit the site
> by IP, domain, or even customized CNAME you cann visit the site with
> out any problem (Why there isn't a wildcard * in site framework?)
>
> I will looking into TEMPLATE_CONTEXT_PROCESSORS thought, maybe a
> customized filter would help
>
> :-)
>
> On Sep 16, 8:01 pm, Kip Parker <[EMAIL PROTECTED]> wrote:
>
> > > no, it's not THAT simple.
>
> > It really is that simple, honest, but your brain has made it all
> > complicated. Look athttp://docs.djangoproject.com/en/dev/ref/contrib/sites/
> > (sites framework), TEMPLATE_CONTEXT_PROCESSORS setting and
> > RequestContext and the URL dispatcher docs, the answers to your
> > problem and many more besides are in there.
>
> > One tip, most people use MEDIA_URL in their templates a lot.
>
> > Kip.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Absolute URL vs Relative URL, or ~ ?

2008-09-16 Thread Kip Parker


> no, it's not THAT simple.

It really is that simple, honest, but your brain has made it all
complicated. Look at http://docs.djangoproject.com/en/dev/ref/contrib/sites/
(sites framework), TEMPLATE_CONTEXT_PROCESSORS setting and
RequestContext and the URL dispatcher docs, the answers to your
problem and many more besides are in there.

One tip, most people use MEDIA_URL in their templates a lot.

Kip.

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



Re: polymorphism and abstract classes

2008-08-21 Thread Kip Parker

Though I'm not sure what MTI is (Google suggest "Massage Training
Institute", but that can't be right), what you're trying to do seems
well within Django's capabilities.

Generic relations allow you to create foreign keys to any other
object, so you'd have a Generic Foreign Key in your enclosure, then
that could contain any kind of animal (or tree, car or building for
that matter). Have another look here:
http://www.djangoproject.com/documentation/models/generic_relations/,
it's so close to what you're doing that I think you can steal most of
the code you need.

Alll the best,

Kip

On Aug 21, 6:40 am, Shay <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks for the tip, I found Generic Relations and GenericForeignKey
> shortly after I posted this and you confirmed I was looking in the
> right place. :)
>
> It seemed a better idea to make Animalabstractsince I don't want it
> to be able to be instantiated on its own.  ZooEnclosure should only be
> able to accept anything that is a type of Animal but not Animal itself
> since it contains no valuable information in isolation of its
> subclasses. Is there a way of preventing this without making the 
> classabstract?
>
> Also are there any scalability issues with using MTI for this type of
> design (Particularly on large tables)?
>
> With respect to implementing that design as a generic relation (sort
> of based onhttp://www.djangoproject.com/documentation/contenttypes/
> andhttp://www.webmonkey.com/tutorial/Build_a_Microblog_with_Django),
> I'm still a little fuzzy on this, but would the implementation be
> something to the effect of:
>
> class Animal(models.Model):
>     content_type = models.ForeignKey(ContentType)
>     object_id = models.PositiveIntegerField()
>     content_object = generic.GenericForeignKey('content_type',
> 'object_id')
>     ...
>
>     class Meta:
>        abstract= True
>
> class Zebra(Animal):
>     /* Inherits the content_type, object_id, content_object attributes
> from Animal */
>     ...
>
> class Snake(Animal):
>     ...
>
> class ZooEnclosure(models.Model):
>     enclosureName = models.CharField(max_length=50)
>
> And then when ZooEnclosure is instantiated (form or otherwise),
> there's either hook or some signal event which will trigger the
> creation of the instance of Animal.
>
> Am I on the right track or completely off?
>
> Also since ZooEnclosure could contain any type of animal, I can't
> recreate a reverse GenericRelation here for inhabitedBy. Creating a
> GenericRelation to Animal would, I'm guessing, leave me with the same
> problem as before because I set it asabstract(and the same other
> problem of unflattened table hierarchy if I didn't set it asabstract).  Is it 
> possible to specify this in the model?
>
> If these are elementary questions, my apologies, I'm still trying to
> get my head around how all of this hangs together. :)
>
> Thanks,
> Shay
>
> On Aug 20, 5:21 pm, Kip Parker <[EMAIL PROTECTED]> wrote:
>
> > Maybe have a look at generic 
> > relations?http://www.djangoproject.com/documentation/models/generic_relations/
>
> > You could also use multi-table inheritance rather thanabstract
> > classes, then use the parent class Animal as the key in ZooEnclosure.
> >Abstractclasses can't exist on their own, which I expect is why you
> > got the NoneType errors.
>
> > Kip.
>
> > On Aug 20, 3:57 am, Shay <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm rather new to Django, so please bear with me. :P
>
> > > I've been trying to figure out how to implement the following in
> > > models:
>
> > > class: Animal (abstractclass)
> > > ...
>
> > > class: Zebra (extends Animal)
> > > ...
>
> > > class: Snake (extends Animal)
> > > ...
>
> > > class: ZooEnclosure
> > > String enclosureName
> > > Animal inhabitedBy
>
> > > So:
> > > - This is a very trivial example
> > > - Zebra and Snake are subclasses of theabstractclass Animal
> > > - ZooEnclosure is composed of some sort of Animal where I could
> > > feasibly use a Zebra or a Snake
>
> > > Creating a new ZooEnclosure for every animal is not an option because
> > > there're quite a few and could quite possibly result in a hundred
> > > different classes just to change the animal.
>
> > > I've looked at the MTI and ABC type documentation (and Google) but I'm
> > > still not clear on how best to implement this in Django Models.
>
> > > Oh and when I have attempted to leave Animalabstract, it gives me
> > > NoneType errors.
>
> > > I'm not sure what the best way to tackle this problem is, any
> > > suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: polymorphism and abstract classes

2008-08-20 Thread Kip Parker

Maybe have a look at generic relations?
http://www.djangoproject.com/documentation/models/generic_relations/

You could also use multi-table inheritance rather than abstract
classes, then use the parent class Animal as the key in ZooEnclosure.
Abstract classes can't exist on their own, which I expect is why you
got the NoneType errors.

Kip.

On Aug 20, 3:57 am, Shay <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm rather new to Django, so please bear with me. :P
>
> I've been trying to figure out how to implement the following in
> models:
>
> class: Animal (abstract class)
> ...
>
> class: Zebra (extends Animal)
> ...
>
> class: Snake (extends Animal)
> ...
>
> class: ZooEnclosure
> String enclosureName
> Animal inhabitedBy
>
> So:
> - This is a very trivial example
> - Zebra and Snake are subclasses of the abstract class Animal
> - ZooEnclosure is composed of some sort of Animal where I could
> feasibly use a Zebra or a Snake
>
> Creating a new ZooEnclosure for every animal is not an option because
> there're quite a few and could quite possibly result in a hundred
> different classes just to change the animal.
>
> I've looked at the MTI and ABC type documentation (and Google) but I'm
> still not clear on how best to implement this in Django Models.
>
> Oh and when I have attempted to leave Animal abstract, it gives me
> NoneType errors.
>
> I'm not sure what the best way to tackle this problem is, any
> suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IE6/Safari not keeping cookie after closing browser

2008-05-01 Thread Kip Parker

Absolutely, cookies are subject to user settings and behaviour so
unreliable, but as far as default browser behaviour goes I think IE6
keeps cookies forever, Firefox has an expiration limit of 90 days, and
my Safari 3 at least has cookies listed to expire in 2099. So it ought
to work if it's working OK in Firefox, unless your browsers are set up
to delete cookies on close?

Safari 3 has a searchable cookie viewer at Preferences > Security >
Show Cookies, might help you to work out what's going on.

Kip.

On May 1, 4:12 am, Michael <[EMAIL PROTECTED]> wrote:
> I am not sure what version of Safari you are using, but sorry there is no
> way for force users to keep cookies on their computer. IE6 flushes cookies
> on close and Firefox puts a default expire time on them. There are reasons,
> historically, why these browsers do this and unless you change the settings
> on the browser you can't expect people to hold their cookies.
>
> On Mon, Apr 28, 2008 at 4:14 PM, Seth Buntin <[EMAIL PROTECTED]> wrote:
>
> > Firefox works great!  Wish everyone used it!
>
> > When setting a cookie in my application it sets correctly and the site
> > works correctly.  It will allow whoever to the places they need to go
> > and force a login otherwise.  When browsing to another site and back
> > the cookie stays which is good.
>
> > When closing the browser and trying to access the site again the
> > cookie is no longer available in IE6 or Safari 3.  I have tried
> > setting the SESSION_COOKIE_DOMAIN but that doesn't seem to work.
>
> > Any suggestions on what I could do to get a solution to this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Looping....

2008-04-18 Thread Kip Parker

I needed something like this to repeat a part of the template x times,
but I couldn't get this to work, the filter repeatedly returned the
range(0,10) so gave a recursion depth error. I may have set it up
wrong.

I ended up making a repeat tag:

def do_repeat(parser, token):
try:
# Splitting by None == splitting by spaces.
tag_name, arg = token.contents.split(None, 1)
number = int(arg)
except ValueError:
raise template.TemplateSyntaxError, "Repeat tag requires 
exactly one
argument which must be a number"
nodelist = parser.parse(('endrepeat',))
parser.delete_first_token()
return RepeatNode(nodelist, number)

class RepeatNode(template.Node):
def __init__(self, nodelist, number):
self.nodelist = nodelist
self.number = number
def render(self, context):
output = self.nodelist.render(context)
return output*self.number
register.tag('repeat', do_repeat)

but it really feels like it shouldn't be that hard. Maybe I missed the
easy way?


On Apr 15, 7:31 pm, Michael <[EMAIL PROTECTED]> wrote:
> I feel like something like this already exists somewhere, but you can simply
> write a filter that turns a number into a range:
>
> so in your templates you would have:
>
> {% for i in 10|range %}
> ...
> {%endfor%}
>
> and your template filter would simply be:
>
> from django.template.defaultfilters import stringfilter
>
> @stringfilter
> def range(value): return range(int(value))
>
> On Tue, Apr 15, 2008 at 12:07 PM, Kenneth Gonsalves <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On 15-Apr-08, at 9:04 PM, Darryl Ross wrote:
>
> > > Duke wrote:
> > >> They are looping over a list
> > >> I am looking for
> > >> for (i = 0; i < 10; i++) {
> > >>      printf("Hello,  World!);
> > >> }
> > >> link for looping statement
>
> > > I am not aware of any tag that will allow you to do that, out of
> > > the box. You have two options, the first is to create a custom
> > > template tag that do what you want[1]. This shouldn't really be
> > > terribly difficult to do.
>
> > > The second option would be to just pass in a variable into the
> > > context with a list containing the number of items of the number of
> > > times you want to loop. Using generic views, this could be done in
> > > your urls.py like:
>
> > > ...
> > >  ('^$', 'direct_to_template',
> > >         { 'template_name': 'homepage.html',
> > >           'extra_context': {'looper': range(10) }})
> > > ...
>
> > > Then you can use the standard {% for %} tag:
>
> > > {% for i in looper %}
> > >   {{i}}
> > > {% endfor %}
>
> > > [1]http://www.djangoproject.com/documentation/templates_python/
> > > #extending-the-template-system
>
> > where is the use case for this? I cannot conceive of any situation
> > where one would want to loop over an arbitrary number.
>
> > --
>
> > regards
> > kg
> >http://lawgon.livejournal.com
> >http://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: edit_inline and models with FileField(core=True)

2008-04-03 Thread Kip Parker

Thanks, that's the one! I'm a bit wary of using the branches for
production sites, do you have any experience of using the newforms-
admin branch?

On Apr 3, 1:51 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 2, 2008 at 3:18 PM, Kip Parker <[EMAIL PROTECTED]> wrote:
>
> > This model is edited inline with the ImageField being the only one
> > with core=True.
>
> > class Image(models.Model):
> >        image = models.ImageField(upload_to="images", core=True)
> >        caption = models.CharField(blank=True, max_length=250)
> >        artist = models.ForeignKey(Artist, edit_inline=models.TABULAR)
>
> > But it doesn't work well in the admin, as if you save the associated
> > Artist entry after editing it without re-entering the image files,
> > they are deleted, I suppose because the "core" fields (the image
> > uploads) are treated as being empty, rather than unchanged.
>
> > Am I doing something wrong or is there a workaround for this?
>
> Sounds like:
>
> http://code.djangoproject.com/ticket/2413
>
> The recommended workaround is to use newforms-admin, where core is no more.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



edit_inline and models with FileField(core=True)

2008-04-02 Thread Kip Parker

This model is edited inline with the ImageField being the only one
with core=True.

class Image(models.Model):
image = models.ImageField(upload_to="images", core=True)
caption = models.CharField(blank=True, max_length=250)
artist = models.ForeignKey(Artist, edit_inline=models.TABULAR)

But it doesn't work well in the admin, as if you save the associated
Artist entry after editing it without re-entering the image files,
they are deleted, I suppose because the "core" fields (the image
uploads) are treated as being empty, rather than unchanged.

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