Re: Serving Media through mod_proxy.
"Jorge Gajon" <[EMAIL PROTECTED]> writes: > Take a look at this page under the section titled "Serving media files" > > http://www.djangoproject.com/documentation/modpython/ > > That way you can also serve your media files from your same Apache instance. Yes, I know. However, that suffers many performance disadvantages, which is why a separate server process is recommended. > Personally I've been using Lighttpd with FastCGI and it has been > working great. In fact Lighttpd only redirect the traffic to the > Django FastCGI instance, it doesn't have to load any python code > itself so it is very light-weight and very good for serving media > files. I know; I have just such a version of my site running... on a nonstandard port. To switch lighty to port 80 I would have to get it running my Tracs and several other things as well. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Serving Media through mod_proxy.
I'm running django with Apache/mod_python and serving media through lighttpd. I have only one IP address, so lighttpd is running on port 8081, but some of my clients are behind firewalls that block ports other than 80. I'm planning to ditch Apache and run everything with lighttpd under FastCGI, but I'm not ready to do that just yet just yet, so I'm wondering if I can use mod_proxy to make it look like the media is being served on port 80. My guess is that would defeat the purpose of having separate servers, but I thought I'd check. TIA, -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Model instance identity
I just wrote some code that used Model instances as keys in a dict, and was surprised to find two instances in the dict that represented the same object in the database. Shouldn't that be impossible? If you can't guarantee that a given object in the database is always represented by the same Python instance, shouldn't django.db.Model have __hash__ and __eq__ methods that makes equivalent instances hash the same? -- Dave Abrahams Boost Consulting www.boost-consulting.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: ForeignKey, null, and schema evolution
"Ramiro Morales" <[EMAIL PROTECTED]> writes: > On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: >> >> Whatever django bugs may be lurking asid, I need to move forward with >> my project ASAP so I'd really appreciate it if someone could give me a >> few hints about how to evolve my existing DB (which was created >> without the primary_key=True and (I think) also without null=True) so >> I can still use the data. > > Disclamer: I know almost nothing about databases. > > Oh, this is a (new) hint. You are not sure if you created your data > when the Session -> Track ForeignKey had null=True? If it hadn' t > and you are now trying to modify it it to use that option without > also modifying the DB, it's not that strange you are getting errors. Yes, I'm aware of that. That's why I asked for help evolving the DB. > You could confirm that by examining the table stucture. Use: > > $ ./manage.py sql program > > twice, once without null=True and once with null=True, to see the difference > and eventually create the ALTER TABLE SQL sentence to modify to reflect > the change you' ve made to your model without losing your valuable data. Good trick, thanks. > This is using sqlite3: > > --- nonull.txt 2007-02-10 19:29:23.0 -0300 > +++ nulltrue.txt2007-02-10 19:28:48.0 -0300 > @@ -13,13 +13,13 @@ > CREATE TABLE "program_session" ( > "id" integer NOT NULL PRIMARY KEY, > "title" varchar(200) NOT NULL, > "short_title" varchar(50) NOT NULL, > "description" text NOT NULL, > "start_id" integer NOT NULL REFERENCES "program_timedivision" ("id"), > -"track_id" integer NOT NULL REFERENCES "program_track" ("id"), > +"track_id" integer NULL REFERENCES "program_track" ("id"), > "duration" time NOT NULL, > UNIQUE ("start_id", "track_id"), > UNIQUE ("title") > ); > CREATE TABLE "program_speaker" ( > "id" integer NOT NULL PRIMARY KEY, Super; thanks for your help! -- Dave Abrahams Boost Consulting www.boost-consulting.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: ForeignKey, null, and schema evolution
"yary" <[EMAIL PROTECTED]> writes: > IIRC, Django's admin can't handle a field with null=True and > blank=False (which is a bit of a shame...) Try adding blank=True to > your model's field? Read my latest post and you'll see that I have tried that. It works, but only if I explicitly specify the ForeignKey's primary key. -- Dave Abrahams Boost Consulting www.boost-consulting.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: ForeignKey, null, and schema evolution
David Abrahams <[EMAIL PROTECTED]> writes: > My models.py is enclosed. It doesn't have any special dependencies. > Would you mind trying to reproduce the problem? > >> Try creating a smaller project with a trimmed >> down model -- doing the standard "remove stuff until it starts working >> or you are only left with the ForeignKey" process. > > I'll see if I can do that. FYI, I can reproduce two problems in a smaller complete project (enclosed), although I haven't had success creating a minimal case. Steps to reproduce the main problem: 0. create a database 1. syncdb 2. run the dev server 3. go to http://localhost:8000/admin/ and login 4. create a new Session object 5. fill in all required fields, creating a Speaker and TimeDivision as needed. leave Track as '--' 6. Save How to make it work: 7. Set primary_key=True on the 'name' field of the Track object 8. AND add blank=True to the 'track' field of the Session object 9. delete the database 10. repeat Note that without blank=True, the Session with no track won't validate. Whatever django bugs may be lurking asid, I need to move forward with my project ASAP so I'd really appreciate it if someone could give me a few hints about how to evolve my existing DB (which was created without the primary_key=True and (I think) also without null=True) so I can still use the data. Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- djtest.tar.bz2 Description: Binary data -- Dave Abrahams Boost Consulting www.boost-consulting.com
Re: ForeignKey, null, and schema evolution
Malcolm Tredinnick <[EMAIL PROTECTED]> writes: > On Sat, 2007-02-10 at 03:34 -0500, David Abrahams wrote: >> >> In my attempt to use >> >>ForeignKey(Track, null=True) >> >> When I actually tried to use a null Track value, I got: > [...traceback snipped...] >> >> ProgrammingError at /admin/program/session/15/ >> ERROR: invalid input syntax for integer: "" SELECT >> "program_session"."id","program_session"."title","program_session"."short_title","program_session"."description","program_session"."start_id","program_session"."track_id","program_session"."duration" >> FROM "program_session" INNER JOIN "program_timedivision" AS >> "program_session__start" ON "program_session"."start_id" = >> "program_session__start"."id" WHERE ("program_session__start"."id" ILIKE >> '40' AND "program_session"."track_id" = '') >> >> My wild guess here is that this happens because track_id is the primary key >> and thus expects an integer value; had I made the track name its >> primary key it might've worked (?). Anyway, if I want to make that >> change at this point, I don't know how to do so without losing my >> valuable data. Any help you can offer me would be very much >> appreciated. > > Can you give a little more information about how you triggered this > error? It looks like you are doing something in the admin, I am. I'm saving an existing Session object after setting its Track to the "--" entry in the pop-up used for track selection. I get a similar effect when creating a new Session without setting the Track. > but I am using null=True foreign keys through the admin successfully > without doing anything special, so it's not totally impossible. It > shows up fine in the admin system and the database stores the > reference as a NULL (in my case). And I'm using PostgreSQL, too, so > it's not a db-specific thing that I can see (although I'm using > psycopg1, not psycopg2). > > If you triggered the problem just by trying to add a record in the admin > and leaving the "track" reference field empty, it's going to be a little > hard to debug remotely. My models.py is enclosed. It doesn't have any special dependencies. Would you mind trying to reproduce the problem? > Try creating a smaller project with a trimmed > down model -- doing the standard "remove stuff until it starts working > or you are only left with the ForeignKey" process. I'll see if I can do that. > I can't place what portion of the admin is generating the query you are > seeing, so any information you can provide would be useful. The endlosed models.py ought to be sufficient. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- from django.db import models class Speaker(models.Model): last_name = models.CharField(maxlength=100) first_name = models.CharField(maxlength=100) email = models.EmailField() bio = models.TextField() class Meta: ordering = ('last_name','first_name','email') class Admin: pass # list_display = ('first_name', 'last_name') def __str__(self): return self.first_name + ' ' + self.last_name class Track(models.Model): name = models.CharField(maxlength=100, primary_key=True) description = models.TextField() class Admin: list_display = ('name', 'description') def __str__(self): return self.name class TimeDivision(models.Model): when = models.DateTimeField() starts_break = models.BooleanField() name = models.CharField(maxlength=100) class Admin: pass # list_display = ('name', 'when', 'starts_break') class Meta: ordering = ('when',) def __str__(self): return self.when.strftime('%A') + ' ' + self.name class Session(models.Model): title = models.CharField(maxlength=200) speakers = models.ManyToManyField(Speaker, filter_interface
ForeignKey, null, and schema evolution
In my attempt to use ForeignKey(Track, null=True) When I actually tried to use a null Track value, I got: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in change_stage 325. errors = manipulator.get_validation_errors(new_data) File "/usr/lib/python2.4/site-packages/django/oldforms/__init__.py" in get_validation_errors 59. errors.update(field.get_validation_errors(new_data)) File "/usr/lib/python2.4/site-packages/django/oldforms/__init__.py" in get_validation_errors 357. self.run_validator(new_data, validator) File "/usr/lib/python2.4/site-packages/django/oldforms/__init__.py" in run_validator 347. validator(new_data.get(self.field_name, ''), new_data) File "/usr/lib/python2.4/site-packages/django/db/models/manipulators.py" in manipulator_validator_unique_together 299. old_obj = self.manager.get(**kwargs) File "/usr/lib/python2.4/site-packages/django/db/models/manager.py" in get 67. return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in get 211. obj_list = list(clone) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in __iter__ 103. return iter(self._get_data()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in _get_data 430. self._result_cache = list(self.iterator()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in iterator 172. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py" in execute 12. return self.cursor.execute(sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/postgresql/base.py" in execute 43. return self.cursor.execute(sql, [smart_basestring(p, self.charset) for p in params]) ProgrammingError at /admin/program/session/15/ ERROR: invalid input syntax for integer: "" SELECT "program_session"."id","program_session"."title","program_session"."short_title","program_session"."description","program_session"."start_id","program_session"."track_id","program_session"."duration" FROM "program_session" INNER JOIN "program_timedivision" AS "program_session__start" ON "program_session"."start_id" = "program_session__start"."id" WHERE ("program_session__start"."id" ILIKE '40' AND "program_session"."track_id" = '') My wild guess here is that this happens because track_id is the primary key and thus expects an integer value; had I made the track name its primary key it might've worked (?). Anyway, if I want to make that change at this point, I don't know how to do so without losing my valuable data. Any help you can offer me would be very much appreciated. Thanks, P.S. I've seen hints elsewhere that you also need blank=True, but that had no effect for me. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Admin convenience
Hi, I'm building an app for scheduling conferences and am having a hard time finding a way to make it convenient for the scheduling administrator. Sessions need to be scheduled into time slots and it seems difficult to take advantage of the usual constraints to make scheduling work well. Here are a few issues I am bumping into. * Typically (but not always) every day of a conference has the same set of time slots, so it would be very convenient if the admin interface had a "duplicate this object" function, but I can't find one. * A conference typically runs somewhere between 3 and 6 days, but AFAICT there's no easy way to create a DateField whose choices are limited to days during the conference in the admin interface. As I think about how to build this thing, admin convenience drives me toward a ridiculously granular set of models, e.g. TimeDiv - containing just a time field TimeSpan - containing a pair of timedivs Day - containing just a date field Slot - a timespan and a day but that's surely bad for performance and query convenience. Any insight into how to resolve these tensions? TIA, -- Dave Abrahams Boost Consulting www.boost-consulting.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: Project organization and decoupling
"Doug Van Horn" <[EMAIL PROTECTED]> writes: You would put parent_folder and parent_folder/spam_website into your python path. So when you need a model from the foo application, you do: from foo.models import Eggs and if you need something from the settings module in the project, you do: from spam_website import settings This would also seem to encourage /not/ putting your applications under a project folder. I've not taken this approach in practice, though. It's just what I've read in the past... Makes sense. The author of this page sent me a private mail referencing it: http://www.guindilla.eu/blog/2006/11/02/django-deployement-personal-server/ I have yet to fully grok everything said there; I'm still reading. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Project organization and decoupling
Stefan Foulis <[EMAIL PROTECTED]> writes: On Jan 16, 2007, at 17:52, David Abrahams wrote: For me, Django doesn't seem to be delivering on its promise to allow me to build a collection of apps and organize them in different combinations into multiple Django projects, and the documentation I can find doesn't really give any clues about best practices for project organization. One problem is that the name of the Django project folder (and thus root module) always seems to creep into the code in the app-specific directories. Any insight you can offer would be appreciated. in most cases (all for me so far) you can omit the project name. I had started doing that in several places but then had problems when I tried to set up my project with lighttpd according to https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoFcgiLighttpd The result was that I started qualifying more names than I had been before. I actually ran into some problems while deploying with mod_python when mentioning the project name in urls. conf and in some import statements. it's all about the python-path :) Of course. I always use e.g app_name.models.bla instead of project_name.app_name.models.bla everywhere now At does seem a bit weird, that in many tutorials and the Documentation the project name is always creeps in. Yeah. And conversely, it's weird that in other places django smooshes together what ought to be separate namespaces. For example, a template can refer to the templatetags of any app without qualification. Is there even a way to add qualification to disambiguate? If I have two apps with a templatetag called "index," what happens? I guess it's bad practice when trying to decouple an app from specific projects. I agree that there should be a chapter on best decoupling practaces in the docs. decoupling url.confs: http://www.djangoproject.com/documentation/0_91/ tutorial3/#decoupling-the-urlconfs Yes, that's useful, and I have to admit that I haven't applied it to my project yet. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Project organization and decoupling
For me, Django doesn't seem to be delivering on its promise to allow me to build a collection of apps and organize them in different combinations into multiple Django projects, and the documentation I can find doesn't really give any clues about best practices for project organization. One problem is that the name of the Django project folder (and thus root module) always seems to creep into the code in the app-specific directories. Any insight you can offer would be appreciated. Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Jeremy Dunck" <[EMAIL PROTECTED]> writes: > Most likely, KeepAlive is holding processes unavailable while > sitting idle. How would I tell if that was happening? Turn it off and see if performance suddenly becomes rediculously good. :) Unfortunately even with KeepAlive off, I'm seeing it be quite slow for the first few page views after not hitting it for some time. The interesting(?) thing here is that my Trac sites on the same server, running with mod_python just like Django, perform well. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Ramiro Morales" <[EMAIL PROTECTED]> writes: > On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote: >> [...] >> >> Most of my content is static in nature, generated on-demand from ReST >> sources. For those pages, the model checks the mod time of a >> directory in the filesystem before deciding if the content in the >> locmem cache is up-to-date. >> > > Sorry but I don understand you here. Your content is static but > generated on-demand from ReST? > > From what you have written your app is working like this: > > 1. your model checks the mdate of the (directory containing the) >ReST files and generating the (html?) content using the docutils >tools. > > 2. Then you cache the newly generated content. Yes. > But is that caching implemented by writing the content to a disk cache > (IMHO a recommended strategy in this case) Recommended by whom? > or the locmem cache is the only one you are using?. Only locmem. > If you are using only the locmem cache you could be dealing with > a scenario like this: > > Since the locmem cache storage is non persistent and if you have > configured it so it the content is forgot after a certain period of > time It's a very long period (like a week). > this could be forcing the ReST -> html conversion to be redone not > only when you run the app/site for the first time but also after a > period of no use. > > Have you measured how much time it takes a rst2html invocation with your > ReST documents?. > > Sorry for making so many assumptions. > > Another idea: If you are using locmem caching, could this be > consuming memory to the point of making your system start > swapping heavily and be the cause of the slowness?. I don't thinks so. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
error: (32, 'Broken pipe')
I see this often when running the development server. All the pages seem to render correctly. Can anyone explain what's going on, and tell me whether I should be concerned? I note that others have asked this question in the past, but the explanation given at http://groups.google.com/group/django-users/browse_thread/thread/6691f4357f298ac5 does not apply to me; I'm only navigating after pages are fully redrawn. Thanks! Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 273, in run self.finish_response() File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 312, in finish_response self.write(data) File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 391, in write self.send_headers() File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 443, in send_headers self.send_preamble() File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 372, in send_preamble self._write( File "socket.py", line 248, in write self.flush() File "socket.py", line 235, in flush self._sock.sendall(buffer) error: (32, 'Broken pipe') -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
Kenneth Gonsalves <[EMAIL PROTECTED]> writes: On 05-Jan-07, at 9:11 PM, David Abrahams wrote: Next most likely is # of child processes. Try fiddling with Min and MaxSpareServers. http://httpd.apache.org/docs/2.0/mod/prefork.html According to the docs that should only be necessary if I have very heavy traffic. I don't; far from it. So I'm reluctant to mess with those. i have light traffic - but messing with those helped immensely Rather than me fishing in the dark, can you suggest some changes? Like, "increase the min" or something? Thanks. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Joseph Heck" <[EMAIL PROTECTED]> writes: Everyone's looking at the web serving mechanisms, so let me ask a relatively obvious question - are you doing anything complex database-wise on the page that's being so slow? Most pages shouldn't require any DB lookups. I don't see PostgreSQL soaking cycles, either. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: On Jan 5, 2:54 am, David Abrahams <[EMAIL PROTECTED]> wrote: I am developing a Django-based site, and it *really* seems to be slow... sometimes. It's running in an Apache virtual server on the Any insight you might have is appreciated. Are you sure it's not a client issue? No I'm not. I had a problem with ffox 1.5 and 2.0 which i fixed disabling ffox IPV6 support and other stuff (maxrequests and so on). The site was crawling, but it wasn't Django's fault. Did your problem cause intermittent slowness, or was it consistent? Mine's rare but bad-when-it-happens. Try testing with IE if you happen to have it handy. I do. I just brought it up and the first few accesses were slowish, but not awful. Had terrible response with Safari yesterday. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Jeremy Dunck" <[EMAIL PROTECTED]> writes: On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote: .. > Except that KeepAlive ties up processes waiting for further requests > from a client, which may never come (and certainly won't if you run > media separately as recommended. So you're saying that basically the docs are wrong (not questioning you; just trying to understand better)? The docs aren't wrong, per se-- KeepAlive generally does result in a performance improvement. I didn't mean that. I meant the part about the default settings being good unless traffic is very high. KeepAlive allows multiple HTTP request/response cycles to run through the same TCP connection, avoiding the TCP setup cost. Typically, requests made on external resources benefit most from KeepAlive (e.g. stylesheets fetched due to a reference from an HTML). But you have to weigh that cost with alternatives. The downside of KeepAlive is that it's based on time, so you'll almost certainly have processes sitting idle. If you run a separate media server, KeepAlive is generally a waste, since subsequent requests go to a separate process, and instead if just ties up the original process for no gain. In general, it's unusual to have such a heavy apache process with no subsequent requests, so the docs weren't written with it in mind. I see. ... another poke in the dark... are you serving flatpages and/or static media via Django? I'm not using the flatpages app if that's what you mean. Most of my content is static in nature, generated on-demand from ReST sources. For those pages, the model checks the mod time of a directory in the filesystem before deciding if the content in the locmem cache is up-to-date. Your settings.py and urls.py (leaving out sensitive stuff, of course) would also help. I can't thank you enough for being willing to crawl through my code and configs. BTW, I'm not posting my httpd.conf (yet) because (a) it's spread across many files and (b) I don't feel very confident that I wouldn't be making a security blunder. Voil�: settings.py --- ADMINS = ( ('Dave Abrahams', 'myemail') # ('Your Name', '[EMAIL PROTECTED]'), ) MANAGERS = ADMINS # # prepare settings that depend on where the project is being run. # from site_context import * TEMPLATE_DEBUG = DEBUG CACHE_BACKEND = 'locmem:///' # A default for the view cache, etc. CACHE_MIDDLEWARE_SECONDS = 60*10 # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE TIME_ZONE = 'US/Pacific' # Language code for this installation. All choices can be found here: # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes # http://blogs.law.harvard.edu/tech/stories/storyReader$15 LANGUAGE_CODE = 'en-us' SITE_ID = 1 # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. # Example: "http://media.lawrence.com"; MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/";, "/media/". ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. SECRET_KEY = # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( #'django.middleware.cache.CacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', ) ROOT_URLCONF = 'boost_consulting.urls' APPEND_SLASH = False TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates". # Always use forward slashes, even on Windows. 'templates' ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.comments', 'boost_consulting.testimonials', 'boost_consulting.news', 'boost_consulting.pages', ) -- urls.py from django.conf.urls.defaults import * from news.models import News from news.feeds import NewsFeed from boost_consulting.setting
Re: Why so slow?
"Jeremy Dunck" <[EMAIL PROTECTED]> writes: On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote: ... > Most likely, KeepAlive is holding processes unavailable while > sitting idle. How would I tell if that was happening? Turn it off and see if performance suddenly becomes rediculously good. :) Tried that; it's hard to tell if it makes a difference. Naturally just after the server restarts performance is bad. It eventually becomes very good, but it does that too when KeepAlive is on. As I said earlier, I usually experience this slowness when I've been away from the site for a while. I could leave it off for a while and see if that changes things, but it might take a day or more to get a good sense of whether it makes a difference. If you want more evidence, perhaps the status module would interest you. Apache status module? I could look at it, thanks. > Next most likely is # of child processes. Try fiddling with Min and > MaxSpareServers. > http://httpd.apache.org/docs/2.0/mod/prefork.html According to the docs that should only be necessary if I have very heavy traffic. I don't; far from it. So I'm reluctant to mess with those. Except that KeepAlive ties up processes waiting for further requests from a client, which may never come (and certainly won't if you run media separately as recommended. So you're saying that basically the docs are wrong (not questioning you; just trying to understand better)? The thing to remember is that apache+modpython+django+your app is a very large process, and you should try to keep it busy doing Django where possible. Otherwise, you're wasting resources... swatting flies with hammers, so to speak. Sure. If the traffic demands were high I could understand why we'd like to dedicate the process to Apache. But I don't think they're high yet. I am running quite a few services off this machine (Trac servers, Mailing lists, SVN) but they have relatively few users. > Next most likely is that you're serving media and django on the > save httpd. I definitely am. However, on a relatively low-traffic server like mine it's hard to imagine that it's causing the kind of slow responses I sometimes see. Maybe I'm deluding myself? If your processes are tied up listening to a client that's not talking, your server will sit completely idle doing nothing for as long as KeepAlive makes them. Want to see ridiculously bad performance? Make 1 server process, set KeepAlive, and server media from it. It'll take (timeout * # of http request seconds) to serve if your client doesn't actually utilize the keepalive feature. Okay, I get that. I could probably install lighthttpd, although getting that running alongside Apache seems like a minefield (just a feeling; I have no data). There's no need at all to run a separate machine for media. Lightty serving media files is crazy-fast. As long as you have a separate IP (and Apache is doing IP-based, rather than name-based, service), I'm somewhat unschooled in the IP-based/name-based distinction. I read the docs, but I'm not sure they connected. My server has one IP address. I am running several Apache virtual servers on that IP address. My configuration contains NameVirtualHost: *:80 so is that name-based? it's quite simple. In your lighttpd.conf: === server.port = 80 server.bind = "your.media.ip" Yeah, I don't have a separate IP for media. I don't know what that would cost me, either. server.username = "same as apache" server.groupname = "same as apache" server.pid-file = "/var/run/lighttpd.pid" server.dir-listing = "disable" server.document-root = "/path/to/media_root/" server.errorlog = "/var/log/lighttpd/error.log" accesslog.filename = "/var/log/lighttpd/access.log" #mime support if you want it: include_shell "/usr/share/lighttpd/create-mime.assign.pl" = Then set MEDIA_URL = media.yourdomain.com and make a DNS entry pointing media.yourdomain.com to your.media.ip. The LightHttpd docs make it sound like it would be better than apache for all _my_ webserver needs, but using it that way with Django sounds like it's still pretty experimental at best. Apparently a fair number of people are using fcgi, though I'm not one of them. Did you see this? http://www.djangoproject.com/documentation/fastcgi/#lighttpd-setup Hmm, I guess I did once. I guess that means it isn't as experimental as I thought, thanks. In any case, you seem reluctant to make changes, Well, I'm just running out of time for experimentation, but maybe I have to bite the bullet. but IMHO, the best thing you can do is keep a copy of your existing (bad) conf and do a series of A/B performance tests, starti
Re: Why so slow?
"DavidA" <[EMAIL PROTECTED]> writes: Is it possible your Apache server is doing reverse DNS lookups on the GET requests and the lookup is failing for the client machine? I seem to remember older versions of Apache having this on by default. It's Apache22, but I don't have any explicit setting in my httpd.conf. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Jeremy Dunck" <[EMAIL PROTECTED]> writes: On 1/4/07, David Abrahams <[EMAIL PROTECTED]> wrote: ... If I log into the server and run "top" while trying to access pages, I don't see any alarming jumps in CPU load; the hungriest processes typically stay in single-digit (or below) percentages of CPU usage, so I doubt profiling is going to be much use. I don't really know where to start in debugging this. Hi Jeremy, Thanks for responding... Most likely, KeepAlive is holding processes unavailable while sitting idle. How would I tell if that was happening? Next most likely is # of child processes. Try fiddling with Min and MaxSpareServers. http://httpd.apache.org/docs/2.0/mod/prefork.html According to the docs that should only be necessary if I have very heavy traffic. I don't; far from it. So I'm reluctant to mess with those. Next most likely is that you're serving media and django on the save httpd. I definitely am. However, on a relatively low-traffic server like mine it's hard to imagine that it's causing the kind of slow responses I sometimes see. Maybe I'm deluding myself? More suggestions: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ Okay, I remember reading that page already. I can't afford a separate media server machine. I could probably install lighthttpd, although getting that running alongside Apache seems like a minefield (just a feeling; I have no data). The LightHttpd docs make it sound like it would be better than apache for all _my_ webserver needs, but using it that way with Django sounds like it's still pretty experimental at best. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Why so slow?
"Jeremy Dunck" <[EMAIL PROTECTED]> writes: On 1/4/07, David Abrahams <[EMAIL PROTECTED]> wrote: ... If I log into the server and run "top" while trying to access pages, I don't see any alarming jumps in CPU load; the hungriest processes typically stay in single-digit (or below) percentages of CPU usage, so I doubt profiling is going to be much use. I don't really know where to start in debugging this. Most likely, KeepAlive is holding processes unavailable while sitting idle. How would I tell if that was happening? Next most likely is # of child processes. Try fiddling with Min and MaxSpareServers. http://httpd.apache.org/docs/2.0/mod/prefork.html According to the docs that should only be necessary if I have very heavy traffic. I don't; far from it. So I'm reluctant to mess with those. Next most likely is that you're serving media and django on the save httpd. I definitely am. However, on a relatively low-traffic server like mine it's hard to imagine that it's causing the kind of slow responses I sometimes see. Maybe I'm deluding myself? More suggestions: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ Okay, I remember reading that page already. I can't afford a separate media server machine. I could probably install lighthttpd, although getting that running alongside Apache seems like a minefield (just a feeling; I have no data). The LightHttpd docs make it sound like it would be better than apache for all _my_ webserver needs, but using it that way with Django sounds like it's still pretty experimental at best. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Why so slow?
I am developing a Django-based site, and it *really* seems to be slow... sometimes. It's running in an Apache virtual server on the same machine as my static site. When things are good, the Django-based site approaches the static site in speed, but when things are bad, there's just no comparison. At those times, my development server (local of course) is far, far faster. The slowness typically comes after not having accessed the site for a while. I suspected paging at first, but I don't think anything should be taking that much memory and I noticed that it tends to stay slow through several minutes of surfing, when everything should have long since been paged back in. I'm using the prefork MPM as recommended. I'm using the locmem cache. I'm not cacheing pages, but I am cacheing major HTML fragments -- the templating system is still running for each page. I was cacheing whole pages for a while and it didn't seem to make a difference, so I turned that off. If I log into the server and run "top" while trying to access pages, I don't see any alarming jumps in CPU load; the hungriest processes typically stay in single-digit (or below) percentages of CPU usage, so I doubt profiling is going to be much use. I don't really know where to start in debugging this. Any insight you might have is appreciated. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Apache auto-reload?
Hi, I'm developing a site locally, and managing its code and static data in a subversion repository. I also have it running on a real apache server on the web with mod_python, but I don't want to login to the server, restart, etc. every time I check something in. I've got a post-commit hook already updating the server's copy of the site code, and I'm guess I'm going to have to add apache.sh gracefulstop # if models were changed, then: # something to wipe out invalidated tables from the database python manage.py syncdb apache.sh start unless someone has a better suggestion. Is this a problem someone out there has already solved? Thanks in advance, -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Moving from development server to apache
I've been very happily developing my Django site with the development server, and decided it was time to start it under Apache. I ran into several problems that really slowed my development down. I'm posting here because: a. I'd love some help with these if anyone can offer it; many of my "solutions" don't seem too clean. b. In the documentation, some note about how to get over the humps would be very useful The first problem was that my App seems to make a number of assumptions based on the current directory where the development server is run. Although my project is a Python package (it has an __init__.py) and I make an effort to qualify names in my project with the package name wherever possible, my httpd.conf needed not only PythonPath "['/path/to/directory/containing/my-project-dir']+sys.path" but PythonPath "['/path/to/directory/containing/my-project-dir', '/path/to/my-project-dir']+sys.path" Without it, the names of my apps would not be recognized without qualification, and since according to the Django design these apps are supposed to be pluggable into different Django projects, they /should/ be recognized that way. Also I found other dependencies on the current working directory (I build some pages from files in my filesystem), which I solved by import os os.chdir('/path/to/my-project-dir') in my settings.py. I think that's a hack, but I don't know how to solve it better. Between that and turning off the serving of site media through Django, it means the settings.py and urls.py I run on my real server have to differ from the ones I use on my development server. I'm trying to be disciplined about using source control for this, so I'd prefer to use portable. I guess I could set a special environment variable in my httpd.conf, detect that in settings.py, and execute different code. Better ideas anyone? Finally, I had to explicitly specify a PostgreSQL user in my settings.py file, because my apache runs as a different user (www) than the one that created the database, and although I used psql to GRANT ALL PRIVILEGES ON DATABASE "my.db" TO www; I still couldn't get it to work until I set DATABASE_USER to "dave", which is a PostgreSQL superuser (yikes!). Since Django's nice model API makes most knowledge of DB nitty-gritties obsolete, it would be great if the docs could lend a helping hand over this particular detail. Thanks in advance, -- Dave Abrahams Boost Consulting www.boost-consulting.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: UnicodeEncodeError with templatetags
Ivan Sagalaev <[EMAIL PROTECTED]> writes: > David Abrahams wrote: >> I've been running into a problem that seems very similar to >> http://code.djangoproject.com/ticket/170, although I see that that >> issue was fixed so I am betting the bug is on my end somewhere. >> Unfortunately, I'm a little green w.r.t. unicode issues so I'm hoping >> someone else can correct my misconceptions. >> >> My app's templatetags/navigation.py file is enclosed. If you look for >> the string ".title()" you can see where the title() method on my Page >> objects is getting called. Unless I change that method to encode its >> result as ascii or utf-8, I get the exception. Can anyone explain >> what's going on? I suspect problems with mixing utf-8 and ascii >> encoded strings, but I'm really out of my depth here. > > Looking at title() that you included: > > def title(self): > return 'Home' > > it already returns an ASCII encoded string. But I suspect you actual > class returns a unicode, right? Frankly I am not sure, although it does seem like a possibility. I could check. > If yes then trying to concatenate a unicode string with a byte string > will force Python to decode a byte string into a unicode using whatever > current locale is active. This automatic decoding-encoding is always > error-prone because in different places you will have different locale. > So it's always needed to do this explicitly. Oh, wow; I may well be doing that all over. Is it possible to instruct Python to make that an error rather than silently succeeding to do something that I shouldn't do? > Since most of the code in your template tag does its work using byte > strings it would be easier to encode title()'s output into a byte string > manually (an alternative would be converting all your tag's code to work > on unicode strings). Well, I did try that (or at least I thought so) but it didn't seem to make the problem go away. > The question is in what byte encoding to encode. It > looks obvious to convert it into settings.DEFAULT_CHARSET since it's an > encoding of all your output. However if you set DEFAULT_CHARSET into > some legacy encoding (i.e. other than 'utf-8') I don't set it to anything explicitly, so I have the default DEFAULT_CHARSET. > there might be cases (theoretically) when a unicode string contains > characters that can't be encoded in it (for example you can't have > russian characters in Western European windows-1252). So you may > want to take a safety measure: > > title().encode(settings.DEFAULT_CHARSET, errors='xmlcharrefreplace') > > ... and all characters that cannot be encoded into DEFAULT_CHARSET will > appear as for example А which is acceptable for HTML. Well, that's very instructive, thank you! But again, my main concern is that I'm probably doing something bad all over, by combining byte strings with unicode strings. By the way, is there a reference that describes Python's string abstractions? I take it from your use of the terms "unicode string" and "byte string" that they are not in fact congruent to one another. Let me guess: a byte string (e.g. 'abcdef') is a semantically void container of bytes that might be used for ascii, utf-8, or something else... and a "unicode string" is a container of code points? Thanks again for your attention, -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
UnicodeEncodeError with templatetags
I've been running into a problem that seems very similar to http://code.djangoproject.com/ticket/170, although I see that that issue was fixed so I am betting the bug is on my end somewhere. Unfortunately, I'm a little green w.r.t. unicode issues so I'm hoping someone else can correct my misconceptions. My app's templatetags/navigation.py file is enclosed. If you look for the string ".title()" you can see where the title() method on my Page objects is getting called. Unless I change that method to encode its result as ascii or utf-8, I get the exception. Can anyone explain what's going on? I suspect problems with mixing utf-8 and ascii encoded strings, but I'm really out of my depth here. Many thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- from django import template # from static.models import Page from static import Page register = template.Library() class Home: '''A fake page that gets us an initial Home menu''' def children(self): return [] def get_absolute_url(self): return '/' def title(self): return 'Home' class NavigationNode(template.Node): @classmethod def _menu_items(self, root, pages, depth): if depth == 0: return '' items = [] items.append( '%s Home' % ( root.get_absolute_url(), root.title())) for i in range(len(pages)): p = pages[i] c = p.children() classes = [] if c: classes.append('submenu') if i == len(pages) - 1: classes.append('last') items.append( '%s\n%s' % ( len(classes) and ('class="' + ' '.join(classes) + '"') or '', p.get_absolute_url(), p.title(), self._menu_items(root, p.children(),depth-1))) return ' \n%s\n' % ''.join(items) def render(self, ctx): result = '\n' first = 'first-' for top in [Home()] + Page.roots(): children = top.children() if children: leaf = '' # increase depth to create multilevel menus menu_items = self._menu_items(top, children, depth=1) else: menu_items = '' leaf = '-leaf' result += '' % (first, leaf) result += '%s\n' % (top.get_absolute_url(), top.title()) result += menu_items result += '' return result + '\n' def navigation_tree(parser, token): return NavigationNode() register.tag(navigation_tree) -- Dave Abrahams Boost Consulting www.boost-consulting.com
Re: Support for static content?
"Adrian Holovaty" <[EMAIL PROTECTED]> writes: > On 10/5/06, David Abrahams <[EMAIL PROTECTED]> wrote: >> So the idea is to map certain URLs into that view, have the view parse >> the URL to find the files in the SVN working copy that it should use >> to generate the page, use those files to generate a data structure on >> which the template can operate, and pass the data structure off to the >> rendering code? Wow, suddenly that looks easy. > > Yes, that's exactly it. Like I said, there's no need to use a > database. Glad you've got it. :) Just to clarify: I intend to use a database; I just have some particular ideas about what kinds of things should be kept there. What I'm still wondering about, though, is whether this isn't a common usage model that should be more explicitly supported by the framework (or its docs, if there's _really_ no code you can write to support it)? Call me fastidious, but it just seems like principled development to keep site content that isn't provided by users in revision control along with the code. Otherwise, rolling back to an earlier version of the site is sorta meaningless. Hmm, subversion uses a database. It would be kind of interesting to see a Django-like system built atop something like subversion. User edits could create/edit YAML, for example. -- Dave Abrahams Boost Consulting www.boost-consulting.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: Support for static content?
"Adrian Holovaty" <[EMAIL PROTECTED]> writes: > If you just want to use the HTTP request/response part of Django, > there's no requirement that you need to use a database. > > All Django cares about is that your view functions return an > HttpResponse. What they do internally -- whether it's connecting to a > database, or connecting to your ReStructured Text source -- is > entirely up to you. > > def my_view(request): > t = get_my_restructured_text() > return render_to_response('mytemplate', {'text': t}) > > There is no reason you'd have to store your text in a database, except > if you wanted your text to be edited by Django's admin interface. But > if you're using SVN to manage your data, you wouldn't want that, > anyway. So the idea is to map certain URLs into that view, have the view parse the URL to find the files in the SVN working copy that it should use to generate the page, use those files to generate a data structure on which the template can operate, and pass the data structure off to the rendering code? Wow, suddenly that looks easy. Thanks :) -- Dave Abrahams Boost Consulting www.boost-consulting.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: Support for static content?
Tim Chase <[EMAIL PROTECTED]> writes: >> Django's database-centric approach seems to make certain kinds >> of mostly-static sites harder to build. > [cut] >> Yes, Django is a framework, so I could build components that >> make this possible, but it seems to me that it should be a >> fundamental, built-in part of the system. Has anyone already >> addressed these issues? > > Well, there's some documentation at > > http://www.djangoproject.com/documentation/static_files/ > > with the lovely "big, fat warning" at the top. I don't know how > to interpret that, as to whether it contains known flaw(s), or if > it just hasn't been audited for security, or what. > > However, it looks like most of the heavy lifting has been done, > but that you might want to review the code for vulnerabilities > (and possibly contribute back any fixes). Ivan Sagalaev <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: >> I >> need a clean separation between the data that is changed by >> interacting with apps and data that isn't. > > You can store your data in the form of templates and use > 'direct_to_template' to bind it to certain urls: > http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template > > Will this work for you? I don't think either of these approaches quite works for me. Maybe "static content" is a misnomer here. The content needs to be _generated_ but from files that are largely static. The distinguishing characteristic is that the content of these files is not the result of some interaction with the user, and so is not stored in the database. For example, I might have a directory hierarchy of page bodies checked into source control: content/ index.rst about.rst company/ contact.rst history.rst projects/ foobar-corp.rst acme-anvils.rst I want the following URLs: http://mysite.net/index.html http://mysite.net/about.html http://mysite.net/company/contact.html http://mysite.net/company/history.html http://mysite.net/projects/foobar-corp.html http://mysite.net/projects/acme-anvils.html Let's say each page should be generated by processing the corresponding .rst file with docutils to get HTML for the main body of the page, and combining that with some template that provides sidebars and menus. This doesn't seem like such an oddball scenario to me, but maybe I'm missing something. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---