Re: Why so slow?

2007-01-12 Thread David Abrahams

"Ramiro Morales" <[EMAIL PROTECTED]> writes:

> On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
>> [...]
>>
>> Most of my content is static in nature, generated on-demand from ReST
>> sources.  For those pages, the model checks the mod time of a
>> directory in the filesystem before deciding if the content in the
>> locmem cache is up-to-date.
>>
>
> Sorry but I don understand you here. Your content is static but
> generated on-demand from ReST?
>
> From what you have written your app is working like this:
>
> 1. your model checks the mdate of  the (directory containing the)
>ReST files and generating the (html?) content using the docutils
>tools.
>
> 2. Then you cache the newly generated content.

Yes.

> But is that caching implemented by writing the content to a disk cache
> (IMHO a recommended strategy in this case) 

Recommended by whom?

> or the locmem cache is the only one you are using?.

Only locmem.

> If you are using only the locmem cache you could be dealing with
> a scenario like this:
>
> Since the locmem cache storage is non persistent and if you have
> configured it so it the content is forgot after a certain period of
> time 

It's a very long period (like a week).

> this could be forcing the ReST -> html conversion to be redone not
> only when you run the app/site for the first time but also after a
> period of no use.
>
> Have you measured how much time it takes a rst2html invocation with your
> ReST documents?.
>
> Sorry for  making so many assumptions.
>
> Another idea: If you are using locmem caching, could this be
> consuming memory to the point of making your system start
> swapping heavily and be the cause of the slowness?.

I don't thinks so.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


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



Re: order_by with Foreign Keys

2007-01-12 Thread DavidA

I found this patch which fixes it. I've been using it for a while now:
http://code.djangoproject.com/ticket/2210

Honza Král wrote:
> this works fine, but if you forget the select_related() it will result
> in a cross join which is probably the last thing you want from your
> database...
>
> I was bitten by this when I specified this sort of ordering in the model...
>
> On 1/13/07, gordyt <[EMAIL PROTECTED]> wrote:
> >
> > Hi Carole,
> >
> > There is a workaround for this problem.  I am using the latest
> > subversion build of django, so I don't know if it works with the last
> > official build or not.
> >
> > Here is an example:
> >
> > ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number")
> >
> > Here are the model definitions:
> >
> > class ProductVersion(models.Model):
> > product=models.ForeignKey(Product)
> > version_number=models.CharField(maxlength=16)
> > availability_date=models.DateField(null=True,blank=True)
> > release_notes=models.TextField(blank=True)
> >
> > class Product(models.Model):
> > name=models.CharField(maxlength=128)
> >
> >
> > Note that kindledb_product is the name of the database table that
> > stores the information from the Product.
> >
> > --gordon
> >
> >
> > >
> >
>
>
> --
> Honza Král
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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: order_by with Foreign Keys

2007-01-12 Thread Honza Král
this works fine, but if you forget the select_related() it will result
in a cross join which is probably the last thing you want from your
database...

I was bitten by this when I specified this sort of ordering in the model...

On 1/13/07, gordyt <[EMAIL PROTECTED]> wrote:
>
> Hi Carole,
>
> There is a workaround for this problem.  I am using the latest
> subversion build of django, so I don't know if it works with the last
> official build or not.
>
> Here is an example:
>
> ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number")
>
> Here are the model definitions:
>
> class ProductVersion(models.Model):
> product=models.ForeignKey(Product)
> version_number=models.CharField(maxlength=16)
> availability_date=models.DateField(null=True,blank=True)
> release_notes=models.TextField(blank=True)
>
> class Product(models.Model):
> name=models.CharField(maxlength=128)
>
>
> Note that kindledb_product is the name of the database table that
> stores the information from the Product.
>
> --gordon
>
>
> >
>


-- 
Honza Král
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Re: Creating a "wizard"

2007-01-12 Thread Honza Král
have a look at ticket
http://code.djangoproject.com/ticket/3218

it contains a proposed wizard class for newforms - simply subclass it,
override the done() method and then instantiate it with a list of
newform classes...

if you need more functionality (dynamic forms etc.) you will have to
override more methods (process_step() )

if you have any questions/feature requests please ask away I am
desperate for some feedback... ;)

Honza

On 1/12/07, gordyt <[EMAIL PROTECTED]> wrote:
>
> Howdy Bram,
>
> Here is an example of something that I am doing with newforms and
> sessions and it seems to work very well.  In my case I have a search
> form displayed.  Depending upon the options that are selected by the
> user, when they submit the form it will be handled by one of several
> different view methods.  But they all need access to the information in
> the form so I save it in the session first when the search form is
> submitted.
>
> First, here is the view that displays the form:
>
> @login_required
> def search(request):
> """
> Serve the main search screen
> """
> if request.method == "POST":
> edit_form = SearchForm(request.POST)
> if edit_form.is_valid():
> for k in edit_form.fields:
> if k in request.session: del request.session[k]
> for k in edit_form.data:
> request.session[k] = edit_form[k].data
> return HttpResponseRedirect( "/kindledb/search/%s/" %
> request.POST['search_type'] )
> else:
> edit_form = SearchForm()
> return render_to_response("kindledb/search.html",
> {'edit_form': edit_form})
>
> Note that when the form is submitted, the first thing it does is clear
> out any session data from the last time this search page was called up.
>  If you don't do that you can end up with stuff hanging around from
> previous searches.
>
> Then it stores all of the information from the newform instance into
> the request.session.  Then it redirects to the appropriate next view.
>
> In that next view, it has access to all of the information that was
> saved in the session.  This works out really well because they are all
> paginated generic object_lists.  So the user can navigate through the
> resulting information no problem.
>
> In your case, you could keep shoving stuff in the request.session if
> you had several pages of forms that they user had to go through.
>
> --gordy
>
>
> >
>


-- 
Honza Král
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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: order_by with Foreign Keys

2007-01-12 Thread gordyt

Hi Carole,

There is a workaround for this problem.  I am using the latest
subversion build of django, so I don't know if it works with the last
official build or not.

Here is an example:

ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number")

Here are the model definitions:

class ProductVersion(models.Model):
product=models.ForeignKey(Product)
version_number=models.CharField(maxlength=16)
availability_date=models.DateField(null=True,blank=True)
release_notes=models.TextField(blank=True)

class Product(models.Model):
name=models.CharField(maxlength=128)


Note that kindledb_product is the name of the database table that
stores the information from the Product.

--gordon


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



Reminder: PyCon early-bird registration ends Monday

2007-01-12 Thread Jacob Kaplan-Moss

Howdy folks --

A quick reminder: Monday 1/15 is the last day for early-bird registration for 
PyCon (you'll save $65).

I'm told that my Django tutorials are nearing capacity, so if you're 
interested in either of them, you should likely sign up sooner rather than 
later.

See you in Dallas!

Jacob

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



Re: Django AMF supports AMF3

2007-01-12 Thread Condredge

I'm having some trouble getting this to work...

Do you know if it works with the Development version of Django (which
I'm using) or only version 0.95?


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



Re: Django AMF supports AMF3

2007-01-12 Thread Condredge

Tomohiro,

Excellent work on this!

Do I need to get the new version if I'm only use AS 2?


--~--~-~--~~~---~--~~
 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: What svn (subversion) client do you use for OS X?

2007-01-12 Thread Noah

have you found svnx to be unstable?


--~--~-~--~~~---~--~~
 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: Generic views and filtering

2007-01-12 Thread David Zhou

On Jan 12, 2007, at 6:25 PM, Nicolas Steinmetz wrote:

> Do I have to do as James [1] suggests, ie to filter it in views.py  
> with some generic views methodes ?

That's the way I do it.  It's a very simple wrapper, and also allows  
me to add a host of other things into the context.

---
David Zhou
[EMAIL PROTECTED]




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



Generic views and filtering

2007-01-12 Thread Nicolas Steinmetz

Hello,

I have a few question with generic views as I can't manage to have all posts
related to a tag or category

My model is :

class Post(models.Model):
author = models.ForeignKey(User)
title = models.CharField(maxlength=50)
summary = models.TextField(blank=True)
message = models.TextField()
category = models.ManyToManyField(Category)
tag = models.ManyToManyField(Tag, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
pub_date = models.DateTimeField('Date de publication',
auto_now_add=True)
pub_status = models.BooleanField('Publie ?', default=True)
url = models.SlugField(prepopulate_from=("title",))

class Tag(models.Model):
name = models.CharField(maxlength=50)
description = models.TextField(blank=True)
url = models.SlugField(prepopulate_from=("name",))

I try to play around with something similar to this in urls.py :

(r'^tag/(?P[-\w]+)/$', 'object_list', dict(queryset=
Post.objects.filter(tag='slug_field'), slug_field= 'url', )),

but did not manage to get anything except errors.

Idea is that all url with /tag/foo gives all posts that have the "foo" tag.

What would be the correct solution ? Do I have to do as James [1] suggests,
ie to filter it in views.py with some generic views methodes ?

So far I run .95 but can move to svn if it is worth :-)

Regards,
Nicolas

[1]



--~--~-~--~~~---~--~~
 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: Dumb question: How to apply patch

2007-01-12 Thread Jeremy Dunck

On 1/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I think I need patch 2070 (file uploads), but have no idea how one goes
> about getting and applying a patch. I assume it's from svn, but that's
> it.

Unfortunately, this ticket
http://code.djangoproject.com/ticket/2070
is a mess.

You may need the functionality, but actually, there's no one
consolidated patch, AFAIK.

:-/

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



Dumb question: How to apply patch

2007-01-12 Thread [EMAIL PROTECTED]

I think I need patch 2070 (file uploads), but have no idea how one goes
about getting and applying a patch. I assume it's from svn, but that's
it.


--~--~-~--~~~---~--~~
 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: Removing SQL From Templates

2007-01-12 Thread George Davis

> I like having access to the models attributes, such as
> get_absolute_url, we use things like this quite a bit in our templates

You could relatively painlessly 'flatten' the attributes of the model
instances in place before rendering template, i.e.

  spam.get_absolute_url = spam.get_absolute_url()

Or programatically

  for attr, val in spam.__dict__ :
if type(val).__name__ == 'function' :
  setattr( spam, attr, val() )

Clearly, related object members would have to be handled slightly
differently, and to save expense on SQL queries you might only want to
evaluate some subset of the object's attributes while deleting others.
But it seems to me that at some point you must specify precisely which
object members will be available to the template, and you might as well
generate a restricted version of the object when doing so.

G


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



Re: Creating a "wizard"

2007-01-12 Thread gordyt

Howdy Bram,

Here is an example of something that I am doing with newforms and
sessions and it seems to work very well.  In my case I have a search
form displayed.  Depending upon the options that are selected by the
user, when they submit the form it will be handled by one of several
different view methods.  But they all need access to the information in
the form so I save it in the session first when the search form is
submitted.

First, here is the view that displays the form:

@login_required
def search(request):
"""
Serve the main search screen
"""
if request.method == "POST":
edit_form = SearchForm(request.POST)
if edit_form.is_valid():
for k in edit_form.fields:
if k in request.session: del request.session[k]
for k in edit_form.data:
request.session[k] = edit_form[k].data
return HttpResponseRedirect( "/kindledb/search/%s/" %
request.POST['search_type'] )
else:
edit_form = SearchForm()
return render_to_response("kindledb/search.html",
{'edit_form': edit_form})

Note that when the form is submitted, the first thing it does is clear
out any session data from the last time this search page was called up.
 If you don't do that you can end up with stuff hanging around from
previous searches.

Then it stores all of the information from the newform instance into
the request.session.  Then it redirects to the appropriate next view.

In that next view, it has access to all of the information that was
saved in the session.  This works out really well because they are all
paginated generic object_lists.  So the user can navigate through the
resulting information no problem.

In your case, you could keep shoving stuff in the request.session if
you had several pages of forms that they user had to go through.

--gordy


--~--~-~--~~~---~--~~
 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: Sessions without cookies for mobile sites

2007-01-12 Thread Michael Radziej

davo schrieb:
> For the record, django/mobile ended up in the 'too difficult' basket
> due to the session difficulties, which is a shame because we were
> digging it development-wise. I'd love to use it for the next pure web
> app though - keep up the good work guys :)

There is a thread in django-developers about sessions without
cookies. Search for 'Stateless sessions'. There seems to be an
almost working implementation. Perhaps you can do it together.

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

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



Re: Django's FastCGI init.d script for Linux

2007-01-12 Thread Michael Radziej

Hi,

could you put this into the wiki? This type of stuff is a lot of
help to new users, but in the mailing list it gets lost. Please note
for which type of linux your script is intended, since init scripts
for, e.g. debian or SUSE, look quite different.

Michael



-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~-~--~~~---~--~~
 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: extending user model, but keep getting type error for user.id

2007-01-12 Thread hotani

One more thing: If I do what it says, and send it the user in the form
of a class, it will continue, but after running "newprofile.save()",
nothing is written to the db table.


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



Pagination too slow in Admin interface

2007-01-12 Thread nm

I have 301220 records in a simple(3 cols) mysql table and in the Admin  
interface the pagination is too slow, even with only 10 records per  
page. There are any reason for this?
Curious, is when I click in a visited page is fast.

Thanks,
Nuno Mariz



--~--~-~--~~~---~--~~
 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: Sessions without cookies for mobile sites

2007-01-12 Thread davo

For the record, django/mobile ended up in the 'too difficult' basket
due to the session difficulties, which is a shame because we were
digging it development-wise. I'd love to use it for the next pure web
app though - keep up the good work guys :)


--~--~-~--~~~---~--~~
 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's FastCGI init.d script for Linux

2007-01-12 Thread Guillermo Fernandez Castellanos

Hi,

For my convenience I've written an init.d script that automatizes the
startup of my FastCGI django servers. As it might interest other
people, I share it here. Feedback  is welcomed.

I can put as many sites as I want, and it will automatically assign
different port numbers to different servers in an increasing order
starting from $PORT_START. It follows the start stop restart
force-reload syntax of the startup scripts and integrates with the
startup process in Ubuntu and Debian systems. Should work in RedHat as
well, not in Gentoo though.

http://www.guindilla.eu/blog/2007/01/12/djangos-fastcgi-initd-script-linux/

The wrapper (/www/run/django_fcgi in my system) is here:
*
 #! /bin/sh

[ $# = 4 ] || echo -n "Usage: $0 django_site ip port pid_file"

DJANGO_SITE=$1
IP=$2
PORT=$3
PID_FILE=$4

/usr/bin/env python $DJANGO_SITE/manage.py runfcgi \
host=$HOST port=$PORT pidfile=$PID_FILE
*

The init script is here:
*
#! /bin/sh
### BEGIN INIT INFO
# Provides:  FastCGI servers for Django
# Required-Start:networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop:  S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description:   Django, in order to operate with FastCGI, must be started
#in a very specific way with manage.py. This must be done
#for each DJango web server that has to run.
### END INIT INFO
#
# Author:  Guillermo Fernandez Castellanos
#  <[EMAIL PROTECTED]>.
#
# Version: @(#)fastcgi 0.1 11-Jan-2007 [EMAIL PROTECTED]
#

 SERVER SPECIFIC CONFIGURATION
#HOST=`/sbin/ifconfig | /bin/sed -n -e 's/\(.*\)inet addr:\(.*\)B.*$/\2/p'`
DJANGO_SITES="complu_haruki_eu www_haruki_eu www_guindilla_eu"
SITES_PATH=/www
DAEMON=/www/run/django_fcgi
RUNFILES_PATH=$SITES_PATH/run
HOST=127.0.0.1
PORT_START=3000
 DO NOT CHANGE ANYTHING AFTER THIS LINE!

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="FastCGI servers"
NAME=$0
SCRIPTNAME=/etc/init.d/$NAME


# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0


#
#   Function that starts the daemon/service.
#
d_start()
{
# Starting all Django FastCGI processes
PORT=$PORT_START
for SITE in $DJANGO_SITES
do
echo -n ", $SITE"
# As $DAEMON is a shell script, the process runs with the name "bash",
# not "$DAEMON".
# Thus I can not use the start-stop-daemon method here.
# start-stop-daemon --start --quiet --pidfile $RUNFILES_PATH/$SITE.pid \
# --exec $DAEMON -- $SITES_PATH/$SITE $HOST $PORT
$RUNFILES_PATH/$SITE.pid \
if [ -f $RUNFILES_PATH/$SITE.pid ]; then
echo -n " already running"
else
$DAEMON $SITES_PATH/$SITE $HOST $PORT $RUNFILES_PATH/$SITE.pid
fi
let "PORT = $PORT + 1"
done
}


#
#   Function that stops the daemon/service.
#
d_stop() {
# Killing all Django FastCGI processes running
for SITE in $DJANGO_SITES
do
echo -n ", $SITE"
start-stop-daemon --stop --quiet --pidfile $RUNFILES_PATH/$SITE.pid \
  || echo -n " not running"
if [ -f $RUNFILES_PATH/$SITE.pid ]; then
   rm $RUNFILES_PATH/$SITE.pid
fi
done
}


ACTION="$1"
case "$ACTION" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;

stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;

restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;

*)
echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac


exit 0
*

Hope it helps,

G

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



extending user model, but keep getting type error for user.id

2007-01-12 Thread hotani

I'm using the 'one to one' method of creating a user profile which
extends django's built-in user model. This is a workaround suggested by
James Bennett on his b-list blog, and I think several other people are
using this or something similar.

My problem is that I have a database I am importing. It contains user
info which I need to insert into both the built-in user, and my
userProfile models.

This is how I am attacking it right now:
1- add new user, where 'u' is an object read from the old data:
newuser = User.objects.create_user(u.uname, u.email, u.pword)

2- add the extra user info to the userProfile model using the "last
inserted id"
newprofile = UserProfile(
user = newuser.id,
office = u.office,
)

Unfortunately, I get an error calling "Invalid Value", but aren't they
both IDs of the same type? This is what it says:
Invalid value: 'user' should be a  instance, not a 

Seems like this should work, and I've seen examples using a similar
approach, but this has stumped me for a few weeks now and I'm getting
tired of looking at it. :-)


--~--~-~--~~~---~--~~
 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: close database connection ?

2007-01-12 Thread Jeremy Dunck

On 1/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> I installed Django-0.95, that shouldn't be the problem.

Actually, it may be part of the problem.  0.95 is somewhat old (r3491)
while trunk is at r4308.  (I'm not saying 0.95 is bad, I'm just saying
I haven't looked at 0.95 in a long while, so there may be another
cause for connections being left open.)
>
> is there a way to test if the connection closes after response
> middleware ?
>

Honestly, if you can reproduce this under runserver, I'd go hack the
database backend to drop into pdb when the connection is opened.

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



Re: Creating a "wizard"

2007-01-12 Thread [EMAIL PROTECTED]

Bram,

If I recall, there have been some discussions about building this sort
of capability in new forms.  However, you can see how I've done
something similar in Satchmo using the old forms implementation.  It's
not automatic, but it does allow someone to move through all three
steps and the final order is not completed until the user confirms.

http://satchmo.python-hosting.com/browser/trunk/satchmo/shop/views/

Look at the views checkout-step1 through step3 to get an idea of one
implementation for a similar sort of checkout process.

-Chris


--~--~-~--~~~---~--~~
 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: Can a view open a page in a new browser window?

2007-01-12 Thread Bob T.

Thanks Julio and Jeremy. When the users generate multiple reports I go
to a page that shows links to the reports and let them click the link
for the report they want to see. However, when there is only one HTML
report to view it would be one less click for the user if I could
bypass that page and go right to the report.

Guess I'll show them the report results page anyway, since it's just a
small refinement anyway.


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



Uploading large files via http FORM

2007-01-12 Thread Pythoni

Hi,
does anyone have an experience with uploading large files in Django
application?
I use mod_python with Django and when I try to upload a file about 100
MB I received an error.
Thank you for any suggestion.
L.


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



sqlite3, QuerySet.extra() and order_by() inconsistencies between Python versions

2007-01-12 Thread Bo Shi

Hi -

Has anyone else observed differences between the behavior of order_by
between Python 2.3 and 2.4?  Under 2.3, the following code drops many
items in thread_list when using order_by():

...
extra_last_updated = """
SELECT date FROM forum_post
WHERE forum_post.thread_id = forum_thread.id
ORDER BY date DESC LIMIT 1
"""

thread_list = thread_list.extra(
select = {
# ...
#'last_updated': extra_last_updated,  # bug:
http://code.djangoproject.com/ticket/2210
'date': extra_last_updated,
'last_poster': extra_last_poster,
#},)
},).order_by('-csticky', '-date')

The above works as expected in a mod_python setup with Python 2.4 but
not Python 2.3 (Debian Sarge vs. Etch).  The pysqlite versions I'm
using are identical in both setups.  Of course, I haven't controlled
for a lot of other factors, but maybe someone has observed this before?


--~--~-~--~~~---~--~~
 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: close database connection ?

2007-01-12 Thread [EMAIL PROTECTED]


I installed Django-0.95, that shouldn't be the problem.

after i get data from the database first there are some actions in
python but the DB is called afterwards. So it could be that there is a
second connection open when the other is still closing.

is there a way to test if the connection closes after response
middleware ?


--~--~-~--~~~---~--~~
 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: date format other than YYYY-MM-DD

2007-01-12 Thread Adrian Holovaty

On 1/12/07, Andres Luga <[EMAIL PROTECTED]> wrote:
> Any idea if newforms simplifies this?

Yes, newforms DateFields let you specify the input format(s). This has
yet to be integrated into the Django admin, but it will be sooner
rather than later.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Creating a "wizard"

2007-01-12 Thread Bram

Hi all,

I started working with Django some time ago, and i've to say that I
like the framework so far. However, now I would like to create a kind
of wizard for an ordering system. In short, a process with
back/next/cancel buttons. It would be nice to save everything in the
session or some other temporary place and create an order when all
steps are finished. Furthermore, the steps could be somewhat dynamic,
the step after a form that prompts the user if he/she is already an
existing customer could be a form for customer registration, or a login
page.

Any ideas how I could get this going?

Tia,

Bram


--~--~-~--~~~---~--~~
 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: What svn (subversion) client do you use for OS X?

2007-01-12 Thread Rob Hudson

If you visit their "Documents & Files" section you can see there have
been some updates as recent as December 2006.  But they sound
experimental.  But it looks like progress is being made...

Noah wrote:
> I could hope there is a rewrite... after all there hasn't been a news
> update since 2004...


--~--~-~--~~~---~--~~
 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: What is the best way of uploading large files from Django?

2007-01-12 Thread Pythoni

Istvan,
Thank you for your reply.
I know about tramline  but I was not able to use tramline together with
Django.
Do you use tramline by yourself?
La.


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



Re: Newforms 'preferred practice'

2007-01-12 Thread Felix Ingram

Hi Chris,

On 12/01/07, Chris Rose <[EMAIL PROTECTED]> wrote:
> Felix Ingram wrote:
> > 3. Binding data - I'd like the form to handle editing of an instance.
> > I could construct a dictionary of values and pass it to the form as
> > per the docs but I'd like to just pass a model instance and have the
> > form sort things out. Is this advisable? If so then does anyone have
> > any pointers about what methods I need to implement?
>
> You can use the model instances __dict__:
>
> my_form = CreateForm(initial=model_instance.__dict__)
>
> Saves copying each field into a seperate dict or implementing any extra
> methods in your form.

This works quite well for simple forms but it won't populate m2m
fields and I need to tweak some fields for display.

Thanks for reminding me about __dict__ though. I do forget about it.

Regards,

Felix

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



Re: Newforms 'preferred practice'

2007-01-12 Thread Felix Ingram

Hi Honza,

On 12/01/07, Honza Král <[EMAIL PROTECTED]> wrote:
> On 1/12/07, Felix Ingram <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> >
> > I've been playing around with the newforms library and I'd like to
> > check that I'm on the right track.
> >
> > I've got a fairly complicated model that has a few foreign keys and
> > m2m fields. One of the m2m fields references a table with ~130,000
> > rows so the usual select boxes aren't that usable. I've created a form
> > which simplifies the entry but I would like to check the preferred way
> > of doing certain things.
> >
> > 1. Additional validation - One field is a RegexField but I would like
> > to add extra validation. At the moment I've subclassed it and added my
> > own 'clean' method.
>
> You can either override clean (remember to call the super.clean) on
> the field, or implement clean_FIELD on the form

Good, I'll stick with the subclassing. This seems to work well enough.

> > 2. Saving the model - I've implemented a save method in the form which
> > will return an instance of the model in a similar fashion to
> > form_for_model. Is this good practice or should I create the instance
> > in my view and populate it from the form?
>
> I do the same thing since I reuse the form in multiple views

This does seem to work, but not I'm getting into trouble when I bind
it to an instance.

> > 3. Binding data - I'd like the form to handle editing of an instance.
> > I could construct a dictionary of values and pass it to the form as
> > per the docs but I'd like to just pass a model instance and have the
> > form sort things out. Is this advisable? If so then does anyone have
> > any pointers about what methods I need to implement?
>
> the easiest way how to do this is in __init__ of the form create the
> dictionary from the model and use it when calling super.__init__

I've just implemented this but I run into trouble when I update the
model. At the moment I'm passing in the POST dict but things are
obviously going wrong as the form fails to validate but I don't get
any errors.

Would it be possible for you to paste an example from one of your
form's __init__s? I have a feeling that I'm missing something obvious.

> > P.S. Are there any thoughts about form inheritance? I'd like to be
> > able to create a form base on another but with some more fields. At
> > the moment this doesn't seem to work as expected...
>
> it works but only for dynamic fields added via self.fields['name'] =
> forms.Field(...)
> I use it with success

I'll give this a go; thanks.

Felix

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



Re: Newforms 'preferred practice'

2007-01-12 Thread Chris Rose

Felix Ingram wrote:
> 3. Binding data - I'd like the form to handle editing of an instance.
> I could construct a dictionary of values and pass it to the form as
> per the docs but I'd like to just pass a model instance and have the
> form sort things out. Is this advisable? If so then does anyone have
> any pointers about what methods I need to implement?

You can use the model instances __dict__:

my_form = CreateForm(initial=model_instance.__dict__)

Saves copying each field into a seperate dict or implementing any extra
methods in your form.

Chris


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



Re: Newforms 'preferred practice'

2007-01-12 Thread Honza Král
On 1/12/07, Felix Ingram <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I've been playing around with the newforms library and I'd like to
> check that I'm on the right track.
>
> I've got a fairly complicated model that has a few foreign keys and
> m2m fields. One of the m2m fields references a table with ~130,000
> rows so the usual select boxes aren't that usable. I've created a form
> which simplifies the entry but I would like to check the preferred way
> of doing certain things.
>
> 1. Additional validation - One field is a RegexField but I would like
> to add extra validation. At the moment I've subclassed it and added my
> own 'clean' method.

You can either override clean (remember to call the super.clean) on
the field, or implement clean_FIELD on the form

>
> 2. Saving the model - I've implemented a save method in the form which
> will return an instance of the model in a similar fashion to
> form_for_model. Is this good practice or should I create the instance
> in my view and populate it from the form?

I do the same thing since I reuse the form in multiple views

>
> 3. Binding data - I'd like the form to handle editing of an instance.
> I could construct a dictionary of values and pass it to the form as
> per the docs but I'd like to just pass a model instance and have the
> form sort things out. Is this advisable? If so then does anyone have
> any pointers about what methods I need to implement?

the easiest way how to do this is in __init__ of the form create the
dictionary from the model and use it when calling super.__init__

>
> Thanks in advance for any pointers.
>
> Felix
>
> P.S. Are there any thoughts about form inheritance? I'd like to be
> able to create a form base on another but with some more fields. At
> the moment this doesn't seem to work as expected...

it works but only for dynamic fields added via self.fields['name'] =
forms.Field(...)
I use it with success

>
> >
>


-- 
Honza Král
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Multi-db question

2007-01-12 Thread dutche

Does anybody knows where can I find some docs about multi-db ??

Thanks in advance


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



Newforms 'preferred practice'

2007-01-12 Thread Felix Ingram

Hello all,

I've been playing around with the newforms library and I'd like to
check that I'm on the right track.

I've got a fairly complicated model that has a few foreign keys and
m2m fields. One of the m2m fields references a table with ~130,000
rows so the usual select boxes aren't that usable. I've created a form
which simplifies the entry but I would like to check the preferred way
of doing certain things.

1. Additional validation - One field is a RegexField but I would like
to add extra validation. At the moment I've subclassed it and added my
own 'clean' method.

2. Saving the model - I've implemented a save method in the form which
will return an instance of the model in a similar fashion to
form_for_model. Is this good practice or should I create the instance
in my view and populate it from the form?

3. Binding data - I'd like the form to handle editing of an instance.
I could construct a dictionary of values and pass it to the form as
per the docs but I'd like to just pass a model instance and have the
form sort things out. Is this advisable? If so then does anyone have
any pointers about what methods I need to implement?

Thanks in advance for any pointers.

Felix

P.S. Are there any thoughts about form inheritance? I'd like to be
able to create a form base on another but with some more fields. At
the moment this doesn't seem to work as expected...

--~--~-~--~~~---~--~~
 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 services in Django

2007-01-12 Thread David Larlet

2006/12/22, juampa <[EMAIL PROTECTED]>:
>
> Hello all:
>
> I am trying to gather all the information I can about implementing web
> services with Django (XML-RPC, SOAP, REST). Can you suggest good
> sources of information/examples of implementations? What is the offical
> status of WS support in Django? Thanks.

Here is a really interesting ticket: http://code.djangoproject.com/ticket/115

Maybe it's time to collect all ressources in order to progress, feel
free to add yours:

On the web:
* XMLRPC in Django http://www.allyourpixel.com/post/xmlrpc-djgo/
* Django Ajax Redux http://lazutkin.com/blog/2005/dec/10/django-ajax-redux/

On mailing-lists:
* Extend URL resolver support for HTTP Methods / REST support:
http://groups.google.com/group/django-developers/browse_thread/thread/15056b2979180228/e9c4c94408a54f44
* metaapi: Django Meta-API - Invitation to Criticize!
http://groups.google.com/group/django-developers/browse_thread/thread/639016969c4cd323/745e4111d3835634
* Django, RDF & XUL
http://groups.google.com/group/django-users/browse_thread/thread/da7638815273dbcd/c0a371f9f6ebd286
* REST-like web services in Django
http://groups.google.com/group/django-users/browse_thread/thread/9f438744f6be28b4/bf7d2d3314d4df0f
* A RESTful Django?
http://groups.google.com/group/django-users/browse_thread/thread/540bce06cda01fc7/056d6c595547abc9

Ok, a lot of people waiting for this "feature" but it's not really
easy to deal with all possibilities so let's get back to the
discussion.

Cheers,
David

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



Re: Django Projects and Subversion

2007-01-12 Thread Jeffrey Zelt

I am just finishing a Django project that is managed by Subversion.  I 
have set up 3 web sites to manage it - a "development", "staging" and 
"production" server.  This is a common paradigm, nothing that I came up 
with myself.

You can have active committing by developers to the repository and there 
are no problems.  Just check out a particular revision onto the the 
staging server and test that everything works as expected.  When you are 
confident that everything is OK (for that revision), you can check out 
the same revision on the production server (effectively performing an 
"upgrade").

Each web server requires a slightly different settings.py file since you 
want each to use their own databases, but most of the content of these 
files will be the same.  I even use Subversion to manage these 3 
settings files in the same repository.  I have 3 settings files:

settings_development.py
settings_staging.py
settings_production.py

When updating one of the servers with a particular revision, all of 
these files are downloaded to the particular server you are dealing 
with.  To use the appropriate settings file, I create a symbolic link:

settings.py

that points the the appropriate settings file.  You can get by without 
introducing this link by referencing the appropriate settings file in 
each Apache Virtual Server configuration, but if you want Django's 
"manage.py" script to work transparently, you need this link.

The important thing is to *NOT* put this link under revision control, 
i.e., it is not managed by the Subversion repository.  It will stick 
around while the other files in the directory are being managed by 
Subversion.

Jeff



Aidas Bendoraitis wrote:
> I have an SVN-specific question which doesn't really fit into Django
> groups. Anyway, maybe somebody of you will have enough experience and
> competence to answer it.
>
> We are going to set our Django projects under
> version control on a dedicated server. We will also publicly run
> several Django websites on the same server. So what is a better
> practice -- to use the code under source
> control for the public websites directly, or to have copies (tags) of
> the subversioned code for the public websites?
>
> How is this managed with djangoproject.com and djangobook.com?
>
> Regards,
> Aidas Bendoraitis aka Archatas
>
> >
>   


--~--~-~--~~~---~--~~
 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: order_by with Foreign Keys

2007-01-12 Thread Russell Keith-Magee

On 1/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I've seen a few posts that this was a bug where you cannot specify
> order_by with a column from a foreign key ...
> order_by(foreignkeytable__foreignkeycolumn) because it says table not
> found.
>
> Does anyone know if there are plans to fix this...or if there is a work
> around?

There are no specific plans that I am aware of (i.e., no schedule that
says 'will be fixed by 25 Jan'). There was talk of a refactoring of
query.py that was to address problems like this one, but the developer
that was championing this cause (Malcolm) has been absent of late.

Obviously, it is a bug, and it would be nice if Django had no bugs,
but the core developers have limited time, and we spend it where we
think it has the most benefit. If someone were to step up and fix this
problem, it would probably find its way into the trunk fairly quickly
(assuming it was a complete patch, of good quality, with unit tests,
etc).

Yours,
Russ Magee %-)

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



What is the best way of uploading large files from Django?

2007-01-12 Thread Pythoni

I use Django with mod_python and it works great. But when I try to
upload large file ( 90 MB)via HTTP FORM I received an error.
Can anyone suggest a way how to upload such file?I was thinking about
FTP protocol but it is difficult because a user who uploads the file
would have to use FTP client too.
Any ideas would be welcome
L.


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



Re: Latex Rendering

2007-01-12 Thread Kjell Magne Fauske


Anush Shetty wrote:
> Hi,
> I want to build a wiki with the html text to be rendered as latex. Can
> anybody please suggest me on how I should go about it.
>

Docutils[1] can generate LaTeX code[2] from reStructuredText markup.
Since its implemented in Python, it should not be that difficult to
integrate it with Django. See for instance [3] for an example.

[1] http://docutils.sourceforge.net/docs/index.html
[2] http://docutils.sourceforge.net/docs/user/latex.html
[3]
http://code.djangoproject.com/browser/django/trunk/django/contrib/markup/templatetags/markup.py

- Kjell Magne Fauske


--~--~-~--~~~---~--~~
 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: Latex Rendering

2007-01-12 Thread Kenneth Gonsalves


On 12-Jan-07, at 1:48 PM, Anush Shetty wrote:

> I want to build a wiki with the html text to be rendered as latex.  
> Can anybody please suggest me on how I should go about it.

rendered where? Use markdown or somesuch for formatting the wiki and  
use the steps somewhat like those described in making reports with  
reportlab to convert your content to latex using html2latex or a  
similar tool:
http://www.djangoproject.com/documentation/outputting_pdfs/

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
 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: date format other than YYYY-MM-DD

2007-01-12 Thread Andres Luga

Hi,

Any idea if newforms simplifies this?

Regards,
Andres

On 9/29/06, DavidA <[EMAIL PROTECTED]> wrote:

> I also ran into this problem so I did it that hard way: I created a
> custom model DateField and a custom form DateField. (I call them
> RelaxedModelDateField and RelaxedFormDateField meaning they are relaxed
> about what format you put the date in). Every time I look at this code
> I think "this is way too complicated to simply allow different date
> formats on input/output" which is probably one of the reasons the
> forms/manipulators/validators are all getting revisited right now.
>
> To use this, just use RelaxedModelDateField in place of
> models.DateField in your model. This works in the admin.
>
> class RelaxedModelDateField(models.DateField):
>"""A DateField that supports various date formats
>rather than just -mm-dd. The following formats
>are allowed:
>  m/-d/-6-23-2006
>  m/-d/-yy  6/23/06
>  m/-d  6/23
>  -mm-dd2006-6-23
>  mmdd  20060623
>
>In the UI, the date will be displayed as mm/dd/"""
>def __init__(self, verbose_name=None, name=None,
> auto_now=False, auto_now_add=False, **kwargs):
>models.DateField.__init__(self, verbose_name, name,
>  auto_now, auto_now_add, **kwargs)
>
>def get_internal_type(self):
>return "DateField"
>
>def to_python(self, value):
>if isinstance(value, datetime.datetime):
>return value.date()
>if isinstance(value, datetime.date):
>return value
>try:
>return toDateRelaxed(value)
>except ValueError:
>raise validators.ValidationError, gettext('Enter a valid
> date.')
>
>def get_manipulator_field_objs(self):
>return [RelaxedFormDateField]
>
>def flatten_data(self, follow, obj = None):
>val = self._get_val_from_obj(obj)
>return {self.attname:
>(val is not None and val.strftime("%m/%d/%Y") or '')}
>
> class RelaxedFormDateField(forms.DateField):
>"""A version of forms.DateField that automatically
>supports various formats of dates."""
>def __init__(self, field_name, is_required=False,
> validator_list=None):
>forms.DateField.__init__(self, field_name, is_required,
> validator_list)
>
>def isValidDate(self, field_data, all_data):
>try:
>toDateRelaxed(field_data)
>except ValueError:
>raise validators.CriticalValidationError, 'Enter a valid
> date.'
>
>def html2python(data):
>"Converts the field into a datetime.date object"
>try:
>return toDateRelaxed(data)
>except ValueError:
>return None
>html2python = staticmethod(html2python)
>
>
> And here is the routine that actually does the "relaxed" parsing:
>
> # handle many formats:
> # m/-d/-6-23-2006
> # m/-d/-yy  6/23/06
> # m/-d  6/23
> # -mm-dd2006-6-23
> # mmdd  20060623
> def toDateRelaxed(s):
>exps = (r'^(?P\d{1,2})[/-](?P\d{1,2})[/-](?P\d{4})$',
>r'^(?P\d{1,2})[/-](?P\d{1,2})[/-](?P\d{2})$',
>r'^(?P\d{1,2})[/-](?P\d{1,2})$',
>r'^(?P\d{4})-(?P\d{1,2})-(?P\d{1,2})$',
>r'^(?P\d{4})(?P\d{2})(?P\d{2})$')
>for exp in exps:
>m = re.match(exp, s)
>if m:
>mm = int(m.group('m'))
>dd = int(m.group('d'))
>try:
>yy = int(m.group('y'))
>if yy < 100:
>yy += 2000
>except IndexError:
>yy = datetime.date.today().year
>return datetime.date(yy, mm, dd)
>raise ValueError, s
>
> Hope this helps...
> -Dave
>

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



Latex Rendering

2007-01-12 Thread Anush Shetty
Hi,
I want to build a wiki with the html text to be rendered as latex. Can
anybody please suggest me on how I should go about it.

-- 
Cheers.
Anush Shetty


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