Re: Automated Translation Management -- Surely someone has already done this?

2009-02-15 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 2:47 AM, DrMeers  wrote:

>
> I have developed a Django site for an open source project, with
> contributors around the globe.
>
> A brief aside/background: I have used django-cms to store the majority
> of the content for the site, but rather than adopting its usual tactic
> of translating a whole page at a time, have used {% trans %} and {%
> blocktrans %} tags within the content, and written a script to dump
> the database content into dummy HTML files so they get picked up by
> django-admin.py's makemessages utility. This way translators don't
> have to hunt for which line/paragraph within a large page has been
> changed, nor worry about messing up the layout of the page when
> translating.
>
> Back to the point: this website will be translated into over a dozen
> languages, and undergo regular content updates. I have written code
> that runs django-admin.py makemessages (via subprocess.Popen, though I
> suspect there is a better way to run it within python?) and allows the
> download of the latest .po file for any given language. I would also
> like registered/authenticated users to be able to easily upload their
> updated translation files and have them automatically update the
> website (using compilemessages). So when I make a change to the
> website, I'd like the registered translators to be automatically
> emailed, and asked to update their translations (again, simply
> download and upload the new .po file via the website). This is easy
> enough to do, and saves me a HUGE amount of work over the next few
> years.
>
> But the reason I am posting this: this is such a common procedure,
> surely someone has written this stuff before? But I cannot find it
> anywhere online. Isn't there a django-translation-management package
> already written? Or should I create it once I finish coding? How have
> other people streamlined this process?
> >
>
You really want to be storing the translations at the DB level to that
effect check out:
http://code.google.com/p/django-multilingual/
or
http://code.google.com/p/transdb/

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Automated Translation Management -- Surely someone has already done this?

2009-02-15 Thread DrMeers

I have developed a Django site for an open source project, with
contributors around the globe.

A brief aside/background: I have used django-cms to store the majority
of the content for the site, but rather than adopting its usual tactic
of translating a whole page at a time, have used {% trans %} and {%
blocktrans %} tags within the content, and written a script to dump
the database content into dummy HTML files so they get picked up by
django-admin.py's makemessages utility. This way translators don't
have to hunt for which line/paragraph within a large page has been
changed, nor worry about messing up the layout of the page when
translating.

Back to the point: this website will be translated into over a dozen
languages, and undergo regular content updates. I have written code
that runs django-admin.py makemessages (via subprocess.Popen, though I
suspect there is a better way to run it within python?) and allows the
download of the latest .po file for any given language. I would also
like registered/authenticated users to be able to easily upload their
updated translation files and have them automatically update the
website (using compilemessages). So when I make a change to the
website, I'd like the registered translators to be automatically
emailed, and asked to update their translations (again, simply
download and upload the new .po file via the website). This is easy
enough to do, and saves me a HUGE amount of work over the next few
years.

But the reason I am posting this: this is such a common procedure,
surely someone has written this stuff before? But I cannot find it
anywhere online. Isn't there a django-translation-management package
already written? Or should I create it once I finish coding? How have
other people streamlined this process?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add views to admin interface

2009-02-15 Thread Robert

Dear Malcom,

thanks for your answer, but as I wrote in my first post altering
templates is not a satisfying solution for me. By altering templates I
have to define all permissions by hand. I thought it must be possible
to define permission - as for models - in the table
auth_permission...
By the way this had the advantage that people who have no permission
on a view don't see the link for that view on the admin interface...
If I add a view to admin by altering template every user will see the
link and if no permission is given the user will see a 'Not-Allowed-To-
See-Site'. I think this is frustrating for users. If I don't want that
I will have to define a lot of 'if user has permission then he can see
a link, else not' statements.

I hope you understand what's my problem

Greetz Robert

On 16 Feb., 00:09, Malcolm Tredinnick 
wrote:
> On Sun, 2009-02-15 at 11:06 -0800, Robert wrote:
> > Hi,
>
> > how can I add views to the admin interface that
> > 1. they are also so 'well-integrated' in the admin interface like
> > models
> > 2. I can also define permissions for them like for a model
>
> Adding views to the admin is easy, since a view is just the target of a
> URL. So alter the admin template that you want to have the new link
> appear on. You don't have to modify the source, just create an
> overriding template in your project.
>
> If you use the filesystem loader to load the template (that is, set up a
> directory using TEMPLATE_DIRS), and if you haven't changed the default
> order of the TEMPLATE_LOADERS setting, any templates in TEMPLATE_DIRS
> will be loaded before app-specific templates. So you create, e.g,
> admin/index.html in a directory in TEMPLATE_DIRS and it will override
> the default admin one.
>
> Once you have added a new HTML link to the template that will trigger
> your view, you have to write a view for it. You add something to one of
> your URL Conf files to catch the URL (do this *before* any admin
> patterns are processed, so that your pattern is handled first) and send
> it off to the view you have written. That view will just be a normal
> Django view, so you can use the normal permission decorators on the view
> if you like.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Supported Django version of Googale app engine

2009-02-15 Thread nivhab

Hi,

Does anyone know if Django 1.0 is already supported out-of-the-box on
the Google app engine?

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



Re: InnoDB tables for MySQL

2009-02-15 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 1:37 AM, jfmxl  wrote:

>
> Hi,
>
> I read through the tutorials and thank you very much! They are well
> designed and very helpful.
>
> I noticed that the models' database definitions created using MySQL
> always create MyISAM tables, but to use functional constraints on
> foreign keys one must use InnoDB tables in MySQL.
>
> Is there someway to change the table type created from MyISAM to
> MyInnoDB with MySQL?
> >
>
By adding:

DATABASE_OPTIONS = {
   "init_command": "SET storage_engine=INNODB",
}


you can get innodb tables by default.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



InnoDB tables for MySQL

2009-02-15 Thread jfmxl

Hi,

I read through the tutorials and thank you very much! They are well
designed and very helpful.

I noticed that the models' database definitions created using MySQL
always create MyISAM tables, but to use functional constraints on
foreign keys one must use InnoDB tables in MySQL.

Is there someway to change the table type created from MyISAM to
MyInnoDB with MySQL?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Svn pre-commit hooks with beanstalkapp.com

2009-02-15 Thread Sean Brant

In case anyone else in interested I whipped up this simple script that
seems to do the job.

http://dpaste.com/121117/

It basically works like svn commit but looks thru all of directories
under your current directory for manage.py files. If it finds one it
runs manage.py test. If all tests pass it runs svn commit passing your
arguments thru.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing the language in test client

2009-02-15 Thread peschler

>
> You are misunderstanding what the set_language view does. That view sets
> up the client's locale cookie so that whenever a view is processed for
> that particular web client, it will be done in the locale of "de" (in
> your case).

Ok. Thanks for making this clear.

>
> It does not change the global locale of the entire Django process, or
> the test framework or anything like that. If you are wanting to run a
> particular test in a certain locale, you will have to call
> translation.activate() at the start of the function and
> translation.deactivate() at the end -- don't forget the second one or
> other tests will fail due to being in an unexpected locale.

That's exactly the information I needed. I already hunted it down to
the Translation class but your information is right on spot.

Thanks for the fast answer.

Regards,
Peter Eschler

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



Re: Table Inheritance and save() method

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 20:41 -0500, Alex Gaynor wrote:

[...]
> 
> select_related doesn't traverse the reverse relation from inheritance
> either, there's a ticket about this:
> http://code.djangoproject.com/ticket/7270 in any event, how can your
> application depend on that, select_related is an optimization, not a
> behavior changer.

The whole thread so far has been about performance optimization. So long
as you read "critical" to mean "performs much better with", it's not an
unreasonable comment, given the earlier context.

Malcolm



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



Re: Implement special model layout

2009-02-15 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 02:03 +0100, Andrási László (g) wrote:
>  Hi,
> 
> Sorry for my english.
> I want to implement the following structure to all of my models. 
> I have two db tables for every model a primary and a modifications
> ( for logging)
> 
> Example:
> CONTENT
> id int(10) primary key (autincrement)
> cre_date datetime
> mod_date datetime
> body longtext
> status enum('A','D')
> 
> CONTENT_MOD
> id int(10) key (not primary!, no autoincrementing!)
> cre_date datetime
> mod_date datetime
> body longtext
> status enum('A','D')
> 
> On every update I have a sql command:
> insert to CONTENT_MOD select * from CONTENT where id=???
> before the update, and I change the CONTENT.mod_date to NOW()
> 
> So I have all the backward modifications logged in the CONTENT_MOD
> table. Then I can use "select * from CONTENT_MOD where id=??? " to get
> all the versions of a record.
> 
> 
> Where can I start? Should I have to overwrite the models.base class?

You could override the save() method on the Content model to save
something to the ContentMod model each time as well.

Or you could set it up as a database trigger so that the updates happen
without requiring any input from Django.

Regards,
Malcolm



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



Re: Table Inheritance and save() method

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 8:38 PM, Trey  wrote:

>
> Thanks Malcom,
>
> I suspected this to be the answer, however since I just finished
> refactoring all of my field references to stop referencing the child
> model explicitly to give inheritance a try, I was hoping that wouldn't
> be the case :)
>
> There is one thing about OneToOne fields that isn't exactly equivalent
> to inheritance, and correct me if I am wrong, you can't ask
> select_related to go backwards in a relationship. This is critical for
> my application.
>
>
>
> On Feb 15, 7:52 pm, Malcolm Tredinnick 
> wrote:
> > On Sun, 2009-02-15 at 16:39 -0800, Trey wrote:
> > > I thought I would ask the question here first before going to devs
> > > with it. Is it possible to update a model without updating that models
> > > parent table?
> >
> > No. Django doesn't do anything like "damage tracking" to determine which
> > fields have changed. One day that might well be implemented (there are a
> > number of different possible approaches, each with benefits and
> > drawbacks), but until then, no.
> >
> > The solution in your case is not to use Python-level inheritance.
> > Remember that it's only an alternative modelling of an explicit
> > one-to-one relation. So use an explicit relation and no "chained saving"
> > will take place (the trade-off being that if you modify the related
> > model, you'll be responsible for explicitly saving it).
> >
> > Regards,
> > Malcolm
> >
> select_related doesn't traverse the reverse relation from inheritance
either, there's a ticket about this:
http://code.djangoproject.com/ticket/7270 in any event, how can your
application depend on that, select_related is an optimization, not a
behavior changer.

Alex


-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Table Inheritance and save() method

2009-02-15 Thread Trey

Thanks Malcom,

I suspected this to be the answer, however since I just finished
refactoring all of my field references to stop referencing the child
model explicitly to give inheritance a try, I was hoping that wouldn't
be the case :)

There is one thing about OneToOne fields that isn't exactly equivalent
to inheritance, and correct me if I am wrong, you can't ask
select_related to go backwards in a relationship. This is critical for
my application.



On Feb 15, 7:52 pm, Malcolm Tredinnick 
wrote:
> On Sun, 2009-02-15 at 16:39 -0800, Trey wrote:
> > I thought I would ask the question here first before going to devs
> > with it. Is it possible to update a model without updating that models
> > parent table?
>
> No. Django doesn't do anything like "damage tracking" to determine which
> fields have changed. One day that might well be implemented (there are a
> number of different possible approaches, each with benefits and
> drawbacks), but until then, no.
>
> The solution in your case is not to use Python-level inheritance.
> Remember that it's only an alternative modelling of an explicit
> one-to-one relation. So use an explicit relation and no "chained saving"
> will take place (the trade-off being that if you modify the related
> model, you'll be responsible for explicitly saving it).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Implement special model layout

2009-02-15 Thread g
Hi,

Sorry for my english.
I want to implement the following structure to all of my models.
I have two db tables for every model a primary and a modifications ( for
logging)

Example:
CONTENT
id int(10) primary key (autincrement)
cre_date datetime
mod_date datetime
body longtext
status enum('A','D')

CONTENT_MOD
id int(10) key (not primary!, no autoincrementing!)
cre_date datetime
mod_date datetime
body longtext
status enum('A','D')

On every update I have a sql command:
insert to CONTENT_MOD select * from CONTENT where id=???
before the update, and I change the CONTENT.mod_date to NOW()

So I have all the backward modifications logged in the CONTENT_MOD table.
Then I can use "select * from CONTENT_MOD where id=??? " to get all the
versions of a record.


Where can I start? Should I have to overwrite the models.base class?

Thx.
laco

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



Re: Table Inheritance and save() method

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 16:39 -0800, Trey wrote:
> I thought I would ask the question here first before going to devs
> with it. Is it possible to update a model without updating that models
> parent table?

No. Django doesn't do anything like "damage tracking" to determine which
fields have changed. One day that might well be implemented (there are a
number of different possible approaches, each with benefits and
drawbacks), but until then, no.

The solution in your case is not to use Python-level inheritance.
Remember that it's only an alternative modelling of an explicit
one-to-one relation. So use an explicit relation and no "chained saving"
will take place (the trade-off being that if you modify the related
model, you'll be responsible for explicitly saving it).

Regards,
Malcolm



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



Signals getting sent twice

2009-02-15 Thread stevedegrace

I realise going through Google that this has been hashed over before,
but nevertheless, I want to know if there is any new thought on this.
Ever since I removed project references from imports in my code, I
have noticed a new problem whereby many functions connected to signals
are being called twice. I don't know if that caused the problem, but
it seems likely because everything I've been reading tracks the
problem down to imports.

A good example is in my __init__.py for my comments application, which
is basically just a bunch of customizations to the Django comments
application. That one has no imports of any of my models in it. It is
posted below.

This is a real pain. Is there any way to make it not do this, short of
going through my code and making all my imports through the project
again? Maybe that wouldn't even help. I tried making selected imports,
e.g., through the list of installed apps in settings.py import through
the project name again but that didn't fix it, so I don't see an easy
hack.

The same thing is happening whether I'm using manage.py runserver at
home or Apache2/mod_wsgi2 on Webfaction. On Webfaction I have no
choice but to have both the project directory and the directory
containing it on my path or I get Apache 500 errors, the only way I
can make my application load is to have both on the path.

This is really awful behaviour - it's probably the ugliest wart (maybe
the only significant one, but still) I have ever found in Django, and
it sucks because my applications are using signals a lot. I hope
there's a way around it.

Stephen

from django.contrib.comments.signals import comment_will_be_posted,
comment_was_posted, comment_was_flagged
from django.contrib.comments.models import Comment
from django.contrib.sites.models import Site
from django.template import Context, loader
from django.core.mail import send_mail
from django.conf import settings

def pre_comment(sender, comment, request, **kwargs):
if not request.user.is_authenticated:
comment.is_removed = True

def post_comment(sender, comment, request, **kwargs):
if comment.is_removed:
comment.delete()
else:
request.session['flash'].append('Thank you for your
comments.')
request.session.modified = True
site = Site.objects.get_current()
template = loader.get_template('comments/comment_email.html')
context = Context({
'comment': comment,
'protocol': 'https' if request.is_secure() else
'http',
'site': site,
})
send_mail("A comment was posted at %s" % site.name,
template.render(context), getattr(settings,
'DEFAULT_FROM_EMAIL', None),
getattr(settings, 'MODERATOR_EMAILS', None))

def flag_comment(sender, comment, flag, created, request, **kwargs):
site = Site.objects.get_current()
template = loader.get_template('comments/comment_flag_email.html')
context = Context({
'comment': comment,
'flagged_by': request.user,
'protocol': 'https' if request.is_secure() else 'http',
'site': site,
})
send_mail("A comment was flagged by %s" % request.user.username,
template.render(context), getattr(settings,
'DEFAULT_FROM_EMAIL', None),
getattr(settings, 'MODERATOR_EMAILS', None))

comment_will_be_posted.connect(pre_comment, Comment)
comment_was_posted.connect(post_comment, Comment)
comment_was_flagged.connect(flag_comment, Comment)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Table Inheritance and save() method

2009-02-15 Thread Trey

I thought I would ask the question here first before going to devs
with it. Is it possible to update a model without updating that models
parent table?

A very small example:

class Aye(model):
  a = field

class Bee(Aye):
  b = field

o = Bee.objects.get(k)
o.b = 3
o.save()


In my code this will update the Bee and the Aye tables. In my case,
where the Aye table is quite large (the entire reason I am using
inheritance) this is somewhat counter productive.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "setup_environ" can't help to run a standalone script

2009-02-15 Thread Orcun Avsar


hi and thanks for advice. however it doesn't seems like the problem
because i did set all my python paths correctly and called
setup_environ.
it was like.

this was the top of script before i solved the problem
>>DIR=os.path.abspath(__file__)
>>sys.path.append(imp.find_module("django")[1])
>>sys.path.append(os.path.split(os.path.split(DIR)[0])[0])
>>setup_environ(settings)

>>from indir.program.models import Program

when it tried to import Program from indir/program/models.py, some
admin.site.register() line from another aplication's models.py also
ran because Program model needs some models from there for a
ForeignKeyField.

  you can see that at the output below:

  from indir.program.models import Program
  File "C:\Documents and Settings\orcun\Desktop\indir\..\indir\program
\models.py", line 6, in 
  from indir.kategori.models import Kategori
  File "C:\Documents and Settings\orcun\Desktop\indir\..\indir\kategori
\models.py", line 33, in 
  admin.site.register(Kategori, KategoriAdmin)

  this is ok so far...

  then admin.site.register calls validate() and validate calls get_apps
() which tries to import installed apps at settings.py. output
continues:

  ...
  ...
  admin.site.register(Kategori, KategoriAdmin)
  File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py",
line 76, in register
  validate(admin_class, model)
  File "C:\Python25\Lib\site-packages\django\contrib\admin
\validation.py", line22, in validate
  models.get_apps()
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 97, in get_apps
  self._populate()
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 57, in _populate
  self.load_app(app_name, True)
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 72, in load_app
  mod = __import__(app_name, {}, {}, ['models'])
  File "C:\Documents and Settings\orcun\Desktop\indir\..\indir\haber
\models.py", line 74, in 
  admin.site.register(Haber, HaberAdmin)
  File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py",
line 76, in register
  validate(admin_class, model)
  File "C:\Python25\Lib\site-packages\django\contrib\admin
\validation.py", line 22, in validate
  models.get_apps()
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 97, in get_apps
  self._populate()
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 57, in _populate
  self.load_app(app_name, True)
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 72, in load_app
  mod = __import__(app_name, {}, {}, ['models'])
  File "C:\Documents and Settings\orcun\Desktop\indir\..\indir\inceleme
\models.py", line 3, in 
  from indir.program.models import Program
  ImportError: cannot import name Program

  ..end of the output.

  in some way get_apps() reaches to import Program model from indir/
program/models.py .

  but we still trying to import Program model.

  i still couldn't figured out excatly but thats something like
deadlock:
  to import Program model , we must call get_apps()
  to call get_apps() ,we must import Program model (i'm not
sure. It imports some other models correctly in smilar situations.and
why any other people didn't had the same problem? because i didn't
find if this is discussed before)



  solution was to call get_apps before importing model
  thats the top of my script now:

  >>DIR=os.path.abspath(__file__)
  >>sys.path.append(imp.find_module("django")[1])
  >>sys.path.append(os.path.split(os.path.split(DIR)[0])[0])
  >>setup_environ(settings)
  >>from django.db.models.loading import get_apps
  >>get_apps()
  >>from indir.program.models import Program

  and now works correctly...

  Thanks for help,









On 16 Şubat, 00:13, pkenjora  wrote:
> Hi,
>
>   You need to define the settings file on top of the python path and
> the path to your settings file.  Start with the xample in the post
> below...
>
> http://blog.awarelabs.com/?p=15
>
>   Once you get it to work, back out some of the paths until you find
> the minimum you need.  You will need to type in your own paths...
>
> Cheers,

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



Re: [django] Re: Etags

2009-02-15 Thread Ricardo Newbery


On Feb 15, 2009, at 3:28 PM, Malcolm Tredinnick wrote:

>
> On Sun, 2009-02-15 at 08:30 -0800, mermer wrote:
>> OK - I've found the problem.  I'm using Firefox (Version 3.06) but  
>> the
>> problem is actually with Firebug, which I've been using to view the
>> headers.
>>
>> With Firebug disabled, it works fine (viewing the headers through
>> another app).
>
> Realise that a browser isn't *required* to send if-none-match. So this
> isn't really a bug in Firebug. It's possibly deliberately not sending
> the header to ensure that it sees the full interaction each time,  
> rather
> than a 304 response.
>
> Also, you probably want to make sure you're also handling
> if-modified-since, as that's also used to check for "liveness".
>
> Regards,
> Malcolm


No sorry, this is definitely a Firebug bug.

http://code.google.com/p/fbug/issues/detail?id=1274

Ric




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



Re: mod_wsgi+apache2.2+django1+WindowsXP: can't serve images

2009-02-15 Thread Graham Dumpleton



On Feb 16, 10:19 am, MrBodjangles  wrote:
> I am going thru the sample blog application introduced in the book
> "Python Web Development with Django (covers Django 1.0)".
>
> Before getting too deep into the book, I decided I wanted to first
> ensure that the application will render in apache since I want to
> include an image at the bottom of the blog posts (I have been hacking
> spaghetti code in php for a couple of years now, but now, am intent on
> coding neatly with python).
>
> The blog application works partially in that apache renders the text
> contents, but not the image.
>
> Note the access.log contents in the end ( "GET /media/img/
> people_rose.jpg HTTP/1.1" 404 2001)
>
> I have read so much good stuff about Django that I want to dive into
> it full speed ahead, but now I am stuck in serving a simple image.
>
> Help?
>
> --
> httpd.conf:
> ===
> .
> .
> .
> 
> # I will put this later in a separe conf file
> ###
> # This did not work ==>>>  AliasMatch ^/([^/]+)/media/(.*) "c:/my_wsgi/
> media"
> #
> # trying AliasMatch below...still does not work :>(
> #
>
> AliasMatch ^media/(.*) "c:/my_wsgi/media/"

Use Alias directive, not AliasMatch, as described in mod_wsgi
documentation. See:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

Perform direct URL accesses against stuff in media directory to
ascertain if working or not.

> 
> Order allow,deny
> Options Indexes
> Allow from all
> IndexOptions FancyIndexing
> 
>
> WSGIScriptAliasMatch ^/([^/]+) "c:/my_wsgi/apache/django.wsgi"

Again, read the documentation. Do not use WSGIScriptAliasMatch, use
WSGIScriptAlias.

Why are you using the Match variants? Where did you get the idea you
had to do that?

Try what is in the documentation instead.

Graham

> 
> Order deny,allow
> Allow from all
> 
> 
>
> #
> # DirectoryIndex: sets the file that Apache will serve if a directory
> # is requested.
> .
> .
> .
>
> 
> django.wsgi:
> 
> import os, sys
>
> #Calculate the path based on the location of the WSGI script.
> apache_configuration= os.path.dirname(__file__)
> project = os.path.dirname(apache_configuration)
> workspace = os.path.dirname(project)
>
> sys.path.append(workspace)
> sys.path.append('c:\\my_wsgi')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> 
> settings.py:
> 
> .
> .
> .
> # Absolute path to the directory that holds media.
> # Example: "/home/media/media.lawrence.com/"
> MEDIA_ROOT = ''
>
> # URL that handles the media served from MEDIA_ROOT. Make sure to use
> a
> # trailing slash if there is a path component (optional in other
> cases).
> # Examples: "http://media.lawrence.com;, "http://example.com/media/;
> MEDIA_URL = ''
>
> # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> to use a
> # trailing slash.
> # Examples: "http://foo.com/media/;, "/media/".
> ADMIN_MEDIA_PREFIX = '/media/'
> .
> .
> .
>
> 
> base.html (lives in c:\my_wsgi\blog\templates):
> ==
> .
> .
> .
> 
> {%block content %}
> {%endblock%}
>
>  
>  height="848"> 
> .
> .
> .
>
> -
> access.log:
> =
> 127.0.0.1 - - [15/Feb/2009:15:05:41 -0800] "GET /blog/v_blog/ HTTP/
> 1.1" 200 565
> 127.0.0.1 - - [15/Feb/2009:15:05:43 -0800] "GET /media/img/
> people_rose.jpg HTTP/1.1" 404 2001
> 127.0.0.1 - - [15/Feb/2009:15:05:44 -0800] "GET /favicon.ico HTTP/1.1"
> 404 1944
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mod_wsgi+apache2.2+django1+WindowsXP: can't serve images

2009-02-15 Thread MrBodjangles

I am going thru the sample blog application introduced in the book
"Python Web Development with Django (covers Django 1.0)".

Before getting too deep into the book, I decided I wanted to first
ensure that the application will render in apache since I want to
include an image at the bottom of the blog posts (I have been hacking
spaghetti code in php for a couple of years now, but now, am intent on
coding neatly with python).

The blog application works partially in that apache renders the text
contents, but not the image.

Note the access.log contents in the end ( "GET /media/img/
people_rose.jpg HTTP/1.1" 404 2001)

I have read so much good stuff about Django that I want to dive into
it full speed ahead, but now I am stuck in serving a simple image.

Help?

--
httpd.conf:
===
.
.
.

# I will put this later in a separe conf file
###
# This did not work ==>>>  AliasMatch ^/([^/]+)/media/(.*) "c:/my_wsgi/
media"
#
# trying AliasMatch below...still does not work :>(
#

AliasMatch ^media/(.*) "c:/my_wsgi/media/"

Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing


WSGIScriptAliasMatch ^/([^/]+) "c:/my_wsgi/apache/django.wsgi"

Order deny,allow
Allow from all



#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
.
.
.


django.wsgi:

import os, sys

#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)

sys.path.append(workspace)
sys.path.append('c:\\my_wsgi')

os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


settings.py:

.
.
.
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
.
.
.



base.html (lives in c:\my_wsgi\blog\templates):
==
.
.
.

{%block content %}
{%endblock%}

 
 
.
.
.


-
access.log:
=
127.0.0.1 - - [15/Feb/2009:15:05:41 -0800] "GET /blog/v_blog/ HTTP/
1.1" 200 565
127.0.0.1 - - [15/Feb/2009:15:05:43 -0800] "GET /media/img/
people_rose.jpg HTTP/1.1" 404 2001
127.0.0.1 - - [15/Feb/2009:15:05:44 -0800] "GET /favicon.ico HTTP/1.1"
404 1944




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



Re: Question about templates

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 15:23 -0800, Deniz Dogan wrote:
> Hi
> 
> I'm developing a website which will have a small menu at the top which
> has a "login" link in it. However, if the user has already logged in,
> it should be a "logout" link instead. This menu is part of a base
> template which is extended in all of my other templates.
> 
> So to for the templates to know whether the user has logged in or not,
> should I pass request.user(.is_authenticated()) in each
> render_to_response or is there a simpler solution?

If you consistently pass a RequestContext to render_to_responses, you'll
always have access to a "user" variable in the context (one the standard
context processors inserts it).

Regards,
Malcolm


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



Re: Etags

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 08:30 -0800, mermer wrote:
> OK - I've found the problem.  I'm using Firefox (Version 3.06) but the
> problem is actually with Firebug, which I've been using to view the
> headers.
> 
> With Firebug disabled, it works fine (viewing the headers through
> another app).

Realise that a browser isn't *required* to send if-none-match. So this
isn't really a bug in Firebug. It's possibly deliberately not sending
the header to ensure that it sees the full interaction each time, rather
than a 304 response.

Also, you probably want to make sure you're also handling
if-modified-since, as that's also used to check for "liveness".

Regards,
Malcolm


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



Question about templates

2009-02-15 Thread Deniz Dogan

Hi

I'm developing a website which will have a small menu at the top which
has a "login" link in it. However, if the user has already logged in,
it should be a "logout" link instead. This menu is part of a base
template which is extended in all of my other templates.

So to for the templates to know whether the user has logged in or not,
should I pass request.user(.is_authenticated()) in each
render_to_response or is there a simpler solution?

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



Re: Problems with multithreading in fastcgi environment

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 01:57 -0800, Jacob Rigby wrote:
> The queue solution that Malcolm is talking about requires 3 types of
> processes as far as I can tell:
> - the fcgi/django processes that will be pushing jobs onto the
> queue
> - a manager process that is started independently from the fcgi
> processes and is responsible for maintaining the shared job queue
> - one or more a worker processes that are started by the manager
> in response to jobs it pulls off the queue.  The manager could do the
> offline processing itself, but if you have a lot of cpus you'd be
> missing out on some performance.

Well, that's one way of implementing a queueing system, but certainly
not the only way. Personally, I'd go with the cronjob processing a
database table if I had something straightforward like video converting
to do.

> 
> A simpler solution

>  is to have a cron job run often and either check a
> directory or a database message table for new jobs to run. 

Which is also a queueing system. You're right that it's simpler than the
above description you gave, but that doesn't make it not a queue. :-)

The role of the "manager process", at least as far as maintaining the
TODO list is played by the database server here. Cron plays the role of
starting child processes. In advanced queue manager systems, the
maintainer of the TODO list and the job spawner often aren't the same
process -- the latter talks to the former to retrieve and remove items,
but it has different scheduling and runtime requirements than the TODO
maintainer process.

Regards,
Malcolm


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



Re: Thread safety in views ?

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 23:50 +0200, makka...@gmail.com wrote:
> On Sunday 15 February 2009 10:39:26 pm slav0nic wrote:
> > if u need start new thread - it will be work, but for more "djngo way"
> > use signals
> 
> Well that is not what i'm concerned about, i asked if a view is accessed only 
> by a one client. I dont want 2 views to acces the same xml and have the 
> shared object in a inconsistent format. If the views are not threadsafe what 
> is the best way to modify shared file objects?

Views are just normal Python functions. They aren't intrinsicly thread
safe or unsafe -- it's up to you to manage that. If you're writing data
to disk, you will need to make sure that only one process at a time does
the writing. File locking is a common approach there: before working on
the file (reading or writing), the function should get a lock on the
file in question to ensure only one accessor at a time.

Alternatively, if there's only ever going to be one writer and many
readers and you somehow know that two processes won't both try to write
the file, you can create the file under a temporary name and then move
it into the final name once it's finished. Move is an atomic operation
(other processes will either see the final result of the move or see
nothing) on any decent file system.

Regards,
Malcolm



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



Re: Changing the language in test client

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 13:29 -0800, peschler wrote:
> Hi,
> 
> i'm currently writing unit tests for an application where I need to
> change the language in the test client.
> 
> I tried using the "django.views.i18n.set_language" view within a test
> case like so:
> 
> ---
> def setUp(self):
> self.client.post('/set_language/', data={'language': 'de'})
> 
> def tearDown(self):
> pass
> 
> def test_registration(self):
> # This is just a duplicate to the above, to sanity check if
> this needs to be
> # called from within each test (unfortunately no..)
> self.client.post('/set_language/', data={'language': 'de'})
> print "get_lang", get_language()
> --
> 
> The url "/set_language/" maps correctly to the
> "django.views.i18n.set_language" view, but the language printed in the
> test case after being set to 'de' is still 'en-us'.

You are misunderstanding what the set_language view does. That view sets
up the client's locale cookie so that whenever a view is processed for
that particular web client, it will be done in the locale of "de" (in
your case). 

It does not change the global locale of the entire Django process, or
the test framework or anything like that. If you are wanting to run a
particular test in a certain locale, you will have to call
translation.activate() at the start of the function and
translation.deactivate() at the end -- don't forget the second one or
other tests will fail due to being in an unexpected locale.

If you are wanting to test the data returned for a particular client
request in a given locale, then using set_language and then making the
request will be the right approach. But it's not a "control the global
locale" function (after all, a single Django install could well be
serving content in many languages simultaneously).

Regards,
Malcolm



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



Re: Add views to admin interface

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 11:06 -0800, Robert wrote:
> Hi,
> 
> how can I add views to the admin interface that
> 1. they are also so 'well-integrated' in the admin interface like
> models
> 2. I can also define permissions for them like for a model

Adding views to the admin is easy, since a view is just the target of a
URL. So alter the admin template that you want to have the new link
appear on. You don't have to modify the source, just create an
overriding template in your project.

If you use the filesystem loader to load the template (that is, set up a
directory using TEMPLATE_DIRS), and if you haven't changed the default
order of the TEMPLATE_LOADERS setting, any templates in TEMPLATE_DIRS
will be loaded before app-specific templates. So you create, e.g,
admin/index.html in a directory in TEMPLATE_DIRS and it will override
the default admin one.

Once you have added a new HTML link to the template that will trigger
your view, you have to write a view for it. You add something to one of
your URL Conf files to catch the URL (do this *before* any admin
patterns are processed, so that your pattern is handled first) and send
it off to the view you have written. That view will just be a normal
Django view, so you can use the normal permission decorators on the view
if you like.

Regards,
Malcolm


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



Re: Dynamically traversing a list in templates

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 6:02 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Sun, 2009-02-15 at 15:09 -0500, Alex Gaynor wrote:
> >
> >
> > On Sun, Feb 15, 2009 at 3:07 PM, nivhab  wrote:
> >
> > Thanks for the fast reply!
> > This generates the following error:
> > 'for' statements with five words should end in 'reversed'
> >
> > And as I have just found out, this error cannot be solved in
> > 0.96
> > version. So it seems there is no way of doing such and
> > iteration in
> > this version. Only 1.0 or DEV versions.
>
> [...]
> >
> > b) Yeah, this isnt' possible on .96, what you can do is iterate over
> > the keys {% for key in dictionary %} and then write a filter or tag to
> > get the item out of the dictionary by key.
>
> Or you can just do it the simple way that has always worked (way back to
> the first release of Django):
>
>{% for element in dictionary.items %}
>   key is {{ element.0 }}
>   value is {{ element.1 }}
>{% endfor %}
>
> To understand this, remember that items() returns a list of 2-tuples
> and .0 and .1 provide access to the first two elements of a sequence
> (e.g. tuple).
>
> The {% for key,value in dictionary.items %} form is only syntactic
> sugar. It didn't make anything possible that wasn't previously so.
>
> Regards,
> Malcolm
>
>
>
> >
>
Thanks Malcolm, can't believe I forgot that.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Dynamically traversing a list in templates

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 15:09 -0500, Alex Gaynor wrote:
>  
> 
> On Sun, Feb 15, 2009 at 3:07 PM, nivhab  wrote:
> 
> Thanks for the fast reply!
> This generates the following error:
> 'for' statements with five words should end in 'reversed'
> 
> And as I have just found out, this error cannot be solved in
> 0.96
> version. So it seems there is no way of doing such and
> iteration in
> this version. Only 1.0 or DEV versions.

[...]
> 
> b) Yeah, this isnt' possible on .96, what you can do is iterate over
> the keys {% for key in dictionary %} and then write a filter or tag to
> get the item out of the dictionary by key.

Or you can just do it the simple way that has always worked (way back to
the first release of Django):

{% for element in dictionary.items %}
   key is {{ element.0 }}
   value is {{ element.1 }}
{% endfor %}

To understand this, remember that items() returns a list of 2-tuples
and .0 and .1 provide access to the first two elements of a sequence
(e.g. tuple).

The {% for key,value in dictionary.items %} form is only syntactic
sugar. It didn't make anything possible that wasn't previously so.

Regards,
Malcolm



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



Re: how to automatically call an additional function on saving a model?

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 5:09 PM, Gabor Nyers  wrote:

>
> Hi all,
>
> I'm learning Django (and for that matter Python) for 2 weeks now and bumped
> into a problem I've been struggling with a
> few days. Apologies if it's obvious, but I've been looking at the Django
> documentation for 2 days now. It might be
> there, but in that case I think I keep missing it. Can someone drop me a
> line with a suggestion how to solve this (or
> where to look)?
>
> I have two models:
> - Request
> - RequestItem
>
> A Request contains multiple Request items. I'm using the Admin interface
> like this:
>
> class RequestItemInline (admin.TabularInline):
>model = ResourceRequestItem
>
> class RequestAdmin(admin.ModelAdmin):
>model = Request
>inlines = [ RequestItemInline ]
>
> I want to automatically call a function for every RequestItem object each
> time I'm saving a RequestAdmin form. This
> function is defined in RequestItem's model.
>
> Any suggestions?
>
> Regards,
> Gábor
>
> >
>
I'm not 100% I follow, but you're looking for one of these 2 methods:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: "setup_environ" can't help to run a standalone script

2009-02-15 Thread pkenjora

Hi,

  You need to define the settings file on top of the python path and
the path to your settings file.  Start with the xample in the post
below...

http://blog.awarelabs.com/?p=15

  Once you get it to work, back out some of the paths until you find
the minimum you need.  You will need to type in your own paths...

Cheers,

- Paul

On Feb 15, 12:02 pm, Orcun Avsar  wrote:
> i added
>
> from django.db.models.loading import get_apps
> get_apps()
>
> before calling models
> and it solved the problem
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to automatically call an additional function on saving a model?

2009-02-15 Thread Gabor Nyers

Hi all,

I'm learning Django (and for that matter Python) for 2 weeks now and bumped 
into a problem I've been struggling with a
few days. Apologies if it's obvious, but I've been looking at the Django 
documentation for 2 days now. It might be
there, but in that case I think I keep missing it. Can someone drop me a line 
with a suggestion how to solve this (or
where to look)? 

I have two models: 
- Request
- RequestItem

A Request contains multiple Request items. I'm using the Admin interface like 
this:

class RequestItemInline (admin.TabularInline):
model = ResourceRequestItem

class RequestAdmin(admin.ModelAdmin):
model = Request
inlines = [ RequestItemInline ]

I want to automatically call a function for every RequestItem object each time 
I'm saving a RequestAdmin form. This
function is defined in RequestItem's model.

Any suggestions?

Regards,
Gábor

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



Re: newbie : bring variables from template to view

2009-02-15 Thread adelevie

Have you learned ajax?

On Feb 15, 9:32 am, arbi  wrote:
> Hi,
>
> In my template I call a javascript function that returns a dictionary.
> I would like to bring back the 2 elements of this dictionary in my
> view to make some work on it.
> How to do it? Use forms? how?
>
> Thx for help on this point :)
>
> Arbi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Thread safety in views ?

2009-02-15 Thread makkalot

On Sunday 15 February 2009 10:39:26 pm slav0nic wrote:
> if u need start new thread - it will be work, but for more "djngo way"
> use signals

Well that is not what i'm concerned about, i asked if a view is accessed only 
by a one client. I dont want 2 views to acces the same xml and have the 
shared object in a inconsistent format. If the views are not threadsafe what 
is the best way to modify shared file objects?

>
> On 15 фев, 19:59, makka...@gmail.com wrote:
> > Hi all i generate some xml files for my gallery app on every new request
> > (i use cache also). That mean i do some file operation on most of gallery
> > requests. I'm concerned about having the xml file in a inconsistent
> > format. Therefore are the django views thread-safe or how can i solve
> > that issue ?
>



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



Changing the language in test client

2009-02-15 Thread peschler

Hi,

i'm currently writing unit tests for an application where I need to
change the language in the test client.

I tried using the "django.views.i18n.set_language" view within a test
case like so:

---
def setUp(self):
self.client.post('/set_language/', data={'language': 'de'})

def tearDown(self):
pass

def test_registration(self):
# This is just a duplicate to the above, to sanity check if
this needs to be
# called from within each test (unfortunately no..)
self.client.post('/set_language/', data={'language': 'de'})
print "get_lang", get_language()
--

The url "/set_language/" maps correctly to the
"django.views.i18n.set_language" view, but the language printed in the
test case after being set to 'de' is still 'en-us'.
Can anybody help me here?
My projects settings.py contains the following variables:
---
LANGUAGE_CODE = 'de-de'

# Languages for modeltranslations
gettext = lambda s: s
LANGUAGES = (
('de', gettext('German')),
('en', gettext('English')),
)
---
As "en-us" is nowhere used here I don't quite understand where the
get_language() call is getting the value from.

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



Apache & Printing

2009-02-15 Thread LizzyLiz

Hi

I've got a problem printing - I'm using the win32 API:

win32api.ShellExecute (0, "print", myfile, None, ".", 0)

This works just fine if I don't run Django through apache but when I
use apache it doesn't work.  I don't get an error just nothing in the
print queue.  I've set the apache service to run as my user but same
problem.

Any ideas?

Many thanks
Liz

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



Re: Thread safety in views ?

2009-02-15 Thread slav0nic

if u need start new thread - it will be work, but for more "djngo way"
use signals

On 15 фев, 19:59, makka...@gmail.com wrote:
> Hi all i generate some xml files for my gallery app on every new request (i
> use cache also). That mean i do some file operation on most of gallery
> requests. I'm concerned about having the xml file in a inconsistent format.
> Therefore are the django views thread-safe or how can i solve that issue ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add views to admin interface

2009-02-15 Thread Robert

Well, I read that short paragraph but I don't understand how this
should work...
Is it possible that you post some code how you solved that problem?

Thanks a lot
Robert

On 15 Feb., 21:13, Brian Neal  wrote:
> On Feb 15, 1:06 pm, Robert  wrote:
>
> > Hi,
>
> > how can I add views to the admin interface that
> > 1. they are also so 'well-integrated' in the admin interface like
> > models
> > 2. I can also define permissions for them like for a model
>
> > I know that it's possible to change a template (i.e. index.html) and
> > add there the code, but that doesn't satisfy me because neither the
> > one nor the other point above is done...
> > Best would be if there were a possiblity to register them like models
> > (admin.site.register(View, ViewAdmin)...
>
> > Greetz Robert
>
> I'd like to hear more about this as well. The Django docs don't say
> much about this, but the Django Book still has a section on this that
> is still relevant to 1.0. Seehttp://www.djangobook.com/en/1.0/chapter17/
> and scroll down to the section titled "Creating Custom Admin Views". I
> used the advice in there to create a custom admin view that allowed a
> site admin to send a bulk email to all people registered with the site
> email list.
>
> I'm not quite sure if this is what you are asking about, but look it
> over and see.
>
> Best,
> BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add views to admin interface

2009-02-15 Thread Brian Neal

On Feb 15, 1:06 pm, Robert  wrote:
> Hi,
>
> how can I add views to the admin interface that
> 1. they are also so 'well-integrated' in the admin interface like
> models
> 2. I can also define permissions for them like for a model
>
> I know that it's possible to change a template (i.e. index.html) and
> add there the code, but that doesn't satisfy me because neither the
> one nor the other point above is done...
> Best would be if there were a possiblity to register them like models
> (admin.site.register(View, ViewAdmin)...
>
> Greetz Robert

I'd like to hear more about this as well. The Django docs don't say
much about this, but the Django Book still has a section on this that
is still relevant to 1.0. See http://www.djangobook.com/en/1.0/chapter17/
and scroll down to the section titled "Creating Custom Admin Views". I
used the advice in there to create a custom admin view that allowed a
site admin to send a bulk email to all people registered with the site
email list.

I'm not quite sure if this is what you are asking about, but look it
over and see.

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



Re: Dynamically traversing a list in templates

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 3:07 PM, nivhab  wrote:

>
> Thanks for the fast reply!
> This generates the following error:
> 'for' statements with five words should end in 'reversed'
>
> And as I have just found out, this error cannot be solved in 0.96
> version. So it seems there is no way of doing such and iteration in
> this version. Only 1.0 or DEV versions.
>
> On Feb 15, 9:57 pm, Alex Gaynor  wrote:
> > On Sun, Feb 15, 2009 at 2:47 PM, nivhab  wrote:
> >
> > > Does anyone know of a way to traverse a list in templates in a dynamic
> > > way?
> > > Let's say I have the following list:
> > > {'message': [u'This field is required.'], 'sender': [u'Enter a valid e-
> > > mail address.']}
> >
> > > and I do not know in advance the keys for this list. I would like to
> > > iterate through it and display its content (keys and values) in a
> > > dynamic way in a template. Can it be done?
> >
> > > Thanks in advance!
> >
> > First of all that's not a list, it's a dictionary, but you can iterate
> over
> > a dictionary just as easily:
> >
> > {% for key, value in dictionary %}
> > {{ key }}: {% for v in value %} {{ v }}{% endfor %}
> > {% endfor %}
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
a) I made a typo in my original post for those who are on 1.0 that should be
{% for key, value in dictionary.iteritems %}
b) Yeah, this isnt' possible on .96, what you can do is iterate over the
keys {% for key in dictionary %} and then write a filter or tag to get the
item out of the dictionary by key.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Dynamically traversing a list in templates

2009-02-15 Thread nivhab

Thanks for the fast reply!
This generates the following error:
'for' statements with five words should end in 'reversed'

And as I have just found out, this error cannot be solved in 0.96
version. So it seems there is no way of doing such and iteration in
this version. Only 1.0 or DEV versions.

On Feb 15, 9:57 pm, Alex Gaynor  wrote:
> On Sun, Feb 15, 2009 at 2:47 PM, nivhab  wrote:
>
> > Does anyone know of a way to traverse a list in templates in a dynamic
> > way?
> > Let's say I have the following list:
> > {'message': [u'This field is required.'], 'sender': [u'Enter a valid e-
> > mail address.']}
>
> > and I do not know in advance the keys for this list. I would like to
> > iterate through it and display its content (keys and values) in a
> > dynamic way in a template. Can it be done?
>
> > Thanks in advance!
>
> First of all that's not a list, it's a dictionary, but you can iterate over
> a dictionary just as easily:
>
> {% for key, value in dictionary %}
>     {{ key }}: {% for v in value %} {{ v }}{% endfor %}
> {% endfor %}
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamically traversing a list in templates

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 2:47 PM, nivhab  wrote:

>
> Does anyone know of a way to traverse a list in templates in a dynamic
> way?
> Let's say I have the following list:
> {'message': [u'This field is required.'], 'sender': [u'Enter a valid e-
> mail address.']}
>
> and I do not know in advance the keys for this list. I would like to
> iterate through it and display its content (keys and values) in a
> dynamic way in a template. Can it be done?
>
> Thanks in advance!
>
> >
>
First of all that's not a list, it's a dictionary, but you can iterate over
a dictionary just as easily:

{% for key, value in dictionary %}
{{ key }}: {% for v in value %} {{ v }}{% endfor %}
{% endfor %}

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Trying to get data from template to view...

2009-02-15 Thread nivhab

If you'd like JavaScript to calculate values before you submit the
form then do the following:

1. Add a "onSubmit" attribute on your "form" tag which calls a JS
function like:


2. In the implementation of that function calculate whatever you need
and plant the result into a hidden input field inside your form OR
change the value of an existing input field.

3. When you're done, your function should return "true" so that the
form submits.

Now the form submits with the value you have calculated.
Good luck.
Yaniv


On Feb 15, 6:56 pm, arbi  wrote:
> Hi all,
>
> In fact my pb is : I have a  that sends a DATA that the user
> writes (input), but I would like it to send javascript_function(DATA)
> instead. How to do it?
>
> This is my input. The DATA is a "departure"
> 
>
> What shoud I write instead of name or value to return the
> javascript_function(departure) instead of departure only? (my js
> function calculates the latitude in fact).
>
> In general, how to bring back to view javascript results?
>
> Thanks a lot!
> Arbi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dynamically traversing a list in templates

2009-02-15 Thread nivhab

Does anyone know of a way to traverse a list in templates in a dynamic
way?
Let's say I have the following list:
{'message': [u'This field is required.'], 'sender': [u'Enter a valid e-
mail address.']}

and I do not know in advance the keys for this list. I would like to
iterate through it and display its content (keys and values) in a
dynamic way in a template. Can it be done?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Add views to admin interface

2009-02-15 Thread Robert

Hi,

how can I add views to the admin interface that
1. they are also so 'well-integrated' in the admin interface like
models
2. I can also define permissions for them like for a model

I know that it's possible to change a template (i.e. index.html) and
add there the code, but that doesn't satisfy me because neither the
one nor the other point above is done...
Best would be if there were a possiblity to register them like models
(admin.site.register(View, ViewAdmin)...

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



Re: "setup_environ" can't help to run a standalone script

2009-02-15 Thread Orcun Avsar

i added

from django.db.models.loading import get_apps
get_apps()

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



Re: Accessing new_object when processing formsets in Admin

2009-02-15 Thread Michael P. Soulier
On 14/02/09 Rick Kitts said:

> Assuming the "main" form is valid I want to get the value of the FK to  
> the Address from the "main" form and use it when processing the forms  
> in the formset.

I haven't tried formsets yet, but I currently do conditional validation of
forms based on whether a given form is valid, sometimes passing a valid form
to the next in the sequence since at times information in them cannot be
duplicated.

Django doesn't seem to be designed for much of this conditional validation,
but it certainly can be done.

Mike
-- 
Michael P. Soulier 
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein


pgpeIqgBL4Cpq.pgp
Description: PGP signature


AuthKit (WSGI middleware) and Django

2009-02-15 Thread Dennis

Wondering if it's common to modify WSGI middleware packages to be used
in django.
Also, wondering if it's difficult to do.

I'm building a website with user authentication similar to facebook
(so the user can stay logged in forever).
Django's contrib auth module did not seem to be the right match since
it's session based and I don't want to keep the session around
forever.
Also, I'm building on google's appengine where django does not have
sessions.

I'm thinking of using AuthKit, a wsgi middleware package, and
wondering if anyone has experience
porting AuthKit or other wsgi middleware to django.
Is it difficult?
Is it recommended (or is it recommended that I don't do 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Thread safety in views ?

2009-02-15 Thread makkalot

Hi all i generate some xml files for my gallery app on every new request (i 
use cache also). That mean i do some file operation on most of gallery 
requests. I'm concerned about having the xml file in a inconsistent format. 
Therefore are the django views thread-safe or how can i solve that issue ?

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



Svn pre-commit hooks with beanstalkapp.com

2009-02-15 Thread Sean Brant

Has anyone created a work around for lack of pre-commit support at
beanstalkapp.com. I would like to run tests on my apps before they get
committed to my repository however with beanstalk you do not get
access to subversion hooks. I was thinking of creating a python script
that would preform the tests and then do the commit if they pass. If
you have run into this before I would be interested in your solution.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble adding custom view to admin-site instance

2009-02-15 Thread michael.hess...@googlemail.com

Thanks, I'll have a read

On Feb 15, 5:59 pm, pkenjora  wrote:
> Hi,
>
>   There is always more than one way to do anything.  For reference you
> may be interested in a custom action (not view) approach within
> admin...
>
> http://blog.awarelabs.com/?p=75
>
>   I've used this for one click emails or custom user reports.  May be
> a bit dated but still useful... "Custom Actions In Django Admin Object
> Editor"
>
> Cheers,
>
> -Paul
>
> On Feb 15, 7:16 am, "michael.hess...@googlemail.com"
>
>  wrote:
> > Hi,
> > I'm trying to add a custom view to a custom admin-site instance, as
> > documented 
> > there:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-views-...
>
> > In my rather small example project I've got this custom admin class.
> > It works just fine, I can register ModelAdmins and so on.
>
> > from urls.py
> > ...
> > (r'^my/(.*)', myad.sites.my_site.root),
> > ...
>
> > class CreationAdminSite(sites.AdminSite):
> >    def get_urls(self):
> >       urls = super(CreationAdminSite, self).get_urls()
> >       my_urls = patterns('',
> >          (r'^myview/$', 'mic.myad.views.show')
> >       )
> >       return my_urls + urls
> > my_site = CreationAdminSite()
>
> > Calling my/myview won't work however. (It should, right?)
> > The pattern shows up when introspecting with python manage.py shell
>
> > (InteractiveConsole)>>> from mic.myad.sites import my_site
> > >>> my_site.get_urls()
>
> > [, ,
> > ,  > admin_password_change ^password_change/$>,  > admin_password_change_done ^password_change/done/$>,  > admin_jsi18n ^jsi18n/$>, 
> > \d+)/(?P.+)/$>,  > P\w+)/$>]
>
> > The first pattern is right there, and so this should work or did I do
> > something wrong? I just can't see why this isn't working...
>
> > Any help would be greatly appreciated ;)
>
> > ps running 9832, "fresh" checkout
>
> > pps Same thing when trying to overwrite the get_urls() from a
> > ModelAdmin, that won't work also.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble adding custom view to admin-site instance

2009-02-15 Thread pkenjora

Hi,

  There is always more than one way to do anything.  For reference you
may be interested in a custom action (not view) approach within
admin...

http://blog.awarelabs.com/?p=75

  I've used this for one click emails or custom user reports.  May be
a bit dated but still useful... "Custom Actions In Django Admin Object
Editor"

Cheers,

-Paul

On Feb 15, 7:16 am, "michael.hess...@googlemail.com"
 wrote:
> Hi,
> I'm trying to add a custom view to a custom admin-site instance, as
> documented 
> there:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-views-...
>
> In my rather small example project I've got this custom admin class.
> It works just fine, I can register ModelAdmins and so on.
>
> from urls.py
> ...
> (r'^my/(.*)', myad.sites.my_site.root),
> ...
>
> class CreationAdminSite(sites.AdminSite):
>def get_urls(self):
>   urls = super(CreationAdminSite, self).get_urls()
>   my_urls = patterns('',
>  (r'^myview/$', 'mic.myad.views.show')
>   )
>   return my_urls + urls
> my_site = CreationAdminSite()
>
> Calling my/myview won't work however. (It should, right?)
> The pattern shows up when introspecting with python manage.py shell
>
> (InteractiveConsole)>>> from mic.myad.sites import my_site
> >>> my_site.get_urls()
>
> [, ,
> ,  admin_password_change ^password_change/$>,  admin_password_change_done ^password_change/done/$>,  admin_jsi18n ^jsi18n/$>, 
> \d+)/(?P.+)/$>,  P\w+)/$>]
>
> The first pattern is right there, and so this should work or did I do
> something wrong? I just can't see why this isn't working...
>
> Any help would be greatly appreciated ;)
>
> ps running 9832, "fresh" checkout
>
> pps Same thing when trying to overwrite the get_urls() from a
> ModelAdmin, that won't work also.

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



Re: Changing the name of a project

2009-02-15 Thread pkenjora

Hi,

  Try using the django-admin.py runserver ... --settings=.., I
abandoned manage.py several projects ago as it consistently did not
work for me.  Mainly because I typically don't start with a fresh
project every time, I copy existing ones and modify.

  If that works then we may need to file a bug for manage.py as it is
coupled to something useless.  I'd be curious to know if the django-
admin.py approach works for you...

Cheers,

-Paul

On Feb 15, 6:15 am, Lee Braiden  wrote:
> Hi Malcom,
>
> 2009/2/15 Malcolm Tredinnick :
>
> > Um .. names are how we refer to things in both the real world and code.
>
> OK, this discussion is going nowhere without concrete examples, so
> I'll leave it here and just submit patches later.
>
> Regards,
>
> --
> Lee
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Trying to get data from template to view...

2009-02-15 Thread arbi

Hi all,

In fact my pb is : I have a  that sends a DATA that the user
writes (input), but I would like it to send javascript_function(DATA)
instead. How to do it?

This is my input. The DATA is a "departure"


What shoud I write instead of name or value to return the
javascript_function(departure) instead of departure only? (my js
function calculates the latitude in fact).

In general, how to bring back to view javascript results?

Thanks a lot!
Arbi

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



Re: Etags

2009-02-15 Thread mermer

OK - I've found the problem.  I'm using Firefox (Version 3.06) but the
problem is actually with Firebug, which I've been using to view the
headers.

With Firebug disabled, it works fine (viewing the headers through
another app).



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



Re: Different ways of working against a SQLite3 dB

2009-02-15 Thread Karen Tracey
On Sun, Feb 15, 2009 at 10:31 AM, DaSa  wrote:

>
> Thx! But I have the correct chcp coding. I can write swedish signs in
> the promt, it is when I try to add them in the SQLite3 dB it goes
> wrong.
>
> I believe it is the "python manage.py shell" that can't handle swedish
> signs. If I insert an object containing swedish signs from the admin
> site and read it out in the "manage.py shell" I get weir signs.
>

That sounds like you may be hitting this Python issue:

http://bugs.python.org/issue1288615

If you are hitting that, it was fixed in Python 2.6 so you could try
upgrading.  Alternatively you could just patch whatever version of Python
you are running, it's a pretty simple fix:

http://svn.python.org/view/python/trunk/Lib/code.py?rev=65578=diff=65578=65577=python/trunk/Lib/code.py=/python/trunk/Lib/code.py


> Are there any other APIs I can use against the database?
>

Sure, just write a python script to do whatever you are planning on doing in
the interactive shell?  (It isn't entirely clear to me how using manage.py
shell is that much better than the admin interface for bulk data importing
-- I'd expect a script would be much better.  But maybe you are just trying
it out in the shell and concluding the script won't work because the shell
is not working.  If so, and if it is that Python issue, the script won't be
subject to the same problem so will likely work.)

Karen

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



Re: Charts for Admin Interface

2009-02-15 Thread Alex Gaynor
On Sun, Feb 15, 2009 at 10:20 AM, Peter Herndon  wrote:

>
> I don't have the URL handy, but the admin docs contain pointers on how
> to add extra URLs to your admin site.  Create a view, make a template,
> add the URL, profit!!  So if you want charts in your admin, such a
> task is well within the capabilities of Django for you to add.
>
> On 2/13/09, Robert  wrote:
> >
> > Dear Community,
> >
> > did ever anybody try to add charts (i.e. with ReportLab) to the admin
> > interface? I think it would be a very nice feature to show
> > statistics, ... First the user should be able to make some choices and
> > then depending on these choices django should create a chart (values
> > of course out of a mysql db) and display it.
> > It's no problem to register a new model for the admin interface. But I
> > don't know how I can add things like Charts or PDFs, ...
> > I hope anybody can give me a help in this case!
> >
> > Nice regards
> > Robert
> > >
> >
>
> >
>
Just a note, the docs you're refering to about adding urls are for the trunk
version of Django ONLY, 1.0 has a different mechanism which isn't
documented.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: assertRaises doesnt catch custom error

2009-02-15 Thread pault

Thanks Karen, it now works as expected ! .

In the tutorial 
http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01
they use the proj in imports but I think the your first option is
better as it is more pluggable in other projects that way.
I wonder if there are any pros to do it like that as your option looks
"better practice"?

Thanks again for your help.

regards Paul



On Feb 15, 4:18 pm, Karen Tracey  wrote:
> On Sun, Feb 15, 2009 at 9:46 AM, pault  wrote:
>
> > Malcom many thanks for your reply I created a new project and app to
> > with only one model and one test.
> > It still fails I know I am missing something but I cant figure out
> > what that is.
>
> > I tested this on both mac OSx10.5 and vista (both python 2.5.1 and
> > django version 1.02)
>
> > Here are my models.py and my tests.py
> >http://dpaste.com/120843/
>
> > The only other thing I changed is add myproj.myapp to my
> > INSTALLED_APPS
>
> Specify just myapp, not myproj.myapp, in INSTALLED_APPS.
>
> Alternatively the error can be fixed by changing:
>
> from myapp.models import Company,CustomError
>
> to:
>
> from myproj.myapp.models import Company,CustomError
>
> in your tests.py, but that isn't what I would do.  The fact that it works to
> fix the error just points towards the fact that you need to be consistent in
> whether it's myproj.myapp.models or just myapp.models you are using.  I
> think it's generally easier (and more re-usable when you want to move things
> from project to project) to consistently omit the project part in the
> imports, so I'd go with the first option.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Mutli-Assignable Models

2009-02-15 Thread Peter Herndon

Hi Justin,

I can't view your code at the moment, but it seems to me you want a
ForeignKey on Article to Show, another FK on Photo to Show, an M2M
from Article to Photo, and a custom manager on Show, or some other
custom method, that returns both Articles and Photos.  The latter
might best be accomplished by having Articles and Photos inherit from
some common model, and have Show pull from that common ancestor and
then descend to the specific type as needed.  The common model would
be where you'd have the FK to Show, thinking about it, and then you
wouldn't need a custom method on Show, you could just use std methods.

---Peter

On 2/12/09, Justin Lilly  wrote:
>
> Hi all.
>
>   I have a project where I need to assign multiple models to each
>   other via some many to many relationship.
>
>   There are a few main players in my prototype: Articles, Photos and
>   Shows. Shows has many Articles and Photos. Article has many Photos,
>   but has one Show. Photos has one Show, but has many Articles. (Might
>   make more sense below) There will be more models involved in this
>   process when this app goes to production, but these 3 will do for
>   prototyping.
>
>   My initial thought was to have an intermediate model with 2 generic
>   relationships. I think this is going to be too costly in terms of
>   performance as I'll need to run 2x the queries per lookup. One to
>   check if my lookup object is referenced in the first generic
>   relationship, then to see if its referenced in the 2nd one.
>
>   The next idea was to have a self-referential m2m field for my models
>   to inherit from. The issue there is the lookup returns objects whose
>   type is that of the parent model, not the child model.
>
>   I'm looking for a way to accomplish queries similar to this:
>
>   >>> myshow
>   
>   >>> myshow.related.all()
>   [, , , , ]
>   >>> photo1 = myshow.related.all()[0]
>   >>> photo1.related.all()
>   [, , , ]
>
>   The self referential model code I was using can be found at
>   http://dpaste.com/119897/ and an ipython session at
>   http://dpaste.com/119898/ . I feel as if I may be stretching what
>   model inheritance was meant for or at least what its currently
>   capable of.
>
>   Although everyone says it, the solution will need to scale to a
>   large number of users as it will be used in a very large
>   dynamic-content site. This is the core of the content plan (to
>   present various content types based on a given "pivot point", in the
>   illustrated case above, shows).
>
>   Looking for any advice or help you may be able to provide.
>
>  -justin
>
> >
>

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



Re: Different ways of working against a SQLite3 dB

2009-02-15 Thread DaSa

Thx! But I have the correct chcp coding. I can write swedish signs in
the promt, it is when I try to add them in the SQLite3 dB it goes
wrong.

I believe it is the "python manage.py shell" that can't handle swedish
signs. If I insert an object containing swedish signs from the admin
site and read it out in the "manage.py shell" I get weir signs.

Are there any other APIs I can use against the database?


Best regards
Daniel

On Feb 15, 2:00 pm, Daniel Roseman 
wrote:
> On Feb 15, 12:53 pm, DaSa  wrote:
>
>
>
> > Hi,
>
> > Maybe this is a SQLite question, but a guess many Django users uses
> > SQLite3.
>
> > I have a lot of data that I want to export to my SQLite3 database. My
> > problem is that the data contains special signs (swedish åäö) and
> > therefore is it not possible to insert the data through "windows
> > command prompt" (and SQLite3 shell) because the windows command prompt
> > does not support swedish signs.
>
> > It works when I,am adding the data through my admin site (Django
> > default admin site), but because of the amount of data it is not
> > possible to add the item one and one.
>
> > My question are if there are any more ways of inserting the data into
> > the SQLite3 dB? Is it possible to open the SQLite3 shell without CMD?
>
> > Thx!
>
> > Best regards
> > Daniel Sandberg
>
> I don't know the answer - or anything about sqlite3 on Windows - but
> it is possible to change the character encoding on the Windows command
> shell. See the 'chcp' command, you should be able to find the correct
> one to allow you to use Swedish characters.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble adding custom view to admin-site instance

2009-02-15 Thread michael.hess...@googlemail.com

well, of course

replaced this
(r'^my/(.*)', myad.sites.my_site.root),

with this
(r'^my/', include(myad.sites.my_site.urls)),

in urls.py and it works a treat ;)


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



Re: Charts for Admin Interface

2009-02-15 Thread Peter Herndon

I don't have the URL handy, but the admin docs contain pointers on how
to add extra URLs to your admin site.  Create a view, make a template,
add the URL, profit!!  So if you want charts in your admin, such a
task is well within the capabilities of Django for you to add.

On 2/13/09, Robert  wrote:
>
> Dear Community,
>
> did ever anybody try to add charts (i.e. with ReportLab) to the admin
> interface? I think it would be a very nice feature to show
> statistics, ... First the user should be able to make some choices and
> then depending on these choices django should create a chart (values
> of course out of a mysql db) and display it.
> It's no problem to register a new model for the admin interface. But I
> don't know how I can add things like Charts or PDFs, ...
> I hope anybody can give me a help in this case!
>
> Nice regards
> Robert
> >
>

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



Re: assertRaises doesnt catch custom error

2009-02-15 Thread Karen Tracey
On Sun, Feb 15, 2009 at 9:46 AM, pault  wrote:

>
> Malcom many thanks for your reply I created a new project and app to
> with only one model and one test.
> It still fails I know I am missing something but I cant figure out
> what that is.
>
> I tested this on both mac OSx10.5 and vista (both python 2.5.1 and
> django version 1.02)
>
> Here are my models.py and my tests.py
> http://dpaste.com/120843/
>
> The only other thing I changed is add myproj.myapp to my
> INSTALLED_APPS
>

Specify just myapp, not myproj.myapp, in INSTALLED_APPS.

Alternatively the error can be fixed by changing:

from myapp.models import Company,CustomError

to:

from myproj.myapp.models import Company,CustomError

in your tests.py, but that isn't what I would do.  The fact that it works to
fix the error just points towards the fact that you need to be consistent in
whether it's myproj.myapp.models or just myapp.models you are using.  I
think it's generally easier (and more re-usable when you want to move things
from project to project) to consistently omit the project part in the
imports, so I'd go with the first option.

Karen

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



Re: assertRaises doesnt catch custom error

2009-02-15 Thread pault

Malcom many thanks for your reply I created a new project and app to
with only one model and one test.
It still fails I know I am missing something but I cant figure out
what that is.

I tested this on both mac OSx10.5 and vista (both python 2.5.1 and
django version 1.02)

Here are my models.py and my tests.py
http://dpaste.com/120843/

The only other thing I changed is add myproj.myapp to my
INSTALLED_APPS

On 15 feb, 03:31, Malcolm Tredinnick  wrote:
> On Sat, 2009-02-14 at 11:28 -0800, pault wrote:
> > I have defined a custom error but if I test if custom error gets
> > raised it fails if I test for Exception the test passes
>
> > class CustomError(Exception):
> >     """
> >     This exception is my custom error
> >     """
>
> > class Company(models.Model):
> >     name = models.CharField(max_length=200)
>
> >     def test_error(self):
> >         raise CustomError('hello')
>
> > and in my tests.py:
>
> > import unittest
> > from api.models import
> > Company,Customer,Employee,Location,Product,ProductCategory,AllreadyPayedError,CustomError
>
> > #class AllreadyPayedException(Exception): pass
>
> You mean AlreadyPaidException. Trust me on this. :-)
>
>
>
>
>
> > class CompanyTestCase(unittest.TestCase):
> >     def setUp(self):
> >         self.company = Company.objects.create(name="lizto")
>
> >     def test2(self):
> >         self.assertRaises(CustomError, self.company.test_error)
>
> > ==
> > ERROR: test2 (lizto.api.tests.CompanyTestCase)
> > --
> > Traceback (most recent call last):
> >   File "/Users/.../tests.py", line 27, in test2
> >     self.assertRaises(CustomError, self.company.test_error)
> >   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> > python2.5/unittest.py", line 320, in failUnlessRaises
> >     callableObj(*args, **kwargs)
> >   File "/Users/../models.py", line 17, in test_error
> >     raise CustomError('hello')
> > CustomError: hello
>
> Using the code you provide (after removing the imports that don't exist
> in the code you provide), this works perfectly for me. So there's
> something special about your setup.
>
> If I were you, I'd start from the simple example you show. Create an app
> that only contains that models.py and that tests.py and fix the import
> line to remove everything except Company and CustomError. That's what
> passes for me.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Etags

2009-02-15 Thread Karen Tracey
On Sun, Feb 15, 2009 at 5:59 AM, mermer  wrote:

>
> I am trying to get Etags working in Django - so that if a page has not
> been updated (and the client has already seen the page) it is returned
> by the client's browser rather than rendered by django.
>
> The code below is proof of concept.   However, it only partially
> works, and that's why I'm asking for help.
>
> When the client first connects the code correctly renders the page and
> returns an ETAG header.
>
> On the next request, the browser correctly sends the "If None Mach"
> request header with the ETAG details. The code correctly returns the
> 304 respose and the client displays the page from the browser's
> caache.
>
> So far so good.
>
> However, on the third request, it seems that the browser does not send
> a "If-None_match" request header, so the etag is not found and the
> whole page re-renders from the server.
>
> Is there something else I need to configure?  Or something I am doing
> wrong?
>
>
My immediate reaction is it sounds like the browser is misbehaving, since it
is the piece that drops the ball and does not send the if-none-match
header.  You haven't said anything about the browser -- which browser is it?
Is this behavior consistent across a range of browsers or specific to only
one?

Another thing to check would be how Django's built-in etag handling behaves,
see:

http://docs.djangoproject.com/en/dev/ref/settings/#use-etags

If you see a difference with the built-in etag handling and your code (I am
assuming you are writing your own version to do something a bit more
sophisticated than what the built-in middleware bit can do?) then I'd
suspect there's something missing from what your code is doing, otherwise
again I'd be looking in more detail at the browser specifics.

Karen

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



Re: database lookup in url conf to efine the application url conf to be included

2009-02-15 Thread yuccaplant

Hi,

I figured out that generating the url_patterns wouldn't work, because
the regular expressions are compiled the first time they are accessed.
So I suppose any addition in the Node table would be ignored and the
initial set would be used.

I found another way to accomplish this. I first call the same view for
all urls: core.view.index. In this view I look up the application name
in the database, based on the first part of the url. Then I use
django.core.urlresolvers.resolve to resolve the second part of the
url.

So I have a root url conf that looks like this:

urlpatterns = patterns('',
(r'^(.*?)/-/(.*?)$', views.index),
(r'^(.*)', views.index),
)

So all request get redirected to the index view function of the core
application. That's where the trickery happens:

def index(request, node_url, application_url = ""):
  node = Node.objects.get(url=node_url)
  (view_function, function_args, function_kwargs) = \
resolve( \
  '/%s' % (application_url), \ # the second part of the url, the
actual parameters for the application
   '%s.urls' % (node.application) \ # the url conf of the
application: '.urls'
)
  function_kwargs['node'] = node
  return view_function(request, *function_args, **function_kwargs)

It works, but somehow doesn't feel right: the url resolver gets called
twice and the first time I always call the same view. Maybe there's a
hook I could use so the database lookup happens before the resolver
gets called by django?

kind regards,

Pieter


On Feb 15, 9:54 am, yuccaplant  wrote:
> Hi Malcolm,
>
> Thanks for your reply. I think I wasn't really clear. The problem is
> that the first part of the url is could be really anything, as it's
> user defined throgh the cms. So they are created, changed, ... from
> within the web application. As I don't know beforehand how they will
> look, I can't write url patterns for it.
>
> I have a model that maps the first part of the url to an application.
> Suppose this model is called Node, then I have a table node like this:
>
> *id* — *url* — *application name*
> 12 — /paralla/yadda/booh/ — blog
> 22 — /home/info — page
> 21 — /home/blog — blog
> 11 — /frank/blog — blog
> 33 — /frank/bio — page
> 35 — /timeline — calendar
>
> One possibility I've been thinking of, is generating the url patterns:
>
> nodes = Node.objects.all()
> for node in nodes:
>   urlpatterns += patterns('',
>     (r'^%s$' % node.url, include(node.application), {'id': node.id}),
>   )
>
> However, if I have a big site with a lot of content, there woud be a
> lot of nodes and the urlpatterns list could become rather long. Maybe
> this would be bad for performance?
>
> thanks,
>
> kind regards,
>
> Pieter
>
> On Feb 15, 3:13 am, Malcolm Tredinnick 
> wrote:
>
> > On Sat, 2009-02-14 at 10:39 -0800, yuccaplant wrote:
> > > Hi all,
>
> > > I want to develop a cms and I want my urls partially to be user-
> > > defined, for example:
>
> > > /home/info
> > > /home/blog/-/post/
> > > /frank/blog/-/articles/2003
> > > /frank/bio
>
> > > The first part (the part before '/-/' if any) would map to an
> > > application in the database and is user defined (it could be
> > > anything). That first part could also define additional information to
> > > be passed to the application, in the case of a blog-application this
> > > could be the blog-id. So:
>
> > I think you're designing the implementation a bit in what follows,
> > rather than the functionality. All this talk of database lookups in
> > URLConf isn't appropriate, unless you want to write your own URL
> > resolver.
>
> > > /home/info
> > > A lookup in the database would return the application name: 'Page' and
> > > the page-id: '23'. The url conf of application Page should be included
> > > and the page-id passed to it.
>
> > How do we know what Page and page-id correspond to here? You haven't
> > explained what this is going to do.
>
> > If /home/ is the generic base URL, you could create a pattern that goes
> > before all the user-specific ones (below) that captures it and any
> > following information and passes the processing to a view function which
> > works out that it needs to return Page and 23 and then calls a
> > subsequent function.
>
> > > /home/blog/-/post
> > > A lookup in the database would return the application name: 'Blog' and
> > > the blog-id: '54'. The url conf of application Blog should be included
> > > and the blog-id passed to it. The included url conf takes care to map
> > > the second part of the url (post) to a view.
>
> > > /frank/blog/-/articles/2003
> > > A lookup in the database would return the application name: 'Blog' and
> > > the blog-id: '22'. The url conf of application Blog should be included
> > > and the blog-id passed to it. The included url conf takes care to map
> > > the second part of the url (articles/2003) to the apropriate view.
>
> > > /frank/bio
> > > A lookup in the database would return the application name: 'Page' and

newbie : bring variables from template to view

2009-02-15 Thread arbi

Hi,

In my template I call a javascript function that returns a dictionary.
I would like to bring back the 2 elements of this dictionary in my
view to make some work on it.
How to do it? Use forms? how?

Thx for help on this point :)

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



Trouble adding custom view to admin-site instance

2009-02-15 Thread michael.hess...@googlemail.com

Hi,
I'm trying to add a custom view to a custom admin-site instance, as
documented there: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-views-to-admin-sites

In my rather small example project I've got this custom admin class.
It works just fine, I can register ModelAdmins and so on.

from urls.py
...
(r'^my/(.*)', myad.sites.my_site.root),
...

class CreationAdminSite(sites.AdminSite):
   def get_urls(self):
  urls = super(CreationAdminSite, self).get_urls()
  my_urls = patterns('',
 (r'^myview/$', 'mic.myad.views.show')
  )
  return my_urls + urls
my_site = CreationAdminSite()

Calling my/myview won't work however. (It should, right?)
The pattern shows up when introspecting with python manage.py shell

(InteractiveConsole)
>>> from mic.myad.sites import my_site
>>> my_site.get_urls()
[, ,
, , , , 
\d+)/(?P.+)/$>, \w+)/$>]

The first pattern is right there, and so this should work or did I do
something wrong? I just can't see why this isn't working...



Any help would be greatly appreciated ;)


ps running 9832, "fresh" checkout

pps Same thing when trying to overwrite the get_urls() from a
ModelAdmin, that won't work also.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing the name of a project

2009-02-15 Thread Lee Braiden

Hi Malcom,

2009/2/15 Malcolm Tredinnick :
> Um .. names are how we refer to things in both the real world and code.

OK, this discussion is going nowhere without concrete examples, so
I'll leave it here and just submit patches later.


Regards,

-- 
Lee

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



Re: Different ways of working against a SQLite3 dB

2009-02-15 Thread Daniel Roseman

On Feb 15, 12:53 pm, DaSa  wrote:
> Hi,
>
> Maybe this is a SQLite question, but a guess many Django users uses
> SQLite3.
>
> I have a lot of data that I want to export to my SQLite3 database. My
> problem is that the data contains special signs (swedish åäö) and
> therefore is it not possible to insert the data through "windows
> command prompt" (and SQLite3 shell) because the windows command prompt
> does not support swedish signs.
>
> It works when I,am adding the data through my admin site (Django
> default admin site), but because of the amount of data it is not
> possible to add the item one and one.
>
> My question are if there are any more ways of inserting the data into
> the SQLite3 dB? Is it possible to open the SQLite3 shell without CMD?
>
> Thx!
>
> Best regards
> Daniel Sandberg

I don't know the answer - or anything about sqlite3 on Windows - but
it is possible to change the character encoding on the Windows command
shell. See the 'chcp' command, you should be able to find the correct
one to allow you to use Swedish characters.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Different ways of working against a SQLite3 dB

2009-02-15 Thread DaSa

Hi,

Maybe this is a SQLite question, but a guess many Django users uses
SQLite3.

I have a lot of data that I want to export to my SQLite3 database. My
problem is that the data contains special signs (swedish åäö) and
therefore is it not possible to insert the data through "windows
command prompt" (and SQLite3 shell) because the windows command prompt
does not support swedish signs.

It works when I,am adding the data through my admin site (Django
default admin site), but because of the amount of data it is not
possible to add the item one and one.

My question are if there are any more ways of inserting the data into
the SQLite3 dB? Is it possible to open the SQLite3 shell without CMD?

Thx!


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



Re: Documentation for Download?

2009-02-15 Thread Steve Holden

Tim Johnson wrote:
> I've installed django on my linux computer.
> I find documentation online at http://docs.djangoproject.com/
> I do not find documentation as part of the django install.
> Is documentation available for download?
> Thanks
> Tim
>   
OK, just so the developers can get back to developing you *can* now
download the 1.0 documentation in HTML form for local use from

  http://holdenweb.com/files/djangoDocsHtml.tgz

There are no guarantees that this will be correct, be maintained,
continue to be available, be joined by PDF documentation or updated to
follow the trunk or other versions. I even refuse to guarantee that this
email is not a complete lie. Enjoy.

regards
 Steve

PS: There's always the websucker.py program if you don't want to do a
local build but need something more recent ...



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



Etags

2009-02-15 Thread mermer

I am trying to get Etags working in Django - so that if a page has not
been updated (and the client has already seen the page) it is returned
by the client's browser rather than rendered by django.

The code below is proof of concept.   However, it only partially
works, and that's why I'm asking for help.

When the client first connects the code correctly renders the page and
returns an ETAG header.

On the next request, the browser correctly sends the "If None Mach"
request header with the ETAG details. The code correctly returns the
304 respose and the client displays the page from the browser's
caache.

So far so good.

However, on the third request, it seems that the browser does not send
a "If-None_match" request header, so the etag is not found and the
whole page re-renders from the server.

Is there something else I need to configure?  Or something I am doing
wrong?


Cheers

MerMer


def etag_test(request):

etag = "TestEtag12345"
if etag == request.META.get("HTTP_IF_NONE_MATCH"): # Check to see
if request has matching etag
return http.HttpResponseNotModified() # if etag matches  send
a 304 reponse, so browser uses client cache


html="This is a test of ETAG"

   #Finally, add in the ETag to the new response we're returning.
response = http.HttpResponse(html)
response["Etag"] = etag  # add Etag header to respone

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



Re: Problems with multithreading in fastcgi environment

2009-02-15 Thread Jacob Rigby

The queue solution that Malcolm is talking about requires 3 types of
processes as far as I can tell:
- the fcgi/django processes that will be pushing jobs onto the
queue
- a manager process that is started independently from the fcgi
processes and is responsible for maintaining the shared job queue
- one or more a worker processes that are started by the manager
in response to jobs it pulls off the queue.  The manager could do the
offline processing itself, but if you have a lot of cpus you'd be
missing out on some performance.

A simpler solution is to have a cron job run often and either check a
directory or a database message table for new jobs to run.  I think
using the DB to communicate is actually a pretty nice option as
keeping a long running manager process alive and the queue uncorrupted
sounds trickier than it's worth (just look at some of the caveats to
using queues in the multiprocessing module docs)

I responded to a similar thread the other day, seems to be a popular
problem:
http://groups.google.com/group/django-users/browse_thread/thread/570f146785c4596d/b0e7338230d7b35e?lnk=gst=+Processing+a+file...#b0e7338230d7b35e

I've only used the above in a low volume intranet site, so if someone
else has more experience I'd like to hear from them too.  Especially
if they have experience pushing the mp module around.

-Jacob

On Feb 15, 4:14 pm, Gregor Müllegger  wrote:
> Thank you for your answer Malcolm.
>
> Though what would you suggest as an solution? Shall i use the
> multiprocessing package as a replacement for the threaded module (i've
> already tried that, see below) or is it better to execute a management
> command with Popen('python manage.py process_video_queue') from the
> subprocess module?
>
> I already tried it with multiprocessing, but it hasn't worked - just
> like threading. It doesn't get executed.
>
> Thanks again,
> Gregor
>
> 2009/2/15 Malcolm Tredinnick :
>
>
>
> > On Sat, 2009-02-14 at 11:31 -0800, Gregor Müllegger wrote:
> >> Hi djangonauts,
>
> >> at the moment i try to setup a youtube-like site. Users can upload
> >> videos which will be converted with ffmpeg to the flv format. The
> >> convertion process is fired up in a view. Though i use the "threaded"
> >> module to not interrupt the view for sending back the response.
>
> > This comes up quite often and the standard answer is that this isn't the
> > right approach to solving the problem. You are tying the background
> > processing to the lifecycle of the fastcgi process. Web processes can
> > stop and start for various reasons (including periodically being killed
> > after a number of requests to rest the memory base).
>
> > Better to use a queue-like setup where you make a record of any
> > conversions that need to be done and have another process (or processes)
> > that go through the queue and convert things. The lifecycle of the
> > latter processes aren't then tied to the web-stack lifecycles.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get_absolute_url always returning empty string

2009-02-15 Thread Michael Strickland

Closed. Turns out I hadn't declared all of my context variable - what
slowed me down was trying to use the decorator with the
"get_absolute_urls = " declaration. The documentation mixes the two
without explaining when to use one or the other. Thanks!

On Feb 15, 4:11 am, Michael Strickland  wrote:
> Sorry, that was a mistake I make from mixing pre-2.4 python markup
> with the @permalink decorator... Ignore the "get_absolute_url =
> permalink(get_absolute_url)" - it wasn't affecting the output, in any
> case...
>
> -Michael
>
> On Feb 15, 4:05 am, Alex Koshelev  wrote:
>
> > Why do you wrap two times the same `get_absolute_url` with
> > `models.permalink` decorator?
>
> > On Sun, Feb 15, 2009 at 10:42 AM, Michael Strickland 
> > wrote:
>
> > > Completely lost on this... I'm trying to set up permalinks to my
> > > articles, which are using generic views. I've gotten it to work by
> > > hard coding the url path into the get_absolute_url function, but I'd
> > > like it to be based off the url defined in the view (http://
> > > docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#the-
> > > permalink-decorator
> > > ).
>
> > > [from urls.py]
>
> > > news_dict = {
> > >        'queryset' : Article.objects.all(),
> > >        'date_field' : 'pub_date',
> > > }
>
> > > urlpatterns = patterns('django.views.generic.date_based',
> > >    url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
> > > P.*)/$', 'object_detail', dict(news_dict, slug_field='slug'),
> > > name='article_view'),
> > > )
>
> > > [from models.py]
>
> > >   �...@models.permalink
> > >    def get_absolute_url(self):
> > >        return ('article_view', (), {
> > >            'year': self.pub_date.strftime('%Y'),
> > >            'month': self.pub_date.strftime('%b').lower(),
> > >            'day': self.pub_date.strftime('%d')
> > >            })
> > >        get_absolute_url = permalink(get_absolute_url)
>
> > > Whenever I call get_absolute_url, all it returns is an empty string -
> > > with no indication of what went wrong. Any ideas on this? I don't see
> > > how my code's any different from the docs...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get_absolute_url always returning empty string

2009-02-15 Thread Michael Strickland

Sorry, that was a mistake I make from mixing pre-2.4 python markup
with the @permalink decorator... Ignore the "get_absolute_url =
permalink(get_absolute_url)" - it wasn't affecting the output, in any
case...

-Michael

On Feb 15, 4:05 am, Alex Koshelev  wrote:
> Why do you wrap two times the same `get_absolute_url` with
> `models.permalink` decorator?
>
> On Sun, Feb 15, 2009 at 10:42 AM, Michael Strickland 
> wrote:
>
>
>
> > Completely lost on this... I'm trying to set up permalinks to my
> > articles, which are using generic views. I've gotten it to work by
> > hard coding the url path into the get_absolute_url function, but I'd
> > like it to be based off the url defined in the view (http://
> > docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#the-
> > permalink-decorator
> > ).
>
> > [from urls.py]
>
> > news_dict = {
> >        'queryset' : Article.objects.all(),
> >        'date_field' : 'pub_date',
> > }
>
> > urlpatterns = patterns('django.views.generic.date_based',
> >    url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
> > P.*)/$', 'object_detail', dict(news_dict, slug_field='slug'),
> > name='article_view'),
> > )
>
> > [from models.py]
>
> >   �...@models.permalink
> >    def get_absolute_url(self):
> >        return ('article_view', (), {
> >            'year': self.pub_date.strftime('%Y'),
> >            'month': self.pub_date.strftime('%b').lower(),
> >            'day': self.pub_date.strftime('%d')
> >            })
> >        get_absolute_url = permalink(get_absolute_url)
>
> > Whenever I call get_absolute_url, all it returns is an empty string -
> > with no indication of what went wrong. Any ideas on this? I don't see
> > how my code's any different from the docs...
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: raise ValidationError has no effect

2009-02-15 Thread Alistair Marshall

On Feb 15, 12:06 am, Karen Tracey  wrote:
> The previous paragraph means that if you are overriding Form.clean(), you
> should iterate through self.cleaned_data.items(), possibly considering the
> _errors dictionary attribute on the form as well. In this way, you will
> already know which fields have passed their individual validation
> requirements.
>

You know I would have sworn I had read that page fully several times
now. Clearly not.
You are right, I had expected it to stop after finding the first
error, but this way makes more scene.

I'll just have to make sure my second part of the validation has all
the required information before it starts
to validate it.

Thanks again
Alistair

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



Re: get_absolute_url always returning empty string

2009-02-15 Thread Alex Koshelev
Why do you wrap two times the same `get_absolute_url` with
`models.permalink` decorator?


On Sun, Feb 15, 2009 at 10:42 AM, Michael Strickland wrote:

>
> Completely lost on this... I'm trying to set up permalinks to my
> articles, which are using generic views. I've gotten it to work by
> hard coding the url path into the get_absolute_url function, but I'd
> like it to be based off the url defined in the view (http://
> docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#the-
> permalink-decorator
> ).
>
>
> [from urls.py]
>
> news_dict = {
>'queryset' : Article.objects.all(),
>'date_field' : 'pub_date',
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
> P.*)/$', 'object_detail', dict(news_dict, slug_field='slug'),
> name='article_view'),
> )
>
>
>
> [from models.py]
>
>@models.permalink
>def get_absolute_url(self):
>return ('article_view', (), {
>'year': self.pub_date.strftime('%Y'),
>'month': self.pub_date.strftime('%b').lower(),
>'day': self.pub_date.strftime('%d')
>})
>get_absolute_url = permalink(get_absolute_url)
>
>
> Whenever I call get_absolute_url, all it returns is an empty string -
> with no indication of what went wrong. Any ideas on this? I don't see
> how my code's any different from the docs...
> >
>

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



Re: database lookup in url conf to efine the application url conf to be included

2009-02-15 Thread yuccaplant

Hi Malcolm,

Thanks for your reply. I think I wasn't really clear. The problem is
that the first part of the url is could be really anything, as it's
user defined throgh the cms. So they are created, changed, ... from
within the web application. As I don't know beforehand how they will
look, I can't write url patterns for it.

I have a model that maps the first part of the url to an application.
Suppose this model is called Node, then I have a table node like this:

*id* — *url* — *application name*
12 — /paralla/yadda/booh/ — blog
22 — /home/info — page
21 — /home/blog — blog
11 — /frank/blog — blog
33 — /frank/bio — page
35 — /timeline — calendar

One possibility I've been thinking of, is generating the url patterns:

nodes = Node.objects.all()
for node in nodes:
  urlpatterns += patterns('',
(r'^%s$' % node.url, include(node.application), {'id': node.id}),
  )

However, if I have a big site with a lot of content, there woud be a
lot of nodes and the urlpatterns list could become rather long. Maybe
this would be bad for performance?

thanks,

kind regards,

Pieter

On Feb 15, 3:13 am, Malcolm Tredinnick 
wrote:
> On Sat, 2009-02-14 at 10:39 -0800, yuccaplant wrote:
> > Hi all,
>
> > I want to develop a cms and I want my urls partially to be user-
> > defined, for example:
>
> > /home/info
> > /home/blog/-/post/
> > /frank/blog/-/articles/2003
> > /frank/bio
>
> > The first part (the part before '/-/' if any) would map to an
> > application in the database and is user defined (it could be
> > anything). That first part could also define additional information to
> > be passed to the application, in the case of a blog-application this
> > could be the blog-id. So:
>
> I think you're designing the implementation a bit in what follows,
> rather than the functionality. All this talk of database lookups in
> URLConf isn't appropriate, unless you want to write your own URL
> resolver.
>
> > /home/info
> > A lookup in the database would return the application name: 'Page' and
> > the page-id: '23'. The url conf of application Page should be included
> > and the page-id passed to it.
>
> How do we know what Page and page-id correspond to here? You haven't
> explained what this is going to do.
>
> If /home/ is the generic base URL, you could create a pattern that goes
> before all the user-specific ones (below) that captures it and any
> following information and passes the processing to a view function which
> works out that it needs to return Page and 23 and then calls a
> subsequent function.
>
>
>
>
>
> > /home/blog/-/post
> > A lookup in the database would return the application name: 'Blog' and
> > the blog-id: '54'. The url conf of application Blog should be included
> > and the blog-id passed to it. The included url conf takes care to map
> > the second part of the url (post) to a view.
>
> > /frank/blog/-/articles/2003
> > A lookup in the database would return the application name: 'Blog' and
> > the blog-id: '22'. The url conf of application Blog should be included
> > and the blog-id passed to it. The included url conf takes care to map
> > the second part of the url (articles/2003) to the apropriate view.
>
> > /frank/bio
> > A lookup in the database would return the application name: 'Page' and
> > the page-id: '455'. The url conf of application Page should be
> > included and the page-id passed to it.
>
> Again, using an initial view to further refine things will work here.
> The URL pattern will look like
>
>         url('^(?P.*?)/(?P.*)$', user_app_mapping),
>
> and the user_app_mapping view could do something like this:
>
>         def user_app_mapping(request, user, application):
>             app_name, object_id = get_data_from_inputs(user,
>         application)
>             return real_view(app_name, object_id)
>
> > So I would to have something like:
>
> > urlpatterns = patterns('',
> >     (r'^(.*)$', include(, )),
>
> Except that include() doesn't work like that. You would need to write
> your own function to do that.
>
> > )
> > (where  and  are found by a database
> > lookup of the first part of the url.)
>
> > I can't firgure out how the database lookup would fit in and how I
> > could pass something like a blog-id to the included application url
> > conf.
>
> > Any ideas how I could accomplish this?
>
> Either use intermediate views or look into writing your own URL resolver
> subclass. The former is easier. The latter might allow you to write
> everything in your URL Conf file, although whether that will be clearer
> or not remains to be seen. It will also be a lot more work (and will
> require reading the existing code and working out how to do it).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 

Re: Exceptions and SET client_encoding to 'UNICODE'

2009-02-15 Thread Timothy

On 14 Feb., 20:58, James Bennett  wrote:
> Everything is happening in a Postgres transaction; at the first error
> the transaction aborts and you must issue a ROLLBACK to the DB before
> continuing. Consult Django's transaction dogs for information on how
> to do this.

Great thx Bennet,

that's perfect solution

Now it works perfectly

Great

Timothy

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



Re: Problems with multithreading in fastcgi environment

2009-02-15 Thread Gregor Müllegger

Thank you for your answer Malcolm.

Though what would you suggest as an solution? Shall i use the
multiprocessing package as a replacement for the threaded module (i've
already tried that, see below) or is it better to execute a management
command with Popen('python manage.py process_video_queue') from the
subprocess module?

I already tried it with multiprocessing, but it hasn't worked - just
like threading. It doesn't get executed.

Thanks again,
Gregor

2009/2/15 Malcolm Tredinnick :
>
> On Sat, 2009-02-14 at 11:31 -0800, Gregor Müllegger wrote:
>> Hi djangonauts,
>>
>> at the moment i try to setup a youtube-like site. Users can upload
>> videos which will be converted with ffmpeg to the flv format. The
>> convertion process is fired up in a view. Though i use the "threaded"
>> module to not interrupt the view for sending back the response.
>
> This comes up quite often and the standard answer is that this isn't the
> right approach to solving the problem. You are tying the background
> processing to the lifecycle of the fastcgi process. Web processes can
> stop and start for various reasons (including periodically being killed
> after a number of requests to rest the memory base).
>
> Better to use a queue-like setup where you make a record of any
> conversions that need to be done and have another process (or processes)
> that go through the queue and convert things. The lifecycle of the
> latter processes aren't then tied to the web-stack lifecycles.
>
> Regards,
> Malcolm
>
>
> >
>

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