Re: Django 1.2 Dropped Sessions when single view contains registration and login authentication

2011-04-26 Thread Ray Cote
- Original Message -
> From: "benp" 
> To: "Django users" 
> Sent: Monday, April 25, 2011 8:54:15 AM
> Subject: Django 1.2 Dropped Sessions when single view contains registration 
> and login authentication
> I've seen other Django developers have the same exact issue with
> registering and logging in a user in the same view. There hasn't been
> a satisfactory answer yet, though I've seen it suggested that it could
> be related to MySQL timeouts or threading issues.
I'll just add my voice as someone else also fighting this issue to no avail.

In our situation, we have two (originally identical) deployments of a custom 
Django app. 
One never has this problem. Users of the second one frequently report this 
error. 
And yes, difficult to reproduce in our test environments. 
--Ray

-- 
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: Proper approach to updating model object with 100 attributes.

2010-06-30 Thread Ray Cote
Thanks for everybody's comments. 
I ended up using the setattr method and, since I always know the data I have is 
a subset of the data in the model, that works wonderfully. 

--Ray


- Original Message -
From: "euan.godd...@googlemail.com" 
To: "Django users" 
Sent: Wednesday, June 30, 2010 10:01:11 AM GMT -05:00 US/Canada Eastern
Subject: Re: Proper approach to updating model object with 100 attributes.

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



Re: Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Ray Cote
Hi Tim: 

Thanks for the pointers. 
I think the setattr is probably safest way to deal with the Django models. 

--Ray

- Original Message -
From: "Tim Chase" 
To: django-users@googlegroups.com
Cc: "Ray Cote" 
Sent: Tuesday, June 29, 2010 2:03:05 PM GMT -05:00 US/Canada Eastern
Subject: Re: Proper approach to updating model object with 100 attributes.

On 06/29/2010 12:01 PM, Ray Cote wrote:
> Hi List:
>
> I have a Django model with over 100 fields in it that is loaded from a data 
> feed.
> Each row in the model has a unique field, let's call it item_id.
> When loading new data, I'm first checking to see if item_id is in the table,
> if it is, I want to update it with the new data from the new 100 fields.
>
> To date, I've done things like:
>
> obj = Model.objects.get(item_id = item_id_from_field)
>
> and then.
> obj.field1 = new_field1
> etc.
>
> However, for 100 fields, I'd like to find something a bit cleaner than 
> listing 100 fieldnames.
> The data for the new 100 fields is in a nice dictionary.
>
> When I create a new item, I'm able to do this:
>obj = MyModel(**dictionary_of_field_values)
>
> Is there something similar I can do with my obj once the data is retrieved?

Well, you could do something like

   for name, value in dictionary_of_field_values.items():
 setattr(obj, name, value)

or possibly even just

   obj.__dict__.update(dictionary_of_field_values)

(I'm not sure how this interacts with Django's meta-class 
yumminess, but it works for regular Python classes)

-tkc




-- 
Ray Cote, President
Appropriate Solutions, Inc.
We Build Software
603.924.6079

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



Proper approach to updating model object with 100 attributes.

2010-06-29 Thread Ray Cote
Hi List:

I have a Django model with over 100 fields in it that is loaded from a data 
feed. 
Each row in the model has a unique field, let's call it item_id.
When loading new data, I'm first checking to see if item_id is in the table, 
if it is, I want to update it with the new data from the new 100 fields. 

To date, I've done things like:

obj = Model.objects.get(item_id = item_id_from_field)

and then.
obj.field1 = new_field1
etc. 

However, for 100 fields, I'd like to find something a bit cleaner than listing 
100 fieldnames. 
The data for the new 100 fields is in a nice dictionary. 

When I create a new item, I'm able to do this:
  obj = MyModel(**dictionary_of_field_values)

Is there something similar I can do with my obj once the data is retrieved? 

Thanks
--Ray

-- 
Ray Cote, President
Appropriate Solutions, Inc.
We Build Software
603.924.6079

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



Re: Hosting for Django sites

2010-04-03 Thread Ray Cote
We have experience with Webfaction, Slicehost, and Linode. 
Webfaction has excellent Django support, ability to generate basic app layouts, 
etc. 
Shell access (which is always important to us). 

Slicehost and Linode are excellent Django-serving platforms, but then again 
they are excellent general serving platforms. You're on your own with 
install/configuration. But you get more fine-tuned control than with 
WebFaction. 

--Ray

- Original Message -
From: "django_jedi" 
To: "Django users" 
Sent: Saturday, April 3, 2010 10:39:41 AM GMT -05:00 US/Canada Eastern
Subject: Hosting for Django sites

Hi Folks,

I'm wondering what people would recommend for hosting Django sites?
I've read the blog posts; I'm wondering what the latest word on the
street would be.  We're talking about hosting multiple Django/Satchmo
installs, possibly w/dedicated/managed servers.

Among the leading contenders so far:

- Webfaction
- Media Temple
- Rackspace Cloud/Slicehost

Thoughts?

TIA.

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


-- 
Ray Cote, President
Appropriate Solutions, Inc.
We Build Software
603.924.6079

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



Re: WebFaction memories

2008-05-29 Thread Ray Cote

At 12:38 PM -0400 5/29/08, didier rano wrote:
>Hi all,
>
>I am trying to evaluate to migrate from Site5 hosting to WebFaction. 
>I have some problems with Site5 to compile some third-parties tools 
>like scipy (subversion) and dependances.
>
>But I don't have ideas about memories size with WebFaction. In 
>shared hosting, it is possible to use from 86 Mb to 256 Mb memories 
>(without apache process and database process). Then, these memories 
>are dedicated to python processes and others processes.
>
>I don't have ideas if 86 Mb is enough for a small web site (between 
>10 to 50 users by day). Does someone use WebFaction with Django ? 
>Which is the memory print of Django in this case ?
>
>Thanks
>Didier Rano

Hi Didier:
I don't have my immediate WebFaction numbers to hand, but I do know 
I'm running one small Django web site on their Shared 1 hosting 
(probably 4-5 times the number of visitors you are estimating) and 
I'm running a number of Django web sites on WebFaction's Shared 2 
hosting (hundreds to thousands of visits per day).

The biggest tricks with WebFaction and memory are:
a: Don't run for long periods of time in Django Debug mode.
b: The Apache 'restart' command they provide you is actually a reload 
command and will not reduce your memory footprint. If you've been 
running in Debug mode, you'll want to switch out and then do a stop 
followed by a start. Then your memory will be nicely reduced.

Hope this helps.
--Ray

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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: Getting file selected for upload to survive validation.

2008-03-04 Thread Ray Cote

At 1:31 AM +1100 3/5/08, Malcolm Tredinnick wrote:
>On Tue, 2008-03-04 at 08:58 -0500, Ray Cote wrote:
>>  I have file uploads working using newforms.
>>
>>  However, if I run into validation errors on the form (say a mandatory
>>  field is not filled), then when the form re-displays for the user,
>>  the file they previously selected is no longer selected.
>
>This is normal browser behaviour: they don't redisplay any file
>specified in file upload widgets to avoid phishing-style attacks. So
>Django doesn't bother sending it through.
>
>If you search in the archives, I seem to remember some people came up
>with ways to pass the filename back in any case for manual display if
>you want that, but it still won't be submitted as part of them form.
>
>Regards,
>Malcolm

Thanks for the pointer (and the note that this is expected behavior).
--Ray

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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
-~--~~~~--~~--~--~---



Getting file selected for upload to survive validation.

2008-03-04 Thread Ray Cote

I have file uploads working using newforms.

However, if I run into validation errors on the form (say a mandatory 
field is not filled), then when the form re-displays for the user, 
the file they previously selected is no longer selected.

I've been reading through a variety of file upload suggestions, but 
I've not found anything specifically targeting this problem.
Any suggestions as to what I'm not doing is appreciated.

Here's what my (simplified) model/view/template looks like:

Model:
class Note(models.Model):
 category = models.ForeignKey(Category)
 title = models.CharField(max_length=80, unique=False)
 article = models.FileField(upload_to='articles/%Y_%m/', 
null=True, blank=True)

View:
def add(request):
 NoteFormClass = forms.models.form_for_model(Note)

 if request.POST:
 form = NoteFormClass(request.POST, request.FILES)
 if form.is_valid():
 form.save()
 return HttpResponseRedirect('/')
 else:
 form = NoteFormClass()

 response = render_to_response('notes/add.html',
 {
  'form': form,
 })

 return response


Template:




 
{{form.category.label}}*:{{form.category.errors}}{{cat_combo|safe}}


 
{{form.title.label}}*:{{form.title.errors}}{{form.title}}


 Article 
File:{{form.article.errors}}{{form.article}}{{form.article_file}}







-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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: Integrating Django with existing site.

2007-09-06 Thread Ray Cote

At 4:22 PM + 9/5/07, Steve  Potter wrote:
>  >
>>  Try coding each module as a Django template tag.
>>  Then, create a template that returns an html fragment rather than a
>>  full html page.
>>  Associate each rendered template with a specific URL.
>>  Perhaps something like:
>>mysite.com/components/module1.html
>>  In Joomla, create a plug-in that simply calls the component.
>>
>>  As you migrate away from Joomla to Django, simply use the template
>>  tag directly in your Django template so you don't need to make the
>>  extra call.
>>  --Ray
>
>Ray,
>
>That sounds like it work work.  The only thing I am having a hard time
>understanding is how the request is made from the php script to
>Django.  Would it be best to make the request to the localhost using
>something like CURL?
>
>Thanks,
>
>Steve

Hi Steve:
Doing an HTTP call is indeed the way to go.
Afraid I don't know the PHP library well enough to answer that definitively.
A quick Google found the following reference calling without CURL.


I'd stay away from Curl simply because I would not want to launch a 
new app each time the remote query needs to be run.  A pure PHP 
solution would be preferable. (also less worry about the security of 
passing a command-line parameter to the curl call).
--Ray


-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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: Integrating Django with existing site.

2007-09-05 Thread Ray Cote

At 4:59 AM + 9/5/07, Steve  Potter wrote:
>... you have many different modules, each of them being a separate 
>application that
>functions independently of the others, but they are all displayed on
>one page.
>I want to be able to convert these modules one by one without having
>to replace the underlying Joomla system until I have finished
>converting all of the modules.

Try coding each module as a Django template tag.
Then, create a template that returns an html fragment rather than a 
full html page.
Associate each rendered template with a specific URL.
Perhaps something like:
  mysite.com/components/module1.html
In Joomla, create a plug-in that simply calls the component.

As you migrate away from Joomla to Django, simply use the template 
tag directly in your Django template so you don't need to make the 
extra call.
--Ray

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
http://www.AppropriateSolutions.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: Newforms: adding a date picker

2007-04-16 Thread Ray Cote

Thanks.
In reading through the custom code referenced in 
the previous email, I saw how to add custom class 
via the attributes. Agree, that's probably all I 
need at this point.
--Ray

At 9:23 PM +0200 4/15/07, Honza Král wrote:
>creating a widget might be an overkill in this case
>
>adding a custom class to the input field via the attrs parameter
>should cover it nicely. i use this approach without the need for a
>special widget.
>
>On 4/15/07, Ray Cote <[EMAIL PROTECTED]> wrote:
>>
>>  Thanks, that is very helpful.
>>
>>  At 11:45 AM -0600 4/14/07, Brian Rosner wrote:
>>  >You will want to check out how to create widgets.  Here might be an
>>  >example you are looking for as well as a an example in general.
>>  >
>>  
>> >http://code.djangoproject.com/browser/django/branches/newforms-admin/django/contrib/admin/widgets.py
>>  >
>>  >On
>>  >
>>  >2007-04-14 11:32:53 -0600, Ray Cote 
>><[EMAIL PROTECTED]> said:
>>  >
>>  >>
>>  >>
>>  >>  Hello:
>>  >>
>>  >>  I'm trying to figure out the approved Django way to add a Javascript
>>  >>  date picker (pop-up calendar) to a field while using newforms.
>>  >>
>>  >>  One way I see people adding date pickers is to give the field a
>>  >>  specific class which the Javascript then attaches to during onload of
>>  >>  the page. However, I don't see a way to add a class to a field with
>>  >>  newforms.
>>  >>
>>  >>  Any help appreciated as I'm fairly new to both Django and JavaScript.
>>  >>  --Ray
>>  >>
>>  >>
>>  >>
>>  >
>>  >
>>  >
>>  >
>>
>>  --
>>
>>  Raymond Cote
>>  Appropriate Solutions, Inc.
>>  PO Box 458 ~ Peterborough, NH 03458-0458
>>  Phone: 603.924.6079 ~ Fax: 603.924.8668
>>  rgacote(at)AppropriateSolutions.com
>>  www.AppropriateSolutions.com
>>
>>  >
>>
>
>
>--
>Honza Kr?l
>E-Mail: [EMAIL PROTECTED]
>ICQ#:   107471613
>Phone:  +420 606 678585
>
>

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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: Newforms: adding a date picker

2007-04-15 Thread Ray Cote

Thanks, that is very helpful.

At 11:45 AM -0600 4/14/07, Brian Rosner wrote:
>You will want to check out how to create widgets.  Here might be an
>example you are looking for as well as a an example in general.
>
>http://code.djangoproject.com/browser/django/branches/newforms-admin/django/contrib/admin/widgets.py
>
>On
>
>2007-04-14 11:32:53 -0600, Ray Cote <[EMAIL PROTECTED]> said:
>
>>
>>
>>  Hello:
>>
>>  I'm trying to figure out the approved Django way to add a Javascript
>>  date picker (pop-up calendar) to a field while using newforms.
>>
>>  One way I see people adding date pickers is to give the field a
>>  specific class which the Javascript then attaches to during onload of
>>  the page. However, I don't see a way to add a class to a field with
>>  newforms.
>>
>>  Any help appreciated as I'm fairly new to both Django and JavaScript.
>>  --Ray
>>
>>
>>
>
>
>
>

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
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
-~--~~~~--~~--~--~---



Newforms: adding a date picker

2007-04-14 Thread Ray Cote


Hello:

I'm trying to figure out the approved Django way to add a Javascript 
date picker (pop-up calendar) to a field while using newforms.

One way I see people adding date pickers is to give the field a 
specific class which the Javascript then attaches to during onload of 
the page. However, I don't see a way to add a class to a field with 
newforms.

Any help appreciated as I'm fairly new to both Django and JavaScript.
--Ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
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
-~--~~~~--~~--~--~---