Re: Beautiful popup windows

2010-08-06 Thread Michael Hipp

On 8/6/2010 8:13 AM, kostia wrote:

Do we know some alternatives for using popups in python/django?


I bookmarked these a while back but haven't yet used them:

http://trentrichardson.com/Impromptu/index.php
http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

Michael

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



Re: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Michael Hipp

On 8/4/2010 7:47 PM, André A. Santos wrote:

wow this is different to me because Java is different follows MVC...
so, the business rules stay on View (GUI)?


All the view does is create the http response. If the particular request 
requires any significant business logic, I would put that in a different 
module to keep it separate but in between the view and the model. That, 
IMHO, is where business logic should reside.


Michael

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



Re: Is there anyone who is using Django on Windows 7 host system.

2010-08-01 Thread Michael Hipp
I'm using it on two Win7 systems (one x32, one x64). The 
"django-admin.py startproject mysite" command seems to do just what is 
expected. But note that I can't just enter it that way. Here's what I do:


python C:\dev\virtenvs\redmule\Scripts\django-admin.py startproject mysite

This is because I use a virtual environment to hold the django packages.

If you're not using a virtual environment that command might be:

python c:\python26\Scripts\django-admin.py startproject mysite

This needs to be entered from the dir where you want the 'mysite' dir to 
be created.


There are 4 things to be aware of:
- Where is python installed?
- Where did the django-admin.py scipt get installed (determined by how 
Django was installed or not)?

- What is the PYTHONPATH?
- What is the system PATH (is python in that path, is django-admin.py in 
it)?


What, precisely, are the symptoms of the problem you're having?

Michael


On 8/1/2010 10:49 AM, balu wrote:

I'm not getting the actual result which should we get when we run
"django-admin.py startproject mysite" on  windows 7 Operating system.



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



Re: What goes in 500.html?

2010-07-26 Thread Michael Hipp

Thanks for a helpful and complete answer, David.
Michael

On 7/26/2010 6:24 AM, David De La Harpe Golden wrote:

On 24/07/10 20:14, Michael Hipp wrote:

What should go in a proper 500.html page?


As little as you can get away with; it's for when your server has
screwed up.

However, you probably want to make it distinguishable from the
apache-level 500 page, in a manner you can ask a user reporting a
failure a single simple question to tell the difference. At one stage I
had the bright idea of making them look the exact same for appearances'
sake. That was dumb.


Is some content fed to it that
should be displayed?


Not really, it's intended to be pretty static, something that django has
a hope of outputting even in a royally messed up config.


Similarly for 404.html?



That's a bit different, put pictures of kittens or whatever you want.



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



What goes in 500.html?

2010-07-24 Thread Michael Hipp
What should go in a proper 500.html page? Is some content fed to it that should 
be displayed?


Similarly for 404.html?

Thanks,
Michael

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



Sending emails, threads, progress back to user

2010-07-21 Thread Michael Hipp

I've been googling extensively but can't seem to find an real answer for this...

- User clicks a button to send a batch of emails to customers
- Django view kicks off a thread to send the emails using django.core.mail
- The view response sends the user to a page that will monitor progress
  using periodic ajax calls

Questions:
- How does the thread communicate progress back to a place where the ajax 
driven view can pick it up and return it to the user?

- Is there a problem running django.core.mail in a thread?

(I'd prefer not to use some of the heavyweight solutions relying on daemons and 
other stuff running entirely outside Django and cron doesn't make the user feel 
involved. In my wxPython desktop apps this stuff is pretty easy using pubsub. 
But I don't see how to make that work in Django.)


Thanks,
Michael

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



Re: Send email attachment from memory buffer

2010-07-21 Thread Michael Hipp

On 7/20/2010 9:08 PM, Ale wrote:

On Tue, Jul 20, 2010 at 10:04 PM, Michael Hipp mailto:mich...@hipp.com>> wrote:
Is it
possible to give it a file-like object instead?

Did you see the documentation regarding creating an EmailMessage and the
attach() method?

"""You can pass it a single argument that is an email.MIMEBase.MIMEBase
instance. This will be inserted directly into the resulting message."""


Yes, I saw that but didn't grasp that therein was the answer to my question. 
Thanks for the hint.



Another idea: In what type of operating environment are you? If you are
in linux you can use /dev/shm [0]


Unfortunately this deployment will be on an old W2k box for a while.

Thanks,
Michael

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



Send email attachment from memory buffer

2010-07-20 Thread Michael Hipp
I will be sending pdfs generated from django and would like to email them but 
without writing them to the filesystem.


I can generate the pdf to a buffer but django.core.mail seems to only handle 
attachments that are specified as a filename. Is it possible to give it a 
file-like object instead?


Thanks,
Michael

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



Any way to get AutoField from inspectdb?

2008-03-08 Thread Michael Hipp

I have a legacy database that happens to be PostgreSQL. It has this primary 
key field:

 CREATE TABLE foo (
 id integer PRIMARY KEY,

When I do 'inspectdb' it gives me a model with this in it:

 class Foo(models.Model):
 id = models.IntegerField(primary_key=True)

But what I really want to end up with, I think, is this:

 class Foo(models.Model):
 id = models.AutoField(primary_key=True)

Is there any way to get inspectdb to provide this instead of IntegerField?

The legacy database is in flux (all 1300+ fields) so just hand editing it 
every time it changes isn't practical right now.

Thanks,
Michael


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



Re: Getting a UNION query in Django Models?

2008-02-25 Thread Michael Hipp

Rajesh Dhawan wrote:
> Hi Michael,
> 
>> How do I do something like this using Django Models?
>>
>>  SELECT name,birthdate FROM friends
>>UNION
>>  SELECT name,birthdate FROM enemies
>>ORDER BY birthdate, name;
>>
>> I can't find any reference in the Django docs to getting a UNION.
> 
> The Django ORM essentially maps one DB table to one Django model
> class. Since, in your example, friends and enemies are two different
> tables i.e. two different Django model classes, the above query is not
> possibly using the Django Model API. However, you can execute this
> query as well as other complex queries using by dropping in to raw
> SQL.
> 
> See this for an example:
> http://www.djangoproject.com/documentation/model-api/#executing-custom-sql

Thanks. Unfortunately doing it that way returns a list of tuples - a bit 
hard to work with.

Is there some way to get a "normal" (i.e. dictionary-like) response 
without having to resort to making my own connection with psycopg2?

Thanks,
Michael

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



Getting a UNION query in Django Models?

2008-02-25 Thread Michael Hipp

How do I do something like this using Django Models?

 SELECT name,birthdate FROM friends
   UNION
 SELECT name,birthdate FROM enemies
   ORDER BY birthdate, name;

I can't find any reference in the Django docs to getting a UNION.

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Where to set the cwd?

2008-02-25 Thread Michael Hipp

Graham Dumpleton wrote:
> On Feb 24, 11:08 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> So how do I make those lines look like that instead of having a bunch of
>>   absolute paths stuck in there or lots of messy stuff with
>> os.path.join(os.path.dirname(__file__)...) in it?
> 
> Don't. You should never ever write a web application such that it will
> only work if the current working directory is a specific directory, it
> is just very bad practice to do so.
> 
> This is because in hosting systems like Apache there is absolutely no
> guarantee that the working directory will be something in particular
> and you can't even change it to be a specific value and expect it to
> work reliably. This is because in any sort of system where the process
> is shared by other code you didn't write or which is outside of your
> control, you can't prevent that other code also wanting to change the
> working directory and subsequently screwing up your code.
> 
> Python web frameworks or applications which have to one degree or
> another made a choice to somehow rely on the current working directory
> being a specific value are limiting the deployment choices for their
> users by doing so. You are thus highly discouraged against doing it
> and using __file__ as an anchor or a variable setting in main settings
> configuration file is a better and more portable way of doing it.

Just to close the loop on this, Graham's explanation makes perfect sense.

But why are these instructions even included in the book and in the 
documentation?

--
http://www.djangoproject.com/documentation/fastcgi/
http://www.djangobook.com/en/1.0/chapter20/

'Running Django on a shared-hosting provider with Apache'

"Create a file mysite.fcgi ..."

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")
--

Shouldn't this be removed (or at least padded with some warnings) since 
  it is arguably encouraging a (new?) user to do something that is poor 
practice or even dangerous.

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Where to set the cwd?

2008-02-23 Thread Michael Hipp

Drew Raines wrote:
> Michael Hipp wrote:
> 
> [...]
> 
>> But I have lots of "data" files that live in and around my Django
>> code and I have to access with them with stuff like:
>>
>> f = open("somedir/myfile.dat", 'r')
>>
>> So how do I make those lines look like that instead of having a bunch of 
>>   absolute paths stuck in there or lots of messy stuff with 
>> os.path.join(os.path.dirname(__file__)...) in it?
> 
> Don't use specific paths throughout your code.  Set variables in
> settings.py and scatter those around.
> 
> To avoid the proliferation of os.path.* everywhere, I use something
> like this in my settings files:
> 
>   import os
>   HOME = os.path.abspath(os.path.dirname(__file__))
> 
>   TEMPLATE_DIRS = (
>   HOME + "/templates",
>   )
> 
>   UPLOADS = HOME + "/files"
> 
> and so on.

Me like. Thanks.

Michael

--~--~-~--~~~---~--~~
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: Where to set the cwd?

2008-02-23 Thread Michael Hipp

Graham Dumpleton wrote:
> On Feb 24, 11:08 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Malcolm Tredinnick wrote:
>>
>>> On Sat, 2008-02-23 at 16:02 -0600, Michael Hipp wrote:
>>>> Where in my Django code files can I set the current working directory
>>>> (so that it applies to all my code)?
>>>> I'm trying to make sure that all paths in my Python code are relative
>>>> paths. But I think I need to know where I can put the cwd change so that
>>>> it runs when Django first comes up.
>>> No, you don't. What you want to do is set the Python path variable in
>>> your environment. Have a look at Django's documentation on mod_python
>>> setup to see how to set that environment variable. That's the standard
>>> way to do this.
>> I think we're talking about two different things. I have the PythonPath
>> variable set in my httpd.conf file. No problem with imports.
>>
>> I wasn't speaking of imports.
>>
>> But I have lots of "data" files that live in and around my Django code
>> and I have to access with them with stuff like:
>>
>> f = open("somedir/myfile.dat", 'r')
>>
>> So how do I make those lines look like that instead of having a bunch of
>>   absolute paths stuck in there or lots of messy stuff with
>> os.path.join(os.path.dirname(__file__)...) in it?
> 
> Don't. You should never ever write a web application such that it will
> only work if the current working directory is a specific directory, it
> is just very bad practice to do so.
> 
> This is because in hosting systems like Apache there is absolutely no
> guarantee that the working directory will be something in particular
> and you can't even change it to be a specific value and expect it to
> work reliably. This is because in any sort of system where the process
> is shared by other code you didn't write or which is outside of your
> control, you can't prevent that other code also wanting to change the
> working directory and subsequently screwing up your code.
> 
> Python web frameworks or applications which have to one degree or
> another made a choice to somehow rely on the current working directory
> being a specific value are limiting the deployment choices for their
> users by doing so. You are thus highly discouraged against doing it
> and using __file__ as an anchor or a variable setting in main settings
> configuration file is a better and more portable way of doing it.

Ok. Thanks. The idea of putting it in settings.py is probably the path 
of least litter.

Michael

--~--~-~--~~~---~--~~
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: Where to set the cwd?

2008-02-23 Thread Michael Hipp

Malcolm Tredinnick wrote:
> 
> On Sat, 2008-02-23 at 16:02 -0600, Michael Hipp wrote:
>> Where in my Django code files can I set the current working directory 
>> (so that it applies to all my code)?
>>
>> I'm trying to make sure that all paths in my Python code are relative 
>> paths. But I think I need to know where I can put the cwd change so that 
>> it runs when Django first comes up.
> 
> No, you don't. What you want to do is set the Python path variable in
> your environment. Have a look at Django's documentation on mod_python
> setup to see how to set that environment variable. That's the standard
> way to do this.

I think we're talking about two different things. I have the PythonPath 
variable set in my httpd.conf file. No problem with imports.

I wasn't speaking of imports.

But I have lots of "data" files that live in and around my Django code 
and I have to access with them with stuff like:

f = open("somedir/myfile.dat", 'r')

So how do I make those lines look like that instead of having a bunch of 
  absolute paths stuck in there or lots of messy stuff with 
os.path.join(os.path.dirname(__file__)...) in it?

Thanks,
Michael



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



Where to set the cwd?

2008-02-23 Thread Michael Hipp

Where in my Django code files can I set the current working directory 
(so that it applies to all my code)?

I'm trying to make sure that all paths in my Python code are relative 
paths. But I think I need to know where I can put the cwd change so that 
it runs when Django first comes up.

I'm on Apache and mod_python on Windows.

Thanks,
Michael


--~--~-~--~~~---~--~~
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: Head swimming - JavaScript libraries

2008-02-18 Thread Michael Hipp

Just wanted to thank everyone who replied (Julien, Dj Gilcrease, Phoenix 
Kiula, Hraban, Horst Gutmann, AmanKow, Peter Rowell).

I think I will have a go at jQuery. Looks good.

Thanks,
Michael


Peter Rowell wrote:
> Yet another vote for jQuery. It completely changed the way I look at
> using JS on pages.
> 
> BTW, ext works with jQuery. See 
> http://docs.jquery.com/Tutorials:Using_Ext_With_jQuery


--~--~-~--~~~---~--~~
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: Head swimming - JavaScript libraries

2008-02-16 Thread Michael Hipp

Julien wrote:
> Hi Michael,
> 
> This subject has been discussed many times here, and the answer is
> that there is no answer. Django is flexible enough to work with
> whatever JS library you like. So, have a look around all those
> libraries, pick the one that would work best for a given project or
> the one you feel most comfortable with, and you can be sure that the
> library you've picked will work fine with Django.

Thanks, Julien.

But actually I was hoping someone would come back with an answer like 
"Just use XYZ, it's great and here's why..."

At the moment I'm despairing of having too many choices.

And did I mention that I personally find JavaScript to be, uh ... er, 
not my favorite programming language.)

Michael


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



Head swimming - JavaScript libraries

2008-02-16 Thread Michael Hipp

My head is swimming...

I've spent the last 2 days reading up on jQuery, MochiKit, Yahoo and 3 
dozen others that I don't remember right now.

Does anyone have any thoughts on picking a JavaScript library for use 
with Django that is compact, simple, and has a good collection of 
widgets and convenience methods (well documented, great community, 
active development, etc.)?

... and the less it forced me to know about JavaScript, the better!

Any help appreciated.

Michael



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



Django with SQLAlchemy?

2008-02-13 Thread Michael Hipp

I've been reading stuff like this:
http://groups.google.com/group/django-developers/browse_thread/thread/5149e1c60dc65bff/a177bb34cfde1ec7

And a zillion others on a Google search of 'django sqlalchemy'.

What's the status?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: i'm tired

2008-02-11 Thread Michael Hipp

Jeff Gentry wrote:
>> Man I hear you. I've been doing web for 10 years, in a variety of
>> languages. I have Django installed VERBATIM according to the
>> documentation.
> 
>> I can get Django to run, but I can't get it to server images using the
>> built-in server. mod_python is a whole other ball of wax. I have
>> mod_python working on another Windows machine, but again, it won't
>> serve images.
> 
> FWIW, just to provide a counter opinion, I started using Django a few
> weeks ago.  So far I have not encountered one single issue, and no
> question/problem that I faced wasn't solvable with a bit of poking around
> and web searching. 
> 
> In fact, I've found that Django "makes sense".  Everything has been
> extremely logical in its layout and design, everything just seems to work
> the way I'd expect it to work.

And the documentation is excellent. Top notch.

Michael

--~--~-~--~~~---~--~~
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: About to give up!!!

2008-02-09 Thread Michael Hipp

Brandon Taylor wrote:
> Hi everyone,
> 
> I'm just about to give up on Django. I can't even get it to load a
> simple jpeg using the built-in server.
> 
> Here is my directory structure:
> 
> '/Users/bt/django_projects' is where all of my Django projects exist
> 
> /btaylor_design
> settings.py, etc
> /public
> /images
> /stylesheets
> /javascript
> 
> 
> In my urls.py, I have the following:
> 
> from django.conf.urls.defaults import *
> from django.conf import settings
> from btaylor_design.views import home
> 
> urlpatterns = patterns('',
> (r'', home),
> 
> # Uncomment this for admin:
> #(r'^admin/', include('django.contrib.admin.urls')),
> )
> 
> if settings.DEBUG:
> urlpatterns += patterns('django.views',
> (r'^public/(.*)$', 'static.serve',
> {'document_root': '/Users/bt/django_projects/btaylor_design/public'}),
> )
> 
> 
> Can ANYONE give me a definitive answer on why this thing won't load so
> much as a simple image, with a src set to: http://www.google.com/search?hl=en&client=firefox-a&channel=s&rls=org.mozilla%3Aen-US%3Aofficial&hs=sTX&q=django+static+files+development+server&btnG=Search

http://www.djangoproject.com/documentation/static_files/

You have the document root thing set to public rather than 
public/images. The instructions clearly say '/path/to/media', not 
/path/to/doc/root

here's mine:

if settings.DEBUG:
 urlpatterns += patterns('',
 (r'^images/(?P.*)$', 'django.views.static.serve',
  {'document_root': 'c:/projects/djcode/reports/images'}),
 (r'^css/(?P.*)$', 'django.views.static.serve',
  {'document_root': 'c:/projects/djcode/reports/css'}),
 )

This isn't hard, but helps when you get started to follow the directions 
*exactly* until it's working, then try customizing things to suit your 
needs/tastes.


Michael

--~--~-~--~~~---~--~~
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: Web Development with Django: Windows vs Linux/Mac OS X

2008-02-07 Thread Michael Hipp

Aleandro wrote:
> In fact, running on the development computer the same exact software
> environment present on the production server is the strongest pro-
> Linux argument, especially if you have a VPS and not a shared server.
> To be honest, I think neither with Windows or Mac OS X you can obtain
> this ideal condition.
> 
> However I doubt this is really necessary: as an example, on my laptop
> I'm currently using the lightweight web server included in Django
> where on the production server I will deploy my Django app with Apache
> and mod_python or mod_wsgi on Apache 2 behind an nginx proxy.
> 
> Of course the deployment stage will be a bit more tricky for a Windows
> developer but, frankly, I'm a developer and I'm more interested in the
> development stuff. If, as a developer, there are no advantages in
> using Linux or Mac OS X, I will remain with Windows.
> 
> So I'd like to know from people using Windows what are (if any) the
> practical handicaps in developing a Django app on Windows.

I'm very much a pro Linux guy.

But I spend most of my time working in Windows on the desktop because 
that's what my clients use and that bit of commonality just saves a lot 
of extra work.

Frankly I'd be hard pressed to articulate any earth-shattering 
advantages for developing Django on Linux. On my Windows boxes I use 
PostgreSQL, psycopg, Python, Django, Apache, mod_python, PuTTY, 
FileZilla, Firefox, Cygwin, etc. All easy as pie.

The advantages for a Linux environment are more subtle, but not 
inconsequential:

- An actual working command-line shell instead of that abomination cmd.exe
- Ease of access to tools like grep, sed, awk, rsync, etc. can 
occasionally make some things a lot easier.

If developing toward a Linux web server environment was my main line of 
work, I'd probably be running Linux on the desktop. But having to deal 
with so much other Windows-centric stuff tilts the center of gravity.

Michael

--~--~-~--~~~---~--~~
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: Setting up Apache & mod_python on my development computer

2008-02-06 Thread Michael Hipp

Is there a reason this line looks like this:
> 

Instead of like this:
> 

Michael

Brandon Taylor wrote:
> Well, still no working solution, but here is my httpd.config now:
> 
> 
> SetHandler python-program
> PythonPath "['C:/django_projects/', 'C:/Python25/lib/site-packages/
> django'] + sys.path"
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE testproject.settings
> PythonDebug On
> 
> 
> I'm wondering if I should move to a FastCGI setup versus mod_python,
> as that's how my shared environment is going to be configured.
> 
> Thoughts anyone? I don't understand what the problem might be here.
> I'll see if I have any more luck on my Mac when I get home.
> 
> - Brandon

--~--~-~--~~~---~--~~
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: template: how to make use of forloop.counter0

2008-02-04 Thread Michael Hipp

Thank you. Using the counter0 as an index into a list seemed like an 
obvious use case to me. So I give your 'get' filter idea a +1.

Thanks for the CSS idea. I found an alternate solution using the  tag to set the alignment on a whole column so I only have 
to loop thru the align list once. More efficient than what I was trying 
to do originally.

Thanks,
Michael

Ned Batchelder wrote:
> The more I think about your questions, the more I think Django could use 
> a |get filter that would be similar in spirit to the |slice filter.  
> |get would be used to get an attribute or index of an object.  Then you 
> could use:
> 
> 
> 
> This |get filter is something I just made up, so it is not available to 
> you, though. 
> 
> In this case, you can use CSS to achieve what you need:
> 
> 
> {% for al in align %}
> td.align{{forloop.counter0}}: { text-align: {{al}}'; }
> {% endfor %}
> 
> ...
> {% for col in row %}
>{{col}}
> {% endfor %}
> 
> (I've probably scrambled the proper CSS attributes, you get the idea.)
> 
> --Ned.
> http://nedbatchelder.com/blog
> 
> Michael Hipp wrote:
>> David Reynolds wrote:
>>   
>>> On 3 Feb 2008, at 3:32 pm, Michael Hipp wrote:
>>>
>>> 
>>>> Malcolm Tredinnick wrote:
>>>>   
>>>>>> Or is there some other way to get at my 'align' list?
>>>>>>   
>>>>> Look at the {% cycle %} template tag. It's designed for precisely  
>>>>> this
>>>>> purpose.
>>>>> 
>>>> Thank you. But can someone show me how to make 'cycle' work?
>>>>
>>>> from django.template import Context, Template
>>>> items = (0, 1, 2, 3, 4, 5)
>>>> mycycle = ("one", "two", "three")
>>>> t = Template("""
>>>>  {% for item in items %}
>>>>  {% cycle mycycle %}
>>>>  {% endfor %}
>>>> """)
>>>> t.render(Context({ "items": items, "mycycle": mycycle }))
>>>>   
>>> Put in your template:
>>>
>>> {% for item in items %}
>>> http://nedbatchelder.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: Optimistic Locking

2008-02-04 Thread Michael Hipp

Tim Sawyer wrote:
> On Sunday 03 Feb 2008, code_berzerker wrote:
>> How about rewriting save method complately and make additional
>> condition in WHERE clausule like this:
>> UPDATE ... WHERE id=666 AND mtime=object_mtime
>> Checking number of updated rows would give you information about
>> success and would guarantee that there is no data manipulation between
>> mtime check and save.
> 
> If you're going to do that, then couldn't we change the framework to add a 
> new 
> VersionField.  If there is a VersionField defined on the object, then the 
> code on save could automatically be added.  This VersionField would simply 
> hold a version number for the record, that is incremented at save.  This is a 
> similar idea to the date thing, but slightly more robust - in a high traffic 
> environment there is a theoretical (albeit small) possibility of two objects 
> picking up the same time.
> 
> This is how hibernate recommends that you do it.  I saw someone suggesting 
> this method on this mailing list (found it with a web search I did when I 
> first started looking at django), this sounds like the optimum solution for 
> optimistic locking to me, and it would open up more use cases for django, at 
> least for me.
> 
> Would this be straightforward to add?

I'd love to see something like this added.

Can it be done entirely in SQL or does it require some stored triggers 
or rules in the database?

Thanks,
Michael


--~--~-~--~~~---~--~~
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: Tool recommendations

2008-02-04 Thread Michael Hipp

Peter Rowell wrote:
>> I have some ideas for AJAXy web sites, and I'm thinking of
>> implementing them in my spare time, but I don't know what tools
>> to learn and use.

> Another suggestion is jQuery as a JS framework (light and very
> featureful) and the excellent taconite plugin. Those two, combined
> with a trivial Django support class I wrote for taconite, make AJAX
> about as straight forward as you could possibly ask for.

Any chance you could share that with us?

I'm beginning to read up on jQuery and it looks promising. But any 
leg-up would help.

Thanks,
Michael

--~--~-~--~~~---~--~~
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: template: how to make use of forloop.counter0

2008-02-04 Thread Michael Hipp

David Reynolds wrote:
> 
> On 3 Feb 2008, at 3:32 pm, Michael Hipp wrote:
> 
>> Malcolm Tredinnick wrote:
>>>> Or is there some other way to get at my 'align' list?
>>> Look at the {% cycle %} template tag. It's designed for precisely  
>>> this
>>> purpose.
>> Thank you. But can someone show me how to make 'cycle' work?
>>
>> from django.template import Context, Template
>> items = (0, 1, 2, 3, 4, 5)
>> mycycle = ("one", "two", "three")
>> t = Template("""
>>  {% for item in items %}
>>  {% cycle mycycle %}
>>  {% endfor %}
>> """)
>> t.render(Context({ "items": items, "mycycle": mycycle }))
> 
> 
> Put in your template:
> 
> {% for item in items %}
>   http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unknown encoding: cp0 (apache, mod_python)

2008-02-03 Thread Michael Hipp

Karen Tracey wrote:
> On Feb 2, 2008 8:14 PM, Michael Hipp <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> 
> My code runs fine on the development server, but dies on a local copy of
> apache with mod_python.
> 
> It's giving me this error:
> unknown encoding: cp0
> 
> On this line:
> print 'report: %s' % report_name
> 
> Google found several references to making everything unicode (see
> below), so I tried this:
> print u'report: %s' % unicode(report_name)
> 
> But it still fails the same.
> 
> I'm running the latest from SVN on W2k with Apache 2.2.8, mod_python
> 3.3.1 and Python 2.5.1.
> 
> Any ideas?
> 
> Thanks,
> Michael
> 
> http://code.djangoproject.com/ticket/5584
> 
> http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist
> 
> 
> This thread:
> 
> http://groups.google.com/group/django-users/browse_thread/thread/f995ff5ddae2cd51
> 
> reports the same error message on a print statement and the fix in that 
> case was to wrap the variable in str(), not unicode(), though it doesn't 
> seem the problem/fix was well understood there.  I'm guessing (which I 
> probably shouldn't do at 1AM) but I think the problem is Windows is 
> returning something to Python that makes Python think unicode strings 
> must be converted to "cp0" in order to be displayed on the console, but 
> Python has no idea what "cp0" is, so generates an error.  If you wrap 
> the variable in str() before you print it then you sidestep the issue of 
> what codepage needs to be used for console printing of unicode strings.  
> I think,  maybe.  Anyway, it's worth a try.

Thanks. That works.

 print 'report: %s' % str(report_name)

It's evidently an Apache-Windows thing. I don't see the problem either 
on the Windows development server or an Apache server on RHEL.

Michael

--~--~-~--~~~---~--~~
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: template: how to make use of forloop.counter0

2008-02-03 Thread Michael Hipp

Malcolm Tredinnick wrote:
>> Or is there some other way to get at my 'align' list?
> 
> Look at the {% cycle %} template tag. It's designed for precisely this
> purpose.

Thank you. But can someone show me how to make 'cycle' work?

from django.template import Context, Template
items = (0, 1, 2, 3, 4, 5)
mycycle = ("one", "two", "three")
t = Template("""
 {% for item in items %}
 {% cycle mycycle %}
 {% endfor %}
""")
t.render(Context({ "items": items, "mycycle": mycycle }))

It works great if I replace 'mycycle' with hardcoded values, but as soon as I 
try to supply it as a list from context it fails.

Any help?

Thanks,
Michael

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



template: how to make use of forloop.counter0

2008-02-02 Thread Michael Hipp

I'm trying to do something in a template that seems really simple ... 
populate the row/columns of a table and apply alignment for each field. 
  So I'm doing this:

 {% for row in report_data %}
 
   {% for col in row %}
 
 {{ col }}
 
   {% endfor %}
 
 {% endfor %}

I'm trying to use the 'forloop.counter0' to get at which column I'm 
currently populating so I can apply the appropriate alignment according 
to the list contained in align.  Align is a tuple of alignments:

   align = ("Center", "Right", "Left", "Center")

So how does one actually make use of the forloop.counter0 variable?

Or is there some other way to get at my 'align' list?

Thanks,
Michael

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



unknown encoding: cp0 (apache, mod_python)

2008-02-02 Thread Michael Hipp

My code runs fine on the development server, but dies on a local copy of 
apache with mod_python.

It's giving me this error:
 unknown encoding: cp0

On this line:
 print 'report: %s' % report_name

Google found several references to making everything unicode (see 
below), so I tried this:
 print u'report: %s' % unicode(report_name)

But it still fails the same.

I'm running the latest from SVN on W2k with Apache 2.2.8, mod_python 
3.3.1 and Python 2.5.1.

Any ideas?

Thanks,
Michael

http://code.djangoproject.com/ticket/5584
http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist

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



Template help, gotta be simple

2008-02-02 Thread Michael Hipp

I'm trying to do something with a template that I thought would be very 
simple but I've not yet found a way to make it work at all.

from django.template import Template, Context
fields = ("f1", "f3")
data = [
 {"f1": "Foo", "f2": "Skip  ","f3": "Bar"},
 {"f1": "Cat", "f2": "Ignore","f3": "Dog"},
 {"f1": "Him", "f2": "Avoid ","f3": "Her"},
]
t = Template("""
 {% for row in data %}
 {% for f in fields %}
 {{ row.f }}
 {% endfor %}
 {% endfor %}
  """)
print t.render(Context({'fields': fields, 'data': data}))

I want to print out the data items row-by-row but skipping 'f2' since 
it's not listed in 'fields'. The above is how it seems like it ought to 
work, but it just ignores me. Lots of other crazy permutations didn't 
work either.

Can someone show me what (very simple) thing I'm missing?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Heads-down transaction-processing apps on Django

2008-02-02 Thread Michael Hipp

Tim Chase wrote:
>>> try to use control+W to delete the previous word while I'm typing
>>> in IE, only to have it close my whole window.  Minutes of sotto
>>> voce oaths usually follow.
>> Ug. This would be disastrous to a clerk on a tight queue. In the very 
>> least it looks like I may have to make Firefox a requirement as there 
>> appear to be fewer push-here-to-explode opportunities.
> 
> The best way to prevent this is to make AJAX'y submissions in the
> background as they work, basically writing the application
> interface in JavaScript.  It's an ugly job to code, but it can
> help save page-fulls of lossage.  FireFox has similar behavior
> with control+W, but I believe if it's something you really want
> to prevent, you can bind it to a NOP to prevent it from
> occurring.  I've not gone hacking FF configs/chrome to such a degree.

That's probably way more JavaScript than I'm likely to do anytime soon 
but it's good to know that such techniques can be made to work.

>> Would that be ReportLab perchance? Print solutions in Python seems to be 
>> a scarce species. I've used ReportLab with mixed success. If you know of 
>> another one to look at I'd sure be eager.
> 
> A short dig in the c.p.l archives found the link I had seen:
> 
> http://wiki.wxpython.org/Printing
> 
> Again, that was for printing to a printer attached to the server,
> rather than a printer attached to the web-client.

Ok. I've done printing from the two methods described in wxPython. The 
HTML variety is good for very simple cases but quickly runs out of power 
even long before full HTML would. The full wxPrint is a bit like coding 
in Assembler and has some bugs.

> Another option is to send the direct PCL yourself.  I've
> hand-cranked printer drivers for a couple thermal printers (Zebra
> and Oneil) that had some basic page-layout functions that I could
> use.  I just sent the printer-specific codes over the wire (IrDA,
> BlueTooth serial-profile, or serial-port in case) for fast and
> simple printing.  If you just need a text dump that you can do
> via simple escape codes, this isn't a bad way to go.  A bit of a
> pain to decipher printer manuals to get those codes...but
> feasible.  At least for those two printers, the PCL is pretty
> straight-forward and well documented.

Yes. This is really easy for stuff like Zebra printers. Hadn't thought 
of it for the bigger ones needing lots of PCL but it could be done 
easily enough with a little work to abstract some of the basic drawing.

Thanks,
Michael


--~--~-~--~~~---~--~~
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: Heads-down transaction-processing apps on Django

2008-02-02 Thread Michael Hipp

Jon Atkinson wrote:
 - Data entry people use lots of F-keys, Ctrl-keys and Alt-keys to make
 things happen on the screen.
>>> Not quite as much flexibility here.  HTML defines accelerator
>>> keys which are browser-specific (sometimes Alt+letter, sometimes
>>> control+letter, or other combos).
>> This is perhaps the only disappointing news from your experiences.
>>
>>> As a vi/vim user, my fingers occasionally
>>> try to use control+W to delete the previous word while I'm typing
>>> in IE, only to have it close my whole window.  Minutes of sotto
>>> voce oaths usually follow.
>> Ug. This would be disastrous to a clerk on a tight queue. In the very
>> least it looks like I may have to make Firefox a requirement as there
>> appear to be fewer push-here-to-explode opportunities.
> 
> Depending on how much control you have over your deployment, remember
> that is it pretty much trivial to modify the Firefox XUL files which
> define the keyboard shortcuts browser-wide. Turning off certain
> shortcut combinations would take a few minutes at the most, once ou
> knew where to look. Then just distribute the XUL files to the clients
> (I think you do it via Firefox profiles, so you would have a profile
> on each client called 'Data Entry' or similar).

Thanks, that's an excellent idea. And could be readily implemented only 
for the stations that really need it.

Michael

--~--~-~--~~~---~--~~
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: Heads-down transaction-processing apps on Django

2008-02-01 Thread Michael Hipp

Tim Chase wrote:

Tim, thanks for taking time to respond in so much depth. You've given me
enough encouragement to think we can move forward.

I'm *really* tired of thick-client GUI development.

>> - Data entry people use lots of F-keys, Ctrl-keys and Alt-keys to make 
>> things happen on the screen.
> 
> Not quite as much flexibility here.  HTML defines accelerator
> keys which are browser-specific (sometimes Alt+letter, sometimes
> control+letter, or other combos).

This is perhaps the only disappointing news from your experiences.

> As a vi/vim user, my fingers occasionally
> try to use control+W to delete the previous word while I'm typing
> in IE, only to have it close my whole window.  Minutes of sotto
> voce oaths usually follow.

Ug. This would be disastrous to a clerk on a tight queue. In the very 
least it looks like I may have to make Firefox a requirement as there 
appear to be fewer push-here-to-explode opportunities.

>> - Printouts need precise on-paper placement and instant delivery (no 
>> pop-ups to select printer or preview).
> 
> printing from the web is a peculiar issue.  If you're printing to
> a local printer (attached/accessible to the browsing machine),
> you pretty much always have to go through a print dialog.  If the
> printer is attached to the web-server, you have more control over
> the immediacy of printing.  You'd have to use a python printing
> module (there was a recent post on comp.lang.python on this that
> pointed at a popular library, though I don't have it on hand).

Would that be ReportLab perchance? Print solutions in Python seems to be 
a scarce species. I've used ReportLab with mixed success. If you know of 
another one to look at I'd sure be eager.

> Django+Python+JavaScript can handle most of the requirements.
> Demand-printing on the web-client is the largest hurdle.  And as
> a web-user, I'd want it that way, as I wouldn't want arbitrary
> websites to be able to send stuff to my printer unsolicited
> without giving me an option to cancel.
> 
> Hope my time in the trenches on the above gives you some pointers.

Yes. Yes it does. Thanks.

Michael

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



Heads-down transaction-processing apps on Django

2008-02-01 Thread Michael Hipp

Sorry for posting such a nebulous question...

Is anyone using Django web apps as heads-down transaction processing 
applications that are heavy in the areas of:

  - Lots of data entry
  - Lots of "instant, right now" demands like POS

A few - slightly more specific - issues:

- What about data entry into a web form. Data entry people use 'Enter' 
to move between fields, not Tab. And they won't touch a mouse.
- Data entry people use lots of F-keys, Ctrl-keys and Alt-keys to make 
things happen on the screen.
- Screens need to save and return *fast*. Instantaneous response is 
expected.
- Printouts need precise on-paper placement and instant delivery (no 
pop-ups to select printer or preview).
- Screens are dense with lots of tightly-packed fields.
- There may be requirements to interface with barcode scanners and 
magstripe scanners (probably USB connected). Is it possible to integrate 
these with a web app.

Is anyone running apps like this?
Can the above issues be dealt-with?
Can a browser provide the right kind of UI for these demanding but 
unexciting applications?

Any insight appreciated,
Michael

--~--~-~--~~~---~--~~
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: Simultaneous edits

2008-02-01 Thread Michael Hipp

Filip,

Thanks for your very informative explanations and ideas. I will be 
studying it closely.

Thanks,
Michael

Filip Wasilewski wrote:
> Hi Michael,
> 
> On Jan 30, 6:25 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> James Bennett wrote:
>>> On Jan 30, 2008 9:18 AM, Michael Hipp <[EMAIL PROTECTED]> wrote:
>>>> Does Django have any built-in way to handle or prevent simultaneous,
>>>> incompatible edits to a database record?
>>> No, that's what your database's concurrency handling is for.
>> Ok, I probably didn't explain well enough...
>>
>> I'm using PostgreSQL so concurrency isn't a problem.
>>
>> What is a problem is that user A loads a record and begins making changes.
>> Then user B loads the same record and begins making different changes. One of
>> them saves it first followed by the other and the only trace that's left is
>> what was saved by the one that got there last.
>>
>> No real issue at the database level. PG doesn't care. But possibly a very big
>> issue at the application level (especially if each of the saves also modified
>> related tables based on the different inputs of each user) and the 
>> application
>> level of each could not know about the other so opportunities to prevent this
>> disaster are few at the app level.
> 
> The way in which you handle the application-level transactions that
> span across a set of requests it entirely up to you :-) Thinking of
> typical scenarios you could either synchronize data in real time
> (something like google docs), synchronize on save (some kind of diff
> and merge), warn users before they start editing a record which is
> already opened for edit by another user (like in MoinMoin) or just
> overwrite or ignore changes (like in all bad-user-experience-apps).
> 
> 
> The third option seems quite reasonable and its also not very hard to
> implement. All what you will need is a (generic) registry that will
> hold information about checked out objects (rows, records, documents -
> whatever the naming convention is) and some locking logic.
> 
> The registry could be simply a model with three fields: [generic]
> model foreign key, user foreign key, and a checkout time, with unique
> constraint on the model foreign key. If you don't need to track
> different models then a "classic" foreign key instead of a generic
> contenttypes one should be just fine.
> 
> The functions that will provide a locking interface should be atomic
> (that's the place where the database level transactions come into
> play). A typical pattern is to have at least an acquire (lock) and a
> release (unlock) routines, plus a couple of additional helpers for the
> typical use cases:
> 
> * acquire_lock(object, user) - creates an entry/replaces expired one
> in the registry, allows for re-entrant locking (the same lock can be
> obtained many times by the user that already possess it without
> raising an error), raises an exception if an object is already locked
> by another user and the lock period hasn't expired.
> 
> * release_lock(object, user) - removes lock from the registry
> 
> * is_locked(object, user) - checks if a valid object lock entry exists
> 
> Cyclic removal of expired entries from the registry should not be
> necessary unless you count for every byte or need to reduce number of
> queries (in a typical case they will consume considerably less space
> than the other models' data).
> 
> After setting this up you should have a pretty robust mechanism for
> controlling parallel access attempts to database records/objects. Just
> lock the object on edit, release the lock on save and issue a warning
> on concurrent edit attempts.
> 
>> I've seen some table layouts that included a column like "last_edit_serial" 
>> so
>> that a steadily incrementing serial could provide a hint to the app level 
>> that
>> something had changed since the record was loaded.
> 
> Only when you want to notify someone that his effort has just been
> cancelled because someone else has corrected a typo in the meantime
> and saving changes is not permitted ;-)
> 
>> But I don't see Django adding any such columns and was wondering if a
>> different mechanism was in effect. Or if some other technique was widely used
>> among Django users.
> 
> What makes me wonder even more is the fact how fantastically people
> seem to get away without all this stuff :-)
> 
> 
> Hope that helps,
> 
> f
> 
> --
> http://filipwasilewski.pl
> 
> > 


--~--~-~--~~~---~--~~
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: Simultaneous edits

2008-01-31 Thread Michael Hipp

Thomas Guettler wrote:
> Am Mittwoch, 30. Januar 2008 16:18 schrieb Michael Hipp:
>> Does Django have any built-in way to handle or prevent simultaneous,
>> incompatible edits to a database record?
> 
> 
> Some days ago there was a thread about optimistic locking:
> I wrote an second answer some minutes ago.
> 
> http://groups.google.com/group/django-users/browse_thread/thread/e9db1349014aa1f4

Thank you. I'm moving my questions to that thread.

Michael

--~--~-~--~~~---~--~~
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: Optimistic Locking

2008-01-31 Thread Michael Hipp

Thomas Guettler wrote:
> Am Donnerstag, 24. Januar 2008 13:08 schrieb Tim Sawyer:
>> Hi Folks,
>>
>> I'm just evaluating django for use on a project.  I have a multiuser
>> application where many users can be changing data at once.
>>
>> What's the status of hibernate style optimistic locking, where each object
>> has a version and update/deletes are prevented if the last saved version of
>> that object is newer than the one being saved?
> 
> Hi,
> 
> I use this solution:
> 
> The model class has an field mtime which get's updated automatically:
> 
> class MyObject(models.Model):
> mtime=models.DateTimeField(verbose_name=u'Letzte Änderung am',
>editable=False, auto_now=True)
> 
> 
> def mtime_has_changed(self, request):
> mtime=request.POST['mtime']
> mtime=datetime.datetime(*[int(i) for i in re.findall(r'[\d]+', 
> mtime)])
> return self.mtime!=mtime

Could you explain how this works, please?

It looks - to my uneducated eyes - if this leaves open a potential race 
condition where the mtime field could yet be changed in the database by 
another process within the "decision time" of this method. Do I 
misunderstand? It seems to me that this can only be reliably caught by 
the database itself (probably using a rule or trigger).

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Simultaneous edits

2008-01-30 Thread Michael Hipp

James Bennett wrote:
> On Jan 30, 2008 9:18 AM, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Does Django have any built-in way to handle or prevent simultaneous,
>> incompatible edits to a database record?
> 
> No, that's what your database's concurrency handling is for.

Ok, I probably didn't explain well enough...

I'm using PostgreSQL so concurrency isn't a problem.

What is a problem is that user A loads a record and begins making changes. 
Then user B loads the same record and begins making different changes. One of 
them saves it first followed by the other and the only trace that's left is 
what was saved by the one that got there last.

No real issue at the database level. PG doesn't care. But possibly a very big 
issue at the application level (especially if each of the saves also modified 
related tables based on the different inputs of each user) and the application 
level of each could not know about the other so opportunities to prevent this 
disaster are few at the app level.

I've seen some table layouts that included a column like "last_edit_serial" so 
that a steadily incrementing serial could provide a hint to the app level that 
something had changed since the record was loaded.

But I don't see Django adding any such columns and was wondering if a 
different mechanism was in effect. Or if some other technique was widely used 
among Django users.

Any help or ideas appreciated.

Thanks,
Michael


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



Simultaneous edits

2008-01-30 Thread Michael Hipp

Does Django have any built-in way to handle or prevent simultaneous, 
incompatible edits to a database record?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Administration site is plain

2008-01-28 Thread Michael Hipp

Thanks, Bill and Alex. A simple symlink did the trick.

Thanks,
Michael

[EMAIL PROTECTED] wrote:
> It is probably looking for 404.html because it can't find the css
> files, and therefore is returning a 404 for them.  Have you followed
> these instructions: 
> http://www.djangoproject.com/documentation/modpython/#serving-the-admin-files
> 
> On Jan 28, 4:48 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Running on my local development server the Administration site looks
>> normal with the nice colors and formatting.
>>
>> Running on my production server it is utterly plain (black and white).
>> It's evidently not picking up some css or templates or something.
>>
>> I don't see anything helpful in the apache log other than it can't find
>> 404.html but I don't know why it would be looking for that. Setting
>> DEBUG=True didn't show anything either.
>>
>> Anyone know how to fix this?
>>
>> Thanks,
>> Michael
> > 


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



Administration site is plain

2008-01-28 Thread Michael Hipp

Running on my local development server the Administration site looks 
normal with the nice colors and formatting.

Running on my production server it is utterly plain (black and white). 
It's evidently not picking up some css or templates or something.

I don't see anything helpful in the apache log other than it can't find 
404.html but I don't know why it would be looking for that. Setting 
DEBUG=True didn't show anything either.

Anyone know how to fix this?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Model: field for HTML

2008-01-25 Thread Michael Hipp

Rajesh Dhawan wrote:
> 
> 
> On Jan 25, 11:57 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> When creating a field that will hold HTML snippets, should it be created
>> as a CharField or an XMLField (or something else)?
> 
> Either of those would work. The XMLField would require you to
> guarantee that the HTML snippet is valid XML. I would recommend a
> TextField:
> 
> http://www.djangoproject.com/documentation/model-api/#textfield

Thanks. That works better especially as it doesn't require a max_length 
parameter.

Michael

--~--~-~--~~~---~--~~
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: field for HTML

2008-01-25 Thread Michael Hipp

When creating a field that will hold HTML snippets, should it be created 
as a CharField or an XMLField (or something else)?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-14 Thread Michael Hipp

Yes. I finally did get it to work. But my issues weren't database 
related. Turned out to be something fairly simple with .htaccess as I 
suspected. (I'm not even up to the point of database access yet. And 
I'll be using PostgreSQL as that's what I know.)

Michael



Ralf wrote:
> Did you get your Django site to work? What database are you using?
> 
> I'm also trying to get Django to work on hostmonster.com, but I'm
> having trouble with the MySQL backend, it doesn't seem to be
> installed.
> 
> I tried manually installing it (copying files), but I get this error:
> 
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/flup/server/fcgi_base.py", line 558, in run
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: protocolStatus,
> appStatus = self.server.handler(self)
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/flup/server/fcgi_base.py", line 1116, in handler
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: result =
> self.application(environ, start_response)
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/core/handlers/wsgi.py", line 184, in __call__
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr:
> self.load_middleware()
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/core/handlers/base.py", line 29, in
> load_middleware
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: mod =
> __import__(mw_module, {}, {}, [''])
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/contrib/sessions/middleware.py", line 2, in ?
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: from
> django.contrib.sessions.models import Session
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/contrib/sessions/models.py", line 3, in ?
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: from django.db
> import models
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/db/__init__.py", line 11, in ?
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: backend =
> __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE,
> {}, {}, [''])
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: File "/home/
> tourista/python/django/db/backends/mysql/base.py", line 12, in ?
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr: raise
> ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
> [Mon Jan 14 03:17:20 2008] [warn] mod_fcgid: stderr:
> ImproperlyConfigured: Error loading MySQLdb module: /home/tourista/
> python/_mysql.so: cannot open shared object file: No such file or
> director
> 
> I guess I'll need to recompile from source on the server, but I don't
> have ssh access yet.
> 
> Ralf
> 
> 
> On Jan 8, 8:32 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Michael Hipp wrote:
>>> Hello,
>>> I'm hoping to rework my website into Django, but am having trouble at my
>>> shared hosting provider (HostMonster).
>>> They don't support mod_python, so Hostmonster said to add this to .htaccess
>>> for FastCGI:
>>>AddHandler fcgid-script .fcgi
>>> I did that and my html sites still work, but when I add the recommendations
>>> from Django my html sites don't work and neither does my fledgling Django 
>>> site.
>>>AddHandler fastcgi-script .fcgi
>>>RewriteEngine On
>>>RewriteCond %{REQUEST_FILENAME} !-f
>>>RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
>>> I also did the mysite.fcgi file. My Django site just returns blank pages. 
>>> The
>>> html sites get an 'Internal Server Error'.
>> Thanks to help from this list the Django site is now funcitonal. But the
>>   old html sites still return Internal Server Errors.  Here's what in
>> the logs:
>>
>> [Mon Jan 07 23:28:15 2008] [error] [client 75.116.4.1] Request exceeded
>> the limit of 10 internal redirects due to probable configuration error.
>> Use 'LimitInternalRecursion' to increase the limit if necessary. Use
>> 'LogLevel debug' to get a backtrace.
>>
>> I assume this is a function of the .htaccess file. How do I get it to
>> route around django for the html sites?
>>
>> Thanks,
>> Michael
> > 


--~--~-~--~~~---~--~~
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: Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Michael Hipp wrote:
> Graham Dumpleton wrote:
>> On Jan 11, 1:13 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>>> Graham Dumpleton wrote:
>>>> On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>>>>> Hello,
>>>>> My "main" Django site is working great. But on my shared hosting account
>>>>> (HostMonster) I have multiple sites. Some will be Django, some will be
>>>>> plain html.
>>>>> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>>>>> I'm using FastCGI and a script for the main site. I only have access to
>>>>> .htaccess.
>>>>> Currently the html sub-pages work fine on the other sites, but not the
>>>>> main page. Apache logs this:
>>>>> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
>>>>> exceeded the limit of 10 internal redirects due to probable
>>>>> configuration error. Use 'LimitInternalRecursion' to increase the limit
>>>>> if necessary. Use 'LogLevel debug' to get a backtrace.
>>>>> Can someone help me get started down the right path on this?
>>>> Looks like your rewrite rule for making a .fcgi script appear as being
>>>> mounted at root of site is not correct. Post your complete .htaccess
>>>> file showing all parts of the directives related to rewrite rule.
>>> It's pretty much verbatim from the Django docs, but I don't know if such was
>>> intended for multi-site installations:
>>>
>>> AddHandler fcgid-script .fcgi
>>> RewriteEngine On
>>> RewriteCond %{REQUEST_FILENAME} !-f
>>> RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]
>> What happens if you replace the last line with:
>>
>>   RewriteRule ^(.*)$ /some/url/redmule.fcgi/$1 [QSA,PT,L]
>>
>> Where '/some/url/redmule.fcgi' is actually the real URL that you would
>> use to access that fcgi script directly if you were doing it from the
>> browser (excluding the http://host bit of course).
>>
>> I have seen problems where using just the basename of the .fcgi script
>> in a .htaccess file doesn't work and full URL is required instead.
> 
> If I understood correctly, I tried it with just this as the .fcgi script is 
> located in my document root (alongside the old index.html file).
> 
>RewriteRule ^(.*)$ /redmule.fcgi/$1 [QSA,PT,L]

Forgot to add that this didn't make any discernible change.

Michael

--~--~-~--~~~---~--~~
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: Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Graham Dumpleton wrote:
> On Jan 11, 1:13 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Graham Dumpleton wrote:
>>> On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>>>> Hello,
>>>> My "main" Django site is working great. But on my shared hosting account
>>>> (HostMonster) I have multiple sites. Some will be Django, some will be
>>>> plain html.
>>>> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>>>> I'm using FastCGI and a script for the main site. I only have access to
>>>> .htaccess.
>>>> Currently the html sub-pages work fine on the other sites, but not the
>>>> main page. Apache logs this:
>>>> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
>>>> exceeded the limit of 10 internal redirects due to probable
>>>> configuration error. Use 'LimitInternalRecursion' to increase the limit
>>>> if necessary. Use 'LogLevel debug' to get a backtrace.
>>>> Can someone help me get started down the right path on this?
>>> Looks like your rewrite rule for making a .fcgi script appear as being
>>> mounted at root of site is not correct. Post your complete .htaccess
>>> file showing all parts of the directives related to rewrite rule.
>> It's pretty much verbatim from the Django docs, but I don't know if such was
>> intended for multi-site installations:
>>
>> AddHandler fcgid-script .fcgi
>> RewriteEngine On
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]
> 
> What happens if you replace the last line with:
> 
>   RewriteRule ^(.*)$ /some/url/redmule.fcgi/$1 [QSA,PT,L]
> 
> Where '/some/url/redmule.fcgi' is actually the real URL that you would
> use to access that fcgi script directly if you were doing it from the
> browser (excluding the http://host bit of course).
> 
> I have seen problems where using just the basename of the .fcgi script
> in a .htaccess file doesn't work and full URL is required instead.

If I understood correctly, I tried it with just this as the .fcgi script is 
located in my document root (alongside the old index.html file).

   RewriteRule ^(.*)$ /redmule.fcgi/$1 [QSA,PT,L]

Is that what you meant?

Should there be a separate 'mysite.fcgi' file for each site?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Graham Dumpleton wrote:
> On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> My "main" Django site is working great. But on my shared hosting account
>> (HostMonster) I have multiple sites. Some will be Django, some will be
>> plain html.
>>
>> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>>
>> I'm using FastCGI and a script for the main site. I only have access to
>> .htaccess.
>>
>> Currently the html sub-pages work fine on the other sites, but not the
>> main page. Apache logs this:
>>
>> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
>> exceeded the limit of 10 internal redirects due to probable
>> configuration error. Use 'LimitInternalRecursion' to increase the limit
>> if necessary. Use 'LogLevel debug' to get a backtrace.
>>
>> Can someone help me get started down the right path on this?
> 
> Looks like your rewrite rule for making a .fcgi script appear as being
> mounted at root of site is not correct. Post your complete .htaccess
> file showing all parts of the directives related to rewrite rule.

It's pretty much verbatim from the Django docs, but I don't know if such was 
intended for multi-site installations:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]

Thansk for any help,
Michael

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



Restart Django site?

2008-01-10 Thread Michael Hipp

How do I restart my Django site (uses FastCGI and shared hosting via 
.htaccess)?

The docs say 'touch mysite.fcgi' but that does not seem to work. Tried 
touching all the py files as well as .htaccess.

I can see the python process still running in memory. If I kill it then 
it re-loads my code and and I can see changes.

Note that changes to templates and other "data" files are immediately 
recognized but changes to code files (.py) are not (e.g. urls.py).

Michael

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



Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Hello,

My "main" Django site is working great. But on my shared hosting account 
(HostMonster) I have multiple sites. Some will be Django, some will be 
plain html.

How do I set this up (specifically in settings.py, urls.py and .htaccess).

I'm using FastCGI and a script for the main site. I only have access to 
.htaccess.

Currently the html sub-pages work fine on the other sites, but not the 
main page. Apache logs this:

[Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request 
exceeded the limit of 10 internal redirects due to probable 
configuration error. Use 'LimitInternalRecursion' to increase the limit 
if necessary. Use 'LogLevel debug' to get a backtrace.

Can someone help me get started down the right path on this?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Context processor a bit too helpful

2008-01-07 Thread Michael Hipp

Simon Willison wrote:
> On Jan 8, 6:47 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Learning about context processors, I have one like this:
>>
>> def bold_word(request):
>>  html = "A bold word."
>>  return {'bold_word': html,}
>>
>> I expected a *bold* word to show up in the browser, but instead here's
>> what is sent:
>>
>>A <b>bold</b> word.
>>
>> So the angle brackets show up (literally) in the browser.
>>
>> How do I say "no thanks" to this helpfulness so my html can to thru?
> 
> You can mark the string as "safe" in your context processor:
> 
> from django.utils.safestring import mark_safe
> 
> def bold_word(request):
>  html = mark_safe("A bold word.")
>  return {'bold_word': html,}

Thanks!

Michael

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



Context processor a bit too helpful

2008-01-07 Thread Michael Hipp

Learning about context processors, I have one like this:

def bold_word(request):
 html = "A bold word."
 return {'bold_word': html,}

I expected a *bold* word to show up in the browser, but instead here's 
what is sent:

   A bold word.

So the angle brackets show up (literally) in the browser.

How do I say "no thanks" to this helpfulness so my html can to thru?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-07 Thread Michael Hipp

Michael Hipp wrote:
> Hello,
> 
> I'm hoping to rework my website into Django, but am having trouble at my 
> shared hosting provider (HostMonster).
> 
> They don't support mod_python, so Hostmonster said to add this to .htaccess 
> for FastCGI:
> 
>AddHandler fcgid-script .fcgi
> 
> I did that and my html sites still work, but when I add the recommendations 
> from Django my html sites don't work and neither does my fledgling Django 
> site.
> 
>AddHandler fastcgi-script .fcgi
>RewriteEngine On
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
> 
> I also did the mysite.fcgi file. My Django site just returns blank pages. The 
> html sites get an 'Internal Server Error'.

Thanks to help from this list the Django site is now funcitonal. But the 
  old html sites still return Internal Server Errors.  Here's what in 
the logs:

[Mon Jan 07 23:28:15 2008] [error] [client 75.116.4.1] Request exceeded 
the limit of 10 internal redirects due to probable configuration error. 
Use 'LimitInternalRecursion' to increase the limit if necessary. Use 
'LogLevel debug' to get a backtrace.

I assume this is a function of the .htaccess file. How do I get it to 
route around django for the html sites?

Thanks,
Michael

--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-07 Thread Michael Hipp

That worked!

Thank you!  Thank you all!

Michael



Muchanic wrote:
> Try adding the .egg to sys.path explicitly, i.e.
> 
> sys.path.insert(0, "/home/redmulec/python/flup-1.0-py2.4.egg")

--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-07 Thread Michael Hipp

Graham Dumpleton wrote:
> On Jan 8, 2:29 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:

>> Does any of that offer any clues?
> 
> Not really. You really need to do what Milan said back at the
> beginning. See if you can get the actual error messages logged in the
> Apache error log files for the request, plus post your .fcgi file.

Well, I'm making progress. It's now giving me some error messages:

--
ERROR: No module named flup Unable to load the flup package. In order to 
run django as a FastCGI application, you will need to get flup from 
http://www.saddi.com/software/flup/ If you've already installed flup, 
then make sure you have it in your PYTHONPATH.
--

So I added some print statements
--
['/home/redmulec/djcode', '/home/redmulec/djtrunk', 
'/home/redmulec/python', '/home/redmulec/public_html', 
'/usr/lib64/python23.zip', '/usr/lib64/python2.3', 
'/usr/lib64/python2.3/plat-linux2', '/usr/lib64/python2.3/lib-tk', 
'/usr/lib64/python2.3/lib-dynload', 
'/usr/lib64/python2.3/site-packages', 
'/usr/lib64/python2.3/site-packages/gtk-2.0', 
'/usr/lib/python2.3/site-packages'] Traceback (most recent call last): 
File "redmule.fcgi", line 10, in ? import flup ImportError: No module 
named flup [Mon Jan 07 22:47:07 2008] [warn] (104)Connection reset by 
peer: mod_fcgid: read data from fastcgi server error. [Mon Jan 07 
22:47:07 2008] [error] [client 75.116.4.1] Premature end of script 
headers: redmule.fcgi [Mon Jan 07 22:47:07 2008] [error] [client 
75.116.4.1] suexec failure: could not open log file [Mon Jan 07 22:47:07 
2008] [error] [client 75.116.4.1] fopen: Permission denied [Mon Jan 07 
22:47:07 2008] [error] [client 75.116.4.1] Premature end of script 
headers: 500.php [Mon Jan 07 22:47:10 2008] [notice] mod_fcgid: process 
/home/redmulec/public_html/redmule.fcgi(16629) exit(communication 
error), terminated by calling exit(), return code: 1
--

So it's obvious something is fubar with flup. But from the command line 
it runs fine:

$ python
Python 2.4.3 (#1, Nov 15 2007, 14:40:32)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import flup
 >>>

Probably a PYTHONPATH problem. But it looks below as if my PYTHONPATH 
should be fine. I've installed flup in ~/python.

$ ls -lh ~/python
total 884K
-rwxr-xr-x  1 redmulec redmulec  286 Jan  7 22:15 easy_install
-rwxr-xr-x  1 redmulec redmulec  294 Jan  7 22:15 easy_install-2.4
-rw-rw-r--  1 redmulec redmulec  235 Jan  7 22:19 easy-install.pth
drwxrwxr-x  2 redmulec redmulec 4.0K Jan  6 09:56 eunuchs
-rw-rw-r--  1 redmulec redmulec 8.8K Sep  4 10:48 ez_setup.py
-rwxrwxr-x  1 redmulec redmulec 371K Jan  6 09:54 flup-1.0-py2.3.egg
-rw-rw-r--  1 redmulec redmulec 133K Jan  7 22:19 flup-1.0-py2.4.egg
drwxrwxr-x  4 redmulec redmulec 4.0K Jan  7 22:13 setuptools-0.6c6-py2.3.egg
-rw-rw-r--  1 redmulec redmulec 320K Jan  7 22:13 setuptools-0.6c7-py2.4.egg
-rw-rw-r--  1 redmulec redmulec   29 Jan  7 22:15 setuptools.pth
-rw-rw-r--  1 redmulec redmulec 2.4K Jan  6 09:48 site.py
-rw-rw-r--  1 redmulec redmulec 1.8K Jan  7 21:36 site.pyc




My .fcgi file:
--
#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/redmulec/python")
sys.path.insert(0, "/home/redmulec/djtrunk")
sys.path.insert(0, "/home/redmulec/djcode")

print sys.path
import flup

# Switch to the directory of your project. (Optional.)
os.chdir("/home/redmulec/djcode")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "redmule.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
--

How can I convince this thing that flup is indeed installed?

Is it because it's installed as an egg?

Thanks,
Michael



--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-07 Thread Michael Hipp

Graham Dumpleton wrote:
>>RewriteRule ^djangosite/(.*)$ mysite.fcgi/$1 [QSA,L]
>>
>> would only use the fcgi stuff on the urls that resolved to the
>> djangosite directory???
> 
> You cannot read the RewriteRule in isolation, the RewriteCond on the
> line before must be taken into consideration as well:
> 
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
> 
> The RewriteCond says that the RewriteRule should only be applied in
> the target of the URL couldn't be mapped as a static file.
> 
> One problem with the rule as shown is that it may not necessarily work
> on all cases. Can be a problem where done in a .htaccess file and that
> directory isn't the root of the site.
> 
> If the URL of the directory is /dangosite, use instead:
> 
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteRule ^(.*)$ /djangosite/mysite.fcgi/$1 [QSA,PT,L]
> 
> The PT flag should be optional because absolute path for redirect, but
> makes it clearer when trying to look through mod_rewrite
> documentation.
> 
> The question thus is, are you doing the rewrite rule in a .htaccess
> file or not? Is that the root of the site?

Thanks, Graham.

Yes, I'm doing it in .htaccess.

The root of the website (the nix system path) is: /home/mysite

The www stuff is stored at: /home/mysite/public_html

That's also where .htaccess and mysite.fcgi both live.

If I do that RewriteRule as

   RewriteRule ^(.*)$ /mysite.com/mysite.fcgi/$1 [QSA,PT,L]

I get an internal server error.

If I do it as /mysite.fcgi or /home/mysite/public_html/mysite.fcgi then 
it just returns a blank page.

Does any of that offer any clues?

Thanks,
Michael



--~--~-~--~~~---~--~~
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: Calling a method from the base template

2008-01-07 Thread Michael Hipp

Peter Rowell wrote:
>> There is a mechanism available
>> for that -- context processors -- but people don't want to use it
>> because they want *something else* that happens for every template.
> 
> Malcolm's absolutely correct: context processors (I mis-typed when I
> said content processors) is exactly what you want here. They are
> trivial to implement and they give you all of the global data you
> could want in a template. We have about a dozen different values that
> are available for each  of our pages and it is all done in one routine
> that is automatically called because it's in the list of
> TEMPLATE_CONTEXT_PROCESSORS and we use RequestContext for pretty much
> all of our views. Hey, it takes a request and returns a dict, How Hard
> Could It Be? (tm)
> 
> E.g. django.core.context_processors:
> 
> def media(request):
> return {'MEDIA_URL': settings.MEDIA_URL}
> 
> Put it in your TEMPLATE_CONTEXT_PROCESSORS  list and now all of your
> views have {{MEDIA_URL}} available to them.

Ok, I've learned enough to make this approach work and it is indeed easy.

But it has a small bit of inelegance...

Is it really necessary to complicate every 'view' method by appending 
'context_instance=RequestContext(request)' to the render_to_response 
call? This seems totally boilerplate and a violation of DRY.


>> That way lies madness (it's called PHP and ASP, amongst other nasty
>> names).
> 
> Amen.

Yes. That's why we're all here.

Thanks, Malcom and Peter!

Michael



--~--~-~--~~~---~--~~
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: Calling a method from the base template

2008-01-06 Thread Michael Hipp

Peter Rowell wrote:
> It
> would probably be better (for any number of reasons) if you put all of
> these types of routines in a utils.py module and import/pass that.
> E.g.
> 
> import utils
> return render_to_response('now.html', RequestContext(request,  {
> 'utils': utils,
> }} )
> 
> Then you can do {{utils.something}} and it will fill in with the
> output of the function.

Thanks. I can see how this would work. But it appears the return of every 
'view' method would have to be cluttered with this and that's sort-of what I'm 
specifically trying to avoid.

> I recommend rethinking how data is passed into and used in your
> templates. Consider creating your own content processor. Or maybe some
> custom template tags and/or filters.  See
> http://www.djangoproject.com/documentation/templates_python/ and
> djangobook.com for much more on these options.

I've been reading up on this option and it may be what I'm looking for. But it 
seems surprising that such an "advanced" feature would have to be called upon 
to do something that seems, to me, so common. But there's gotta be something 
I'm missing. (See below)

> If you need to do all kinds of mid-template computing (which Django
> templates are deliberately designed to discourage)

Could you elaborate please?

My web pages won't be so different, I think, than many others. Each page will 
have "main content" and "other stuff". The "other stuff" is not related to 
"main stuff" and therefore "main stuff" shouldn't know anything about them. 
But lots of the "other stuff" need to be created dynamically so I have to 
somehow invoke a method that does the job.

Is this what you're referring to as mid-template computing? What's the correct 
way?

I'm a noob and I've figured out using urls.py how you give control to a 
routine to produce the "main stuff" for a page, but I can't figure out how to 
invoke some other routine to create the "other stuff".

Clear as mud?

Thanks for any help,
Michael



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



Calling a method from the base template

2008-01-06 Thread Michael Hipp

This is probably really simple, but I'm not seeing it.

I have my base.html and sub.html templates. The method that services the sub 
template does it's job fine. But in the base template I have a piece of 
content that is independent of the sub template. I have a get_stuff() method 
in views.py to produce this content.

Attempting to do a method call {% views.get_stuff %} just results in a 'bad 
tag' error.

Doing it like a variable {{ views.get_stuff }} just seems to be ignored.

How is this done?

Thanks,
Michael


--~--~-~--~~~---~--~~
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: Shared hosting with FastCGI, problems

2008-01-06 Thread Michael Hipp

[EMAIL PROTECTED] wrote:
>>   AddHandler fastcgi-script .fcgi
> 
> Is this the actual name of your fcgi script? Also, there seems to be a
> space before ".fcgi", which doesn't seem right.

That line came directly from ...

   http://www.djangobook.com/en/1.0/chapter20/
   http://www.djangoproject.com/documentation/fastcgi/

It appears to be correct from what I've seen from several sources. (But what I 
know about Apache wouldn't fill a thimble.)

Thanks,
Michael

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



Shared hosting with FastCGI, problems

2008-01-05 Thread Michael Hipp

Hello,

I'm hoping to rework my website into Django, but am having trouble at my 
shared hosting provider (HostMonster).

They don't support mod_python, so Hostmonster said to add this to .htaccess 
for FastCGI:

   AddHandler fcgid-script .fcgi

I did that and my html sites still work, but when I add the recommendations 
from Django my html sites don't work and neither does my fledgling Django site.

   AddHandler fastcgi-script .fcgi
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

I also did the mysite.fcgi file. My Django site just returns blank pages. The 
html sites get an 'Internal Server Error'.

I'm pretty sure my Django code works as it's just the simple stuff from 
chapter 2 and 3 and it works on the development server.

Any help?

Thanks,
Michael

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



Web host for Django, what to ask for?

2005-12-31 Thread Michael Hipp


I'm hoping to convince my current hosting provider (zipa.com) to support 
Django. (Switching providers would be a pain right now.) What would I tell 
them I need?


apache
mod_python
psycopg
postgresql (or mysql) (1 database?)

Is there any chance of convincing them to modify their httpd.conf file for me 
as in http://www.djangoproject.com/documentation/modpython/ ?


Anything else I should ask for or any best way to pose the question?

Thanks,
Michael

P.S. Here are their shared hosting plans:
http://zipa.com/shared/index.php?group_id=192788&plan_id=&ln=1&all=1


Re: Multiple apps on one page, how?

2005-12-31 Thread Michael Hipp


Jacob Kaplan-Moss wrote:


On Dec 31, 2005, at 11:02 AM, Michael Hipp wrote:


How do I put multiple apps on one page/template?


Just use both apps in the same view::

from django.models.polls import polls
from django.models.blogs import entries

def my_view(request):
return render_to_response("template_name", {
"poll_list" : polls.get_list(),
"entry_list" : entries.get_list(),
}


Thanks. But isn't this going to violate the DRY principle?

I'm thinking of the example where I have things that I want to appear around 
the perimeter of every page on my site representing the output of numerous 
independent apps. This would seem to leave me with two choices:


1) Replicate the same code across a lot of different views in different apps.

2) Built a mega-view that is called for every url pattern in which it is 
decoded what was really requested and then calls the various views.


Neither of those sound like good options.

Any insight appreciated,
Michael




Re: A very simple application

2005-12-31 Thread Michael Hipp


Jacob Kaplan-Moss wrote:


On Dec 31, 2005, at 11:14 AM, Michael Hipp wrote:


How do I make this work?

In mysite/apps/simple/views.py I have:

  from django.core.extensions import render_to_response
  def saysomething(request):
assert False, "Test assert"
return render_to_response('base', {'message': "My message."})

The inclusion of the 'assert' line causes it to throw exception  
"TemplateDoesNotExist: 500" and no sign of the output from assert  
anywhere.



That's because you have DEBUG off, so Django is looking for a  template 
"500.html" to display a "nice" error message fit for public  
consumption.  If you turn DEBUG on, you'll see the assertion error.


Thank you. Didn't realize I had ever turned it off.

Michael


Method call in template, how?

2005-12-31 Thread Michael Hipp


In http://www.djangoproject.com/documentation/templates/#variables it says:

-
Behind the scenes
Technically, when the template system encounters a dot, it tries the following 
lookups, in this order:


* Dictionary lookup
* Attribute lookup
* Method call
* List-index lookup
-

This appears to say that it is possible to call a method directly from within 
a template. Exactly how does one do a method call this way, where would that 
method live, and what would such an animal look like?


Thanks,
Michael


Re: A very simple application

2005-12-31 Thread Michael Hipp


Adrian Holovaty wrote:

On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:

Thanks. What about the case where I need to get debugging output from deep in
a routine and no obvious (to me, at least) way to bubble it up into the web
browser?


A simple solution is to raise an exception at any point. It'll bubble
up to the Web browser as long as you have DEBUG=True. (If you have
DEBUG=False, Django will attempt to send an e-mail with the full
traceback to the people defined in the ADMINS setting.)

Personally I use "assert False" for this. For example, if I wanted to
see the value of variable foo, I'd do this:

assert False, foo


How do I make this work?

In mysite/apps/simple/views.py I have:

  from django.core.extensions import render_to_response
  def saysomething(request):
assert False, "Test assert"
return render_to_response('base', {'message': "My message."})

The inclusion of the 'assert' line causes it to throw exception 
"TemplateDoesNotExist: 500" and no sign of the output from assert anywhere.


Thanks,
Michael



Multiple apps on one page, how?

2005-12-31 Thread Michael Hipp


Still trying to get my brain around how Django works...

How do I put multiple apps on one page/template?

Explanation:
I have my base.html template, different parts of the page need to be fed data 
from different apps (app1, app2, etc.) The apps are independent and don't 
(shouldn't) know anything about one another. The template has blocks/variables 
to grab the data from each app.


Issue:
The urlpatterns all seem to be geared around a one-one (url->view) model. The 
associated template can inherit from others that have additional things on 
them but how do I get the views for those other apps to run?


Hope that made some sense.

Thanks,
Michael


Re: 'now' outputs in UTC

2005-12-31 Thread Michael Hipp


Eugene Lazutkin wrote:
The easiest way to handle it is to rely on native Windows time zone: do not 
set any time zone at all (django\conf\settings.py, line 64). I didn't try it 
but it should work.


In any case please file a ticket to track the problem.


Thanks for that tip. I did remove the TIME_ZONE setting and it now gives the 
correct local time, but the UTC offset still shows as wrong ('O' format string 
for 'now').


I have submitted a ticket:
  http://code.djangoproject.com/ticket/1149

Thanks,
Michael


'now' outputs in UTC

2005-12-30 Thread Michael Hipp


I'm playing with the following in my template:

  {% now "O Y-M-d H:i" %}

This renders: '+ 2005-Dec-31 06:03' which appears to be UTC (6 hours later 
than here in central time in the US).


This is on WinXP Pro and (according to Control Panel) my time zone appears to 
be set correctly. In settings.py I have TIME_ZONE = 'America/Chicago' which 
should be correct.


Is this expected behavior?

Thanks,
Michael


Re: A very simple application

2005-12-30 Thread Michael Hipp


James Bennett wrote:

Basically, render_to_response is a shortcut which takes the name of a
template and a dictionary, and instantiates a context from the
dictionary, loads the template, renders it and creates an HttpResponse
from the result.


Ok, if render_to_response is a shortcut, then I need to stop looking sideways 
at it.


Anyway, using the r_to_r as you and limodou suggested it is now happily 
putting things on the screen.


So I can move on to the whatever is the next thing I won't understand. :-)

Thanks for your help,
Michael


Re: A very simple application

2005-12-30 Thread Michael Hipp


limodou wrote:

HttpResponse just return the message to the caller, not directly to the screen.


Who/what is the caller?


render_to_response is a utility function provided by django, if you
don't want to use it, you can do it yourself, just like:


It's not that I have something against render_to_response, it's that all the 
tutorials and docs seem to be saying that the "correct" way is HttpResponse 
and my objective is to be consistent with the published materials. (Failing 
that, I'd like to understand why the app I'm trying to build requires a 
different approach than seemingly everything else.)


So is there an error in the tutorials in that HttpResponse won't, in fact, 
cause that string to appear on the screen? If it will do that, then what is 
required to make it happen?


I realize I'm missing something basic and fundamental so please forgive my 
ignorance.



template receives variable, and it should be invoked by views.


Ok, that's beginning to sink in somewhat. But in the tutorial example

  (myproject/apps/polls/views.py)
  def index(request):
return HttpResponse("Hello, world. You're at the poll index.")

what variable receives the "Hello, world" string?

Thanks for your patient help. Wish I could read your Chinese-language tutorial.

Michael


Re: A very simple application

2005-12-30 Thread Michael Hipp


Adrian Holovaty wrote:

On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:


But what about the "root" of the website, how do you specify a view for just
"mysite.com"?



To target the root, use '^$' as the regular expression, like so:

urlpatterns = patterns('',
(r'^$', 'path.to.my_view'),
)

Does this answer your question?


Yes. But I still seem to be off somewhere...

From http://www.djangoproject.com/documentation/tutorial3/#write-your-first-view
there is:
--
from django.utils.httpwrappers import HttpResponse

def index(request):
return HttpResponse("Hello, world. You're at the poll index.")

This is the simplest view possible. Go to "/polls/" in your browser, and you 
should see your text.

--

I don't know how to reconcile this with what James Bennett and limodou wrote 
about using render_to_response() instead of HttpResponse() as none of the 
examples in the docs use render_to_response() as their return value from the 
view method. So the advice seems contradictory to the docs.


The tutorial seems to be saying that anything returned from a view by way of 
the HttpResponse() call will be sent directly to the screen. And at another 
place is shows the url pattern to trap the correct url:

  (r'^polls/$', 'myproject.apps.polls.views.index')
Which seems a simple process of
  urlpattern -> view -> template -> screen

But I can't see in the tutorial example what is put in the template that will 
receive this "Hello, world..." output.


Thanks,
Michael


Re: A very simple application

2005-12-30 Thread Michael Hipp


James Bennett wrote:

On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:


I have a base.html that is a skeleton html document with this call to my
'simple' app added:

  {{ simple.saysomething }}



You never call the view function from inside the template; by the time
Django is rendering the template, the view code has already been
executed. What happens, roughly, is this:

1. A request comes in, and Django looks at the URLConf to see if it
matches any pattern there.
2. If it does, Django calls the view listed in the URLConf for that pattern.
3. The view code does whatever processing it needs, then generates a
context -- a dictionary of keys and values -- which it passes to a
template for rendering. The view code is responsible for determining
which template will be loaded and used.
4. The template renders using the values passed in the context.

So the template tag '{{ simple.saysomething }}' would expect the view
to have included in the context a key/value pair where 'simple' is the
value, and the key is an object with a 'saysomething' attribute.

Probably a better way of doing this would be:

def saysomething(request, message):
return render_to_response('base', {'message': message})

This takes in whatever value you want to pass as the message, and then
hands it off to the template 'base.html' as the variable 'message'.
And then in the template, just have '{{ message }}', which will render
the text.


I'm not sure I grasped the above. And it's possible I'm asking the question in 
the wrong way. So allow me to try again...


I'm trying to construct the simplest possible case of a single-page website 
with a single ultra-simple Django app inside that outputs something to the 
screen when viewed.


Per Adrian's earlier suggestion, I'm still using
  (r'.*', 'django.views.generic.simple.direct_to_template',
{'template': 'base'})
as my urlpattern.

Where I seem to be confused is that all the urlpattern examples in the docs 
all seem to be geared toward the "mysite.com/foo" where you give it a pattern 
to catch /foo and then specify a view like 'mysite.apps.foo.views.fooview'. 
But what about the "root" of the website, how do you specify a view for just 
"mysite.com"?


In other words, I have no unique url pattern to trap to send it to a view for 
my simple.saysomething app.


Did that make any sense at all? I'm feeling really dense right about now. 
Hopefully it is a temporary condition. :-)



Also, what is the best way to get debug output from Django? I tried a 'print'
statement in 'saysomething' but it seemed to go nowhere.



If you need to debug and see what output is actually getting to your
template, a simple way is to include, inside an HTML comment, a list
of any objects/variables you want to have access to in the template
and print out their names and values. For example, to test the above,
you might put this in your template:




Thanks. What about the case where I need to get debugging output from deep in 
a routine and no obvious (to me, at least) way to bubble it up into the web 
browser?


I'm grateful for your help.

Michael


Re: Really basic question...

2005-12-30 Thread Michael Hipp


Adrian Holovaty wrote:

On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:


Thank you! That worked great (well, once I figured out that TEMPLATE_DIRS
wants Unix-style "slashes" even on this Winders box.)



Ah, thanks for pointing out that the slash-style isn't well
documented. I've updated the docs:

http://www.djangoproject.com/documentation/templates_python/#the-template-dirs-setting
http://www.djangoproject.com/documentation/settings/#template-dirs


Excellent. A suggestion might be to have it added to the generated 
'settings.py' file which currently starts out like this:


TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
)

Perhaps add "# Always use Unix-style forward slashes, even on Windows."

Thanks. The more I see, the more I'm convinced Django is the item I've been 
looking for.


Michael



A very simple application

2005-12-30 Thread Michael Hipp


I have a base.html that is a skeleton html document with this call to my 
'simple' app added:


  {{ simple.saysomething }}

In mysite/apps/simple/views.py there is:

  from django.utils.httpwrappers import HttpResponse
  def saysomething(request):
return HttpResponse("This is from the 'simple' app.")

And settings.py has:
  INSTALLED_APPS = ("mysite.apps.simple",)

But there appears to be no output from "saysomething". What am I missing?

Also, what is the best way to get debug output from Django? I tried a 'print' 
statement in 'saysomething' but it seemed to go nowhere.


Thanks,
Michael


Re: Really basic question...

2005-12-30 Thread Michael Hipp


Adrian Holovaty wrote:

You'll want to use the "direct to template" generic view, documented here:
http://www.djangoproject.com/documentation/generic_views/#using-simple-generic-views

Here's the URLconf you'd use:

urlpatterns = patterns('',
(r'.*', 'django.views.generic.simple.direct_to_template',
{'template': 'base'}),
)

And you'd create a template "base.html" in the directory pointed-to by
your TEMPLATE_DIRS setting.

Let us know how it goes, and happy new year!


Thank you! That worked great (well, once I figured out that TEMPLATE_DIRS 
wants Unix-style "slashes" even on this Winders box.) Happy new year to you also!


Michael



Really basic question...

2005-12-30 Thread Michael Hipp


I'm trying to get Django to put up the most basic possible template/page which 
consists of nothing more than an html doc with essentially nothing in it, no 
apps, nothing that really requires the power of Django.


The tracebacks I'm getting seem to be alternately complaining about my 
templates and urlpatterns.  So, 2 questions:


1) What do I put in urls.py that is a basic "catch all" pattern?
   I tried:
 urlpatterns = patterns('',)
 urlpatterns = patterns('', (r'*', ''),)

2) How do I tell it to find my base.html in the mysite/templates directory?

Any help appreciated.

Michael


Re: Maybe the easiest tutorial

2005-12-30 Thread Michael Hipp


Jarek Zgoda wrote:

Looking forward to see. Here are my thoughts on current "official"
Django tutorial:




Anyway, it's god to see anybody working on introductory materials.


Thanks for the encouragement. I'm banging away on it now. Hopefully in a few 
days I'll have something to show.


Michael


Re: Maybe the easiest tutorial

2005-12-27 Thread Michael Hipp


Jarek Zgoda wrote:

Michael Hipp napisał(a):



Yea, this is the simplest "tutorial" one can imagine, but it wouldn't
help the beginners in any way, as it doesn't explain how Django works.
IMO, it's worthless.


Does such a tutorial exist?



The official tutorial explains Django internals at some extent. Some say
it's enough to start working with Django-based apps, but I would argue.
It is enough to start your Django app, but it soon renders unhelpful --
when you find your most valuable Django documentation are Django irc
logs. It's sick.


I agree. The official tutorial starts off well, but about 1/3 way thru the 
first page is ceases being a tutorial and seems to scatter in all directions 
never to return.


Alas, I'm thinking of writing one. If I ever figure it out, that is. Django 
looks great - a real gem. But being a Django newbie is not a particularly 
happy place.


Best regards,
Michael



Re: Maybe the easiest tutorial

2005-12-27 Thread Michael Hipp


Jarek Zgoda wrote:

Yea, this is the simplest "tutorial" one can imagine, but it wouldn't
help the beginners in any way, as it doesn't explain how Django works.
IMO, it's worthless.


Does such a tutorial exist?

Michael




Re: Django for eCommerce?

2005-12-21 Thread Michael Hipp


Jacob Kaplan-Moss wrote:


On Dec 21, 2005, at 10:24 AM, Michael Hipp wrote:

How suitable is Django for an eCommerce site (SSL, shopping cart,  
product database, accounts, etc.)?



Very well suited.


Thank you.

Could anyone elaborate - perhaps with pointers to docs or example code to 
implement some of the features?


Thanks,
Michael


Re: Django built-in web server?

2005-12-21 Thread Michael Hipp


Joseph Kocherhans wrote:
On 12/21/05, *Michael Hipp* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
wrote:



The documentation says "Django comes with its own Web server for
development
purposes." I'd like to use this for development and experimentation.
But I can
find nothing about where it lives or how to configure and run it.
Any pointers? 



You're probably looking for the django-admin.py runserver command. Check 
out http://www.djangoproject.com/documentation/tutorial2/ and search for 
"Start the development server"


Yes. I completely missed that. Thank you very much.

Michael


Django built-in web server?

2005-12-21 Thread Michael Hipp


The documentation says "Django comes with its own Web server for development 
purposes." I'd like to use this for development and experimentation. But I can 
find nothing about where it lives or how to configure and run it. Any pointers?


Thanks,
Michael


Django for eCommerce?

2005-12-21 Thread Michael Hipp


Hello, just trying to get started with Django. Question...

How suitable is Django for an eCommerce site (SSL, shopping cart, product 
database, accounts, etc.)?


Thank you,
Michael Hipp
Heber Springs, Arkansas, USA