Re: Help with a Caching Strategy

2007-07-06 Thread Clint Ecker

Thanks Jeremy,
   I'll try to expand a bit, and give some insight into a solution I
crafted this morning after reading your message (it flipped a switch
in my brain)

> How's the data updated?  Need to know how to get the update info to
> the cache.  :)

The data is updated by a crontab job that  runs a python script.  This
script pulls down RSS feeds, scrapes web sites, etc., mines out data
into my format, adds rows to the database using the Django ORM, etc.
every 15 minutes.

> As a hack, you could have a stub view that just decides if it's the
> current month or not, then dispatch either of 2 real views, each with
> its own cache_page.

This is how I implemented it this morning. I think there might a few
edge cases that aren't being handled but what I did is I send everyone
to:

month_detail(...)

which then decides whether or not they are requesting this month or a
previous month, and they're forwarded to the following views,
respectively:

this_month_detail(...) and previous_month_detail(...) which both do a
call to real_month_detail(...) which has all the shared code.

When I set up caching I then just cache this_month_detail for 15
minutes and previous_month_detail for 10 years or so.

> For an actual solution, more detail's needed.
>
> How many other parameters from the request come into play?

Pretty much every parameter that's taken into account comes through my
function arguments, (year, month, entity).  That is, the output of the
view depends wholly on the unique combinations of those 3 items.

> If a small number of permutations, you could bake all the data (that
> is, pull requests into a flat file to be served cheaply later, in
> which "invalidating cache" is deleting a file).

I'd say that there are (3 years)*(12 months)*(65 entities)
permutations (~2300) and that obviously grows every month and as we
add more entities, which happens at the rate of approximately 1-2 a
month.

Do you mean by "baking the requests", caching the output to a file on
disk/db or by pickling the request object (pretty sure you don't mean
this).  If the first is what you mean, how does this differ from using
file-based caching in Django?

> If you decide to use the low-level cache due to too many permutations,
> this is the general approach:
>
> expensive_thing = cache.get(some_key)
> if not expensive_thing:
> expensive_thing = expensive_process
>cache.set(some_key, expensive_thing, cache_timeout)
>
> You can, of course, do that as much as you want.

> I have some views that do two or 3 phases, in which I cache a whole
> resultset, then munge or whittle it depending on parameters and cache
> that bit with a more fine-grained key.

I may look into this a bit more to target my intensive bits of that
particular view.


In another vein,  how does everyone deal with invalidating the cache
and the resulting penalty the next client to request that view
receives? These old views can take near 30 seconds to regenerate from
a non-cached state. Say for whatever reason, a month from 5 months ago
recieves a new bit of data and I kill the cache for it.  How do you
regenerate that view?

Is there a way to do it programatically from within Django?

i.e. when I add a new bit of data to an old month in my cron script
and invalidate that month's cache, can I trigger what I might call an
automated rebuild of that template?

I would prefer that the penalty take place during my cron'd script's
execution rather than the user have a perceived delay the next time
that particular view is requested.

Also, thanks a bunch, Jeremy!
Clint

-- 
Clint Ecker
Sr. Web Developer - Stone Ward Chicago
p: 312.464.1443
c: 312.863.9323
---
twitter: clint
skype: clintology
AIM: idiosyncrasyFG
Gtalk: [EMAIL PROTECTED]

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



Help with a Caching Strategy

2007-07-05 Thread Clint Ecker

In one of the applications I maintain, I use a view that takes the
following inputs, crunches a lot of data from over the course of a
month, and spits out a view:

def month_detail(request, year, month, check=True):

This could be the current month, the previous month, a month 3 years
ago, etc. The information pertaining to the current month is updated
every 15 minutes (if there's been new data in the past 15 minutes), so
I would like to make that information only cache for 15 minutes at
most.  It would be super cool to invalidate the cache (or not) at the
moment I update the data, but it's not mission critical.  For someone
to visit the site every 15 minutes and get new data for the current
month is just fine.

However, the data for previous month's is done and set in stone pretty
much at the beginning of the next month.  Data for the previous month
might roll in for a few days into the new month, but in general, once
we roll into the new month, it's a done deal.  I would like to cache
those pages forever, or maybe invalidate their caches when the rare
bit comes in after the month is over.

Long story short, my current approaches haven't yielded any fruit. I'm
not sure that I can cache one view two different ways by using the
cache_page function.  Perhaps I need to dig a little deeper into the
caching mechanisms?

How would people with more experience with caching+Django approach
this situation?

Thanks in advance,
Clint

-- 
Clint Ecker
Sr. Web Developer - Stone Ward Chicago
p: 312.464.1443
c: 312.863.9323
---
twitter: clint
skype: clintology
AIM: idiosyncrasyFG
Gtalk: [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Creating HTML emails

2007-02-14 Thread Clint Ecker

And please note, this was probably nabbed from some example online and
modified to suit my needs, please don't attribute it to me, it's only
as an example for you ;)

Clint

On 2/8/07, Tipan <[EMAIL PROTECTED]> wrote:
>
> I've been able to create Plain text emails to send to users with an
> authentication link which work well, however I'd like to improve the
> look of these by outputting in HTML with a logo. If I use the
> send_mail function it simply incorporates the HTML in the plain text.
>
> Can anyone point me in the right direction with the process required
> for formatting and sending my emails from Django in HTML?
>
> Thanks
>
>
> >
>


-- 
Clint Ecker / Sr. Web Dev / STONE WARD
Boston / [ Chicago ] / Little Rock
312.464.1443, ext. 111
http://www.stoneward.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: Creating HTML emails

2007-02-14 Thread Clint Ecker

Forgot to include my send_mail function:

http://dpaste.com/hold/5682/

On 2/8/07, Tipan <[EMAIL PROTECTED]> wrote:
>
> I've been able to create Plain text emails to send to users with an
> authentication link which work well, however I'd like to improve the
> look of these by outputting in HTML with a logo. If I use the
> send_mail function it simply incorporates the HTML in the plain text.
>
> Can anyone point me in the right direction with the process required
> for formatting and sending my emails from Django in HTML?
>
> Thanks
>
>
> >
>


-- 
Clint Ecker / Sr. Web Dev / STONE WARD
Boston / [ Chicago ] / Little Rock
312.464.1443, ext. 111
http://www.stoneward.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: Creating HTML emails

2007-02-14 Thread Clint Ecker

Here is a bit of code from a project I did, let me know if I should
explain anything:

http://dpaste.com/hold/5681/

Seems to work just fine for me!

On 2/8/07, Tipan <[EMAIL PROTECTED]> wrote:
>
> I've been able to create Plain text emails to send to users with an
> authentication link which work well, however I'd like to improve the
> look of these by outputting in HTML with a logo. If I use the
> send_mail function it simply incorporates the HTML in the plain text.
>
> Can anyone point me in the right direction with the process required
> for formatting and sending my emails from Django in HTML?
>
> Thanks
>
>
> >
>

-- 
Clint Ecker / Sr. Web Dev / STONE WARD
Boston / [ Chicago ] / Little Rock
312.464.1443, ext. 111
http://www.stoneward.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
-~--~~~~--~~--~--~---



Exercise: How would you design these models

2006-10-20 Thread Clint Ecker

Hey guys, I'm developing some models for a project and I'm running
into some issues and I'm wondering if perhaps I'm way off base with
how I'm approaching the design.  Here's how things should work, in
words:

A UserProfile can have many ImageObjects associated to it
A UserProfile can have many VideoObjects associated to it
A UserProfile can have many URLObjects associated to it
An ImageObject can belong to a single UserProfile
A VideoObject can belong to a single UserProfile
A URLObject can belong to a single UserProfile

and for the kicker...

A UserProfile can have a single ImageObject associated with it for use
as a profile image.

*** Oh, and I have my profile models in one app and my content models
in another app.

This is how I had it (obviously simplified) and I was running into
some issues, plus I felt it didn't specifically adhere to the
situation above as an *Object could belong to multiple users:

---[ myproj.profile.models ]---
from myproj.content.models import ImageObject, VideoObject, URLObject

class UserProfile(models.Model):
  profile_image = models.ForeignKey(ImageObject, related_name='profile_image')
  images = models.ManyToManyField(ImageObject, related_name='images')
  videos = models.ManyToManyField(VideoObject)
  urls = models.ManyToManyField(URLObject)
---

---[ myproj.content.models ]---
class ImageObject(models.Model):
  name = models.CharField()
  uri = models.ImageField()

class VideoObject(models.Model):
  name = models.CharField()
  uri = models.FileField()

class URLObject(models.Model):
  name = models.CharField()
  uri = models.URLField()
---

So then I changed how I did it to this model, to try and enforce the
"a profile can have many images and a picture can only have 1
UserProfile" restraint above:

---[ myproj.profile.models ]---
from myproj.myapp.models import ImageObject

class UserProfile(models.Model):
  profile_image = models.ForeignKey(ImageObject, related_name='profile_image')


---[ myproj.content.models ]---
class ImageObject(models.Model):
  name = models.CharField()
  uri = models.ImageField()
  user = models.ForeignKey(UserProfile)

class VideoObject(models.Model):
  name = models.CharField()
  uri = models.FileField()
  user = models.ForeignKey(UserProfile)

class URLObject(models.Model):
  name = models.CharField()
  uri = models.URLField()
  user = models.ForeignKey(UserProfile)


However, at this point I'm getting errors in th dev-server and they
models disappear from the administrative interface:

---
Validating models...
stoneward_intranet.profile: cannot import name UserProfile
stoneward_intranet.content: cannot import name ImageObject
2 errors found.
---

I get the same errors from the shell and I'm wondering if this has
something to do with each model importing the other and it running
into some sort of loop?  Am I taking the fundamentally wrong approach
or do I need to work around this behavior?

thanks!

Clint Ecker

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



Re: models: There has to be a better way.

2006-09-23 Thread Clint Ecker

Please do a  search for 'schema-evolution' on the dev list.  It's been
discussed ad nauseum and there was a project with Google's SoC to
address the issue.  The code, as far as i know, is complete and
waiting in a seperate branch for testing before being merged into the
main trunk.

Clint


On 9/23/06, Tom Smith <[EMAIL PROTECTED]> wrote:
> At the moment I am learning django and so far, almost everything about it
> feels fantastic. Except for this...
>
> A lot of the time I need to change the database model as I go... I have
> millions of records and have problems dumping all the data out re-sync-ing
> the database and then importing the data again. My problems are partly
> because I am using MAMP and for the life of me can't work out how to give
> myself full privileges when using mysqladmin.. another part is because it is
> quite easy to get in a muddle because I do it so often.
>
> You could say, "well, design your databases first", but I just don't work
> like that...
>
> Most of the time I just need to add an extra field (which shouldn't be too
> complicated should it?)
>
> Sometimes I'd like to change something about the field (adding an index to
> it for example) which I almost could do "under" the django models without it
> knowing about.
>
> Are there any approaches or tools I should know about when dealing with what
> is a common problem for me of regularly evolving models.py and lots of data?
>
> thanks
>
> tom
>
>
>
>
>
>  >
>


-- 
Clint Ecker | STONE WARD
440 N. Wells, Suite 750, Chicago, IL 60610
Boston | [ Chicago ] | Little Rock
www.stoneward.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
-~--~~~~--~~--~--~---



Re: Field options validation only occur in admin interface?

2006-05-04 Thread Clint Ecker
On 5/4/06, Kilian CAVALOTTI <[EMAIL PROTECTED]> wrote:
Hi all,I thought model properties validation would occur at objectcreation/modification, but it seems that it's not the case.(To be complete, I'd like to precise that I use the current svn trunk, and
that I ran a 'manage.py reset project' between each model modification)Check these threads out.  The short answer is, "it's coming." :)

Making models validation aware:
http://groups.google.com/group/django-developers/browse_thread/thread/4bc65cf676c93846/5d7db0f7a5f85006?lnk=st=validation+aware+models=5#5d7db0f7a5f85006

Proposal: Validation aware models:
http://groups.google.com/group/django-developers/browse_thread/thread/b0bd008c85cf8fa0/fd61d54ba8640eb7?lnk=st=validation+aware+models=4#fd61d54ba8640eb7

Validaiton aware models: first stab:
http://groups.google.com/group/django-developers/browse_thread/thread/9e16f6650d541175/bcf3f32e2c597a5d?lnk=st=validation+aware+models=2#bcf3f32e2c597a5d

Validation aware models revisited:
http://groups.google.com/group/django-developers/browse_thread/thread/cd0c58f0dce474fe/4af412291fd4ac37?lnk=st=validation+aware+models=1#4af412291fd4ac37
-- Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: get parameters in template

2006-05-04 Thread Clint Ecker
On 5/4/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
That wouldn't work, because you pass the argument in the URLconf, andthe URLconf doesn't have access to request objects. The solution hereis either the global TEMPLATE_CONTEXT_PROCESSORS setting or the"context_processors" keyword argument to the specific view.
AdrianGood point! I've never used them (generic views) in a project yet, so I was bound to hit some sort snag with my solution ;)-- Clint Ecker
[EMAIL PROTECTED]http://phaedo.cx

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


Re: get parameters in template

2006-05-04 Thread Clint Ecker
Oops, just now noticed you were specifically talking about Generic Views! I apologize! :DOn 5/4/06, Clint Ecker <
[EMAIL PROTECTED]> wrote:You could pass the "
request.GET" or "request.POST" variable into the template context and then access it as follows.  I'm making the assumption that you'd pass it in as 'request':The page is: {{ 
request.page }} and the test is {{ request.test }}.http://www.djangoproject.com/documentation/request_response/#attributes

On 5/4/06, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
Hi,Is there a way (I bet there is) to find GET parameters (?page=3=6)
inside the template of a generic view ?Z.-- Clint Ecker
[EMAIL PROTECTED]http://phaedo.cx

-- Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


[OT]: Video of Jacob's talk at Google

2006-05-03 Thread Clint Ecker
Just noticed this on Google's engEDU!http://video.google.com/videoplay?docid=-70449010942275062=type%3Agoogle+engEDU=true
Here's a list of all the stuff which is all very interesting!http://video.google.com/videosearch?q=type%3Agoogle+engEDU=1=0=1
-- Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: MR: Revision 2745 and up -- Syncdb breakage, and why

2006-04-26 Thread Clint Ecker
On 4/25/06, Ken Kennedy <[EMAIL PROTECTED]> wrote:
I'd say put 'em there!Done---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: MR: Revision 2745 and up -- Syncdb breakage, and why

2006-04-26 Thread Clint Ecker
There was already a bug report on this, and a simple patch:http://code.djangoproject.com/ticket/1677On 4/26/06, 
Rudolph <[EMAIL PROTECTED]> wrote:
This revision also causes another minor bug. When running syncdb ittells youAdding permission ''for every permission. This is caused by the __repr__ and __str__changes. Shall I file a bug report?
Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: MR: Revision 2745 and up -- Syncdb breakage, and why

2006-04-25 Thread Clint Ecker
On 4/25/06, Rudolph <[EMAIL PROTECTED]> wrote:
The above fixes the issue, but to completely remove all uppercasednames also do:BEGIN;UPDATE django_content_type set name='group' where model='group';UPDATE django_content_type set name='user' where model='user';
COMMIT;Thanks for putting those together, now I'm trying to figured out where the best place to put this information is?

Is this a good place? http://code.djangoproject.com/wiki/RemovingTheMagic#Databasechangesyoullneedtomake

Or does that only deal with changes from 0.9.1 to 0.91MR? ---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


MR: Revision 2745 and up -- Syncdb breakage, and why

2006-04-25 Thread Clint Ecker
After updating to revision 2747 this morning I tried installing a new app in my project and found Django trying to reinstall permissions.  After a bit of digging I found out that my "names" in auth_permissions had uppercase chars in them instead of lowercase (ie. 'Can add Group' instead of 'Can add group').  This caused syncdb to try and re-add the permissions and die because a restraint placed on this table stops it from duplicating that information.
Anyway, I found out that the cause of this was a slight change made in revision 2745 ( http://code.djangoproject.com/changeset/2745 ), where the verbose names of the Users and Groups were lowercased.  
Purpose of this email: if you're running into syncdb breakage after updating to a 2745+ revision of MR, just go into auth_permission table and change the 'Can * Group' and 'Can * User' stuff to 'Can * group' and 'Can * user' respectively.
 Hope this helps out anyone who runs into this!---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


SQL Debugging in MR

2006-04-25 Thread Clint Ecker
I poked through the mailing list here and never saw a solution for digging through the SQL query stack in MR as you were able to do in old-world-django, ala:
http://www.djangoproject.com/documentation/faq/#how-can-i-see-the-raw-sql-queries-django-is-runningI did some grepping and looked through the /core/db/ stuff but didn't see anything.  pbx in #django pointed me to this solution:
>> from django.db import connection; print connection.queriesThis returns an array of dicts for all the queries made so far.  They include keys for 'time' and 'sql'.  Hope this helps people who've been looking for this information.  pbx will be updating the MR docs with that info soon!
 ---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Slow initial startup on Django project

2006-04-21 Thread Clint Ecker
Hey everyone, I'm not considering this a "problem" so much as it's annoying.  I moved a project I'd been running locally under mod_python to a shared server (on Dreamhost) using fcgi.  I've noticed that when I first visit the site, it takes somewhere between 1-10 seconds to actually load the index of my app.  I know the HTTP server is responding quickly because, well, I have it htaccess password protected and that pops up immediately, and I have a ton of other sites on this same server with no slow startup issues.
Any ideas about what causes this "slow startup" phenomena? Is it just inherent to fcgi or is there something wrong with how I'm doing business.  Thanks in advance! ---Clint Ecker
[EMAIL PROTECTED]http://phaedo.cx

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


Re: ImageField/FileField in M/R

2006-04-20 Thread Clint Ecker
This was discussed 8 months ago.  This is the ticket: http://code.djangoproject.com/ticket/369.  Feel free to add anything you think relevant.
On 4/20/06, Denis <[EMAIL PROTECTED]> wrote:
If so, then it (the file) shouldn't be deleted when you delete()the object? Also, M/R branch seems has no methods like_pre_save/_post_save,instead you can subclass save/delete methods. There are some references
in db.models.signals, dont know how to use them thoughClint Ecker написав:> This is correct.  I believe the general consensus is that the developer> should take care of file destruction on their own.  Perhaps in a _pre_save
> method?>> Clint>> On 4/20/06, Denis <[EMAIL PROTECTED]> wrote:> >> >> > Hi> >> > It looks like old files aren't being removed after object change.
> > That is, if i change the object like the 1 below and upload new file> > via admin interface, old file remains in the directory, though nothing> > refers to it :-/> >> > class Picture(
models.Model):> > fullsize = models.ImageField(upload_to='%Y/%m/%d')> > ...> >> >> > >> >>>> --> ---> Clint Ecker
> [EMAIL PROTECTED]> http://phaedo.cx>---Clint Ecker[EMAIL PROTECTED]
http://phaedo.cx
--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---



Re: ImageField/FileField in M/R

2006-04-20 Thread Clint Ecker
This is correct.  I believe the general consensus is that the developer should take care of file destruction on their own.  Perhaps in a _pre_save method?Clint On 4/20/06, 

Denis <[EMAIL PROTECTED]> wrote:

HiIt looks like old files aren't being removed after object change.That is, if i change the object like the 1 below and upload new filevia admin interface, old file remains in the directory, though nothing
refers to it :-/class Picture(models.Model):fullsize = models.ImageField(upload_to='%Y/%m/%d')...-- ---Clint Ecker[EMAIL PROTECTED]
http://phaedo.cx


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


Re: Ecommerce & Django

2006-04-14 Thread Clint Ecker
Here's basically what I have... the thing with t-shirts is that you can have a base product, the design... and it's got several subproducts  Medium Black shirts, Large black shirts, Meidum blue.  And they've all got different prices attributed to them, like an XXL shirt would be a little more expensive than a XL shirt.  For shipping and such, each shirt (or item) needs a weight associated with it.  Since I used shirts and they typically come in different, generic, reusable types like Jerseys 50/50 Heavyweight, I abstracted that away... anyway, here's a very basic idea of what my model system looks like, its what I came up with doing this site in PHP for a few years and I cleaned it up a lot for Django, it works suprisingly well and is pretty generic, although I can see how it might need some extra stuff depending on what's being sold.
Item-- short_name(slug)-- long_name(char)-- active(bool)Sub_Item-- Item(foriegn)-- Color(foriegn)-- Size (foriegn)-- Type (foriegn) # what kind of shirt is it?-- unit_price (float)
-- num_in_stock (int)Color-- name (char)  # something like "Black"-- html_equivilant (char)  # something like #00Size -- short_name # like "S"-- long_name # like "Small"
Type-- name # like "Jerseys 100% Cotton Large"-- weight (float) # I use it in pounds.  so it's usually something like 0.23I also have Image and Coupon models along with some helpful methods in the Image models for doing thumbnails and stuff that I needed to develope when doing my templates.  Anyway, I've got a basic shopping cart about 60% of the way done and my shirt_detail views and stuff, showing stock matrices and stuff.
I'd be happy to share anything I've come up with to help this project out!On 4/14/06, Jeremy Jones <
[EMAIL PROTECTED]> wrote:On Fri, 14 Apr 2006 22:15:31 +1200Michael <
[EMAIL PROTECTED]> wrote:> http://dshop.mine.nu/shop>> working now to setup trac>>
> > Michael> >>>I just put up what I've coded so far onhttp://jeremy.pitterpatprints.com/I just created that subdomain, so it's not in the DNS for work yet, but
it is from home.  I don't have a shopping cart built in there yet.Another question is whether to allow products from multiple stores topopulate the same shopping cart instance.  I'd think not.Anyway, this site is butt-ugly.  Nothing like the one Michael has put
up, but I hope it gets across some of my intentions.- jmj-- ---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: Ecommerce & Django

2006-04-13 Thread Clint Ecker
I'm also working on an ecommerce site in Django for selling t-shirts, but it would be easily expandable to just about anything.  It will interact with Paypal's shopping cart system and USPS for shipping.  It's a pretty straight forward port from my old PHP system, but a lot more fun and easy.
Mine is on m-r, btw.On 4/12/06, olive <[EMAIL PROTECTED]> wrote:
I'm currently working on rewriting a store (for my wife too;) I haveoriginaly wrote in OmniMark language (isn't it exotic ?).It is pretty straightforward with Django, I have already achieve theshopping cart management, user registration, shipping (Chronopost,
France), discounts.But the model is far from generic unless you want to sell CDs, DVDs,books, music and dance events and accessories.It is not yet plugable, has not been port to Magic Removal branch (this
is the next step before going on dev).I am wiilling to share my experience and participate to such a project.Olivier.-- ---Clint Ecker[EMAIL PROTECTED]http://phaedo.cx

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


Re: why is my view for a submitted form not getting a POST?

2006-03-09 Thread Clint Ecker
What is happening is that Django is redirecting your request from "rating" to "rating/" (which is the correct location).  Unfortunately POST information is lost in this redirect.
On 3/9/06, Glenn Tenney <[EMAIL PROTECTED]> wrote:
I've taken a working template and a working detail view and addeda form to that template AND another view to handle that form whensubmit gets clicked.In my template I've got:
Rating: ="" />
and that view's code is:def place_rated(request, app_label, module_name, object_id=None, template_name=None):   foo = foobar   try:  s = places.get_object(id__exact=object_id, select_related=True)
   except: raise Http404   # we either have a rating already or have to create one   rating = 0   if request.POST:  foo = foo  # this will actually do some other stuff, but... for example...
  s.rating = request.POST['rating']  s.save()   foo = bar   return HttpResponseRedirect("/place/%s/" % object_id)When I clicked on the form it got to that view just fine, but never seemed to do
anything, so... I added the "foo=..." lines purposely for debugging to throw an exceptionto see what was happening.I added the "foo = foobar" line because it never got to the "foo = foo" line
(i.e. never got to the "if request.POST").it barfs on the foo = bar line and the debug info shows:   Request Method:   GET   ...   GETNo GET data   POST   No POST data
I thought that clicking on the SUBMIT button would be a post methodand that request.POST would be true (and POST would bepopulated)... but it's not.  Because it gets an exception at the"foo=..." line, I know that it is getting to that view when I click
submit.Huh? ? What's happening?   What am I doing wrong? ?p.s. although it never gets to the line "... request.POST['rating']",is that the right way to write it to pull the input field named "rating"


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


Re: Django and Ruby on Rails framework roundtable: Dec. 3 in Chicago

2005-11-17 Thread Clint Ecker
Will the event be recorded, either audio or video?

ClintOn 11/17/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
Hi all,If you're in the area, you should come to Snakes and Rubies, a meetingof Python and Ruby Web programmers on Dec. 3 in Chicago.David Heinemeier Hansson of Ruby on Rails will be presenting his
creation, and I'll be presenting Django. We'll have spiriteddiscussion, answer questions, etc. It should be really fun.Full information is here:http://snakesandrubies.com/event/
Adrian--Adrian Holovatyholovaty.com | djangoproject.com | chicagocrime.org



Re: django & dreamhost

2005-11-14 Thread Clint Ecker
I don't have any real help for you, but I suspect that those instructions were made against an older version of Django.  Since that time, several backwardsincompatible changes have been made that will probably impede your progress.
Perhaps there is someone who could cleanup the DH instructions to match a more recent version of Django?On 11/14/05, patrickk <
[EMAIL PROTECTED]> wrote:i just tried to install django on dreamhost using the tutorial on
http://wiki.dreamhost.com/index.php/Django.some questions:it says "Create django-admin.fcgi in the same directory, with the samecontents, but change 
myproject.settings.main tomyproject.settings.admin" ... BUT, there is no myproject.settings.mainin django.fcgi - so i just used myproject.settings for both django.fcgiand django-admin.fcgi (right?).
404:when trying to go tohttp://mydreamhostserver.com/django-admin.fcgi/admin/ orhttp://mydreamhostserver.com/django.fcgi
 i get ERROR 404.patrick


Re: Catching IntegrityError?

2005-11-01 Thread Clint Ecker

Thanks a bunch! I rewrote my app using the manipulators and such and
it cut out a ton of stuff I'd written!

I guess I should read through the docs a bit more often ;)

Clint

On 11/1/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/1/05, Clint Ecker <[EMAIL PROTECTED]> wrote:
> > In my view, I do something similar to the following (instantate a new
> > Person, fill in the information from a form, and try to save it).  When
> > someone enters a forumsname that's already in the database, I'd like to
> > catch that, and act appropriately.  So initially, I didn't have a try/catch
> > block so I could see what the exception was.  It told me that it would be
> > throwing an "IntegrityError" so I modified my code to look like this:
> > [...]
> > When I try the above code, I get the following error:
> > NameError: global name 'IntegrityError' is not defined
>
> Two things here:
>
> First, you're getting "global name 'IntegrityError' is not defined"
> because IntegrityError isn't in the local namespace when you're
> catching it. You'll need to import it -- probably from psycopg:
>
> from psycopg import IntegrityError
>
> Second, it's bad practice to wrap save() in try/except. The save()
> methods don't perform validation -- they expect data to be valid
> already. Use a manipulator to validate your data. (A manipulator
> encapulates validation and form display.) See the docs here:
> http://www.djangoproject.com/documentation/forms/#custom-forms-and-manipulators
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


Catching IntegrityError?

2005-11-01 Thread Clint Ecker
I've got a model that looks like the following and describes a "Person", notice that I require the forumsname to be "unique"---begin code---class Person(meta.Model):    fullname    = 
meta.CharField(maxlength=100,verbose_name="Full Name",blank=False)    forumsname  = meta.CharField(maxlength=100, blank=False, unique=True)    address1    = meta.CharField(maxlength=255, blank=False)
    address2    = meta.CharField(maxlength=255)    city    = meta.CharField(maxlength=255, blank=False)    stateprovince   = meta.CharField(maxlength=100, blank=False)    postalcode  = meta.CharField
(maxlength=32, blank=False)    country = meta.CharField(maxlength=100, blank=False)     emailaddress    = meta.EmailField(blank=False)    notes   = meta.TextField()    beenemailed = 
meta.BooleanField(default=False)    randomkey   = meta.CharField(maxlength=32)    ...--end code--In my view, I do something similar to the following (instantate a new Person, fill in the information from a form, and try to save it).  When someone enters a forumsname that's already in the database, I'd like to catch that, and act appropriately.  So initially, I didn't have a try/catch block so I could see what the exception was.  It told me that it would be throwing an "IntegrityError" so I modified my code to look like this:
---begin code---p = persons.Person( fullname = input['fullname'],    forumsname = input['forumsname'].lower(),    address1 = input['address1'],    address2 = input['address2'],
    city = input['city'],    stateprovince = input['stateprovince'],    country = input['country'],    notes = input['notes'],    postalcode = input['postalcode'],
    emailaddress = input['emailaddress'],    randomkey = GenPasswd2(32) )    if errors == 0:    try:    p.save()    except IntegrityError, e:   # this doesn't work!
    errors = errors + 1    t['forumsnameerror'] = e    ---end code---When I try the above code, I get the following error:NameError: global name 'IntegrityError' is not defined
So which is it?  does it exist or not?  I'm really confused here :)Clint


Problems configuring urls.py to respond to /

2005-10-26 Thread Clint Ecker
Just a quick question, I played with this last night, but I didn't have much luck.

How would I set up my urls.py to redirect people who attempt to access
the root URL of the site, (ie. http://mydomain.com/) to the application
I want people to use (ie. http://mydomain.com/myapp/)

For whatever reason I couldn't figure out how to set up the url regexp to respond to a request for /

thanks in advance!

Clint


Re: Freebsd Port

2005-10-26 Thread Clint Ecker
I'd rather not go through all the backwardscompatible updates for the low-priority application I'm running on that machine ;P~
Thanks for the ever so helpful advice though.  I'm going to print it out and hang it on my wall :)

Clint
On 10/25/05, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
On Tuesday 25 Oct 2005 10:57 pm, Clint Ecker wrote:> I've also been using django on freebsd for quite a while now. But its> an old revision.svn update--regardskg
http://www.livejournal.com/users/lawgontally ho! http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!


Re: Freebsd Port

2005-10-25 Thread Clint Ecker
I've also been using django on freebsd for quite a while now.  But its an old revision.On 10/25/05, Kenneth Gonsalves <
[EMAIL PROTECTED]> wrote:On Tuesday 25 Oct 2005 2:32 pm, 
[EMAIL PROTECTED] wrote:> I just sent a new port request for Django on FreeBSD.> http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/87973
> If someone else using Django on FreeBSD> and has comment, feel free to write me.i am using django on freebsd, but i wouldnt think that a port would beof any use until django is released
--regardskghttp://www.livejournal.com/users/lawgontally ho! http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!



Re: "runserver" vs. "runserver :" : a bug?

2005-10-15 Thread Clint Ecker
On 10/15/05, Emanuele <[EMAIL PROTECTED]> wrote:
Is it a correct behaviour? I look for it in the docs but I foundnothing.Is it a bug?http://www.djangoproject.com/documentation/django_admin/
 


Re: Are multiple projects posible?

2005-08-05 Thread Clint Ecker

Are you using the built-in development server or mod_python?  In mod
python you'd just vhost another dir and set the "SetEnv" module to the
different project.

If you want to do it with two development servers, just start another
terminal instance and do the runserver mode with the --settings
command line switch.

On 8/5/05, gheorghe <[EMAIL PROTECTED]> wrote:
> 
> I want to have 2 apps that use 2 distinct databases in one django
> instalation
> There is only one SETTINGS_MODULE and that only takes 1 database.
> Is it posible?
> 
>


Re: Planet Django

2005-08-04 Thread Clint Ecker

I have a django category on my blog, here's the feed URL:

http://phaedo.cx/archives/category/geek/programming/python/django/feed

On 8/4/05, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> 
> Hey guys --
> 
> I'm working on a "planet Django" thing for djangoproject.com (written
> in Django, naturally :).
> 
> If you've got a blog (or know of one) that covers Django, please send
> me a link to the feed -- preferably a feed for the Django category,
> if it exists.  I'll try to have something up by this weekend.
> 
> Jacob
> 
>