DEFAULT_FILE_STORAGE and tests

2018-09-20 Thread sandro dentella
Hi, I have a storage that create some thumbnail and is declared in some models' fields. It's created inheriting from DEFAULT_FILE_STORAGE and it just works fine both in FileSystemStorage and in Aws. For this project need the aws Storage (from Django_storages) but when testing I prefer the lo

Re: translations: how give precedence to project over apps

2008-05-14 Thread sandro dentella
> > I have a project that assembles applications that I have prepared for > general pourpose. One of them is a ticket application developed with > software ticket in mind. Now I want to make it work for a complete > different company. It turns out I just need to rename fields, not the >

sql & cache problem? Am I crazy?

2008-04-03 Thread sandro dentella
Hi all, I've being using django for a while now with great satisfaction, but I've never needed to cope with cache system. Now I'm hit by a problem that I believe is dependant on cache. I have a form (newform), that in the .save() method updates an object (it works!). Then reloading the page

sudo under django or better solutions?

2008-01-31 Thread sandro dentella
Hi, i'd like to make an application that should execute commands with permission that are not normally for www-data (eg: create user). Of course I know I could use sudo and execute the command via subprocess or similar. But it happens that the command is a python script so i'd prefer to

Re: weird "can't adapt" error

2007-11-22 Thread Sandro Dentella
On Tue, Nov 20, 2007 at 03:04:09PM -0600, Jeremy Dunck wrote: > > On Oct 26, 2007 2:47 AM, sandro dentella <[EMAIL PROTECTED]> wrote: > ... > > > > once again I stumble into this problem. This time I gathered some > > more > > info so I describe th

Re: weird "can't adapt" error

2007-11-20 Thread Sandro Dentella
On Tue, Nov 20, 2007 at 01:17:50AM -0800, Jarek Zgoda wrote: > > I just started receiving the same problem when I try to save an object > that has non-ASCII values in char field (the values are all properly > decoded to unicode)> This seems related to psycopg2 backend, as I do > not observe such

Re: weird "can't adapt" error

2007-10-26 Thread sandro dentella
On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote: > Hi, > > I'm meeting a weird problem in a django application. > It works w/o any problem from my pc connecting remotely to my customer's > apache but is not working inside the lan. > > I

weird "can't adapt" error

2007-09-26 Thread Sandro Dentella
Hi, I'm meeting a weird problem in a django application. It works w/o any problem from my pc connecting remotely to my customer's apache but is not working inside the lan. I'm connecting from firefox/ubuntu they're connecting from firefox/XP. the weird part is that: 1. they h

Re: inteactive shell, threads & debug

2007-08-26 Thread sandro dentella
As often happens, writing the questions gave me the answer at least to the main problem if not to the single questions on threading. I ended up writing (interactively) a variable in django.conf.settings and modified get user to test for INTERACTIVE_USER if it does not find any user defined in the

inteactive shell, threads & debug

2007-08-26 Thread sandro dentella
Hi, First the question, then the explanation why a ask this... 1. Are all the commands issued in an interactive shell run in the same thread? 2. Is it possible to make functions (eg: Model.objects.all()) called within the interactive shell read variables in the interactive

error: (32, 'Broken pipe'), ThreadLocals & ticket #4444

2007-06-27 Thread sandro dentella
I'm trying to debug a problem for which vanderkerkoff opened ticket http://code.djangoproject.com/ticket/, the fact that under some circumstances the development server prints a tracebak terminating with: error: (32, 'Broken pipe') I noticed that if I add middleware ThreadLocals as per:

Re: project directory - simple question

2007-06-22 Thread Sandro Dentella
On Fri, Jun 22, 2007 at 06:32:51PM +0300, KpoH wrote: > > put in your "mysite_classes" directory empty file named __init__.py > it will indicate that this is python module, and from now you can import > it, or it's contents. Thanks ut this is not what I was looking for. I know how to import a mo

project directory - simple question

2007-06-22 Thread sandro dentella
hi, while writing application that are meant to be used in many different projects *and* that allow projects to overwrite single methods/ classes I need to have a way to refer to the application project in a general way (not by name, since I don't know in the application which will be the

Re: tests, localization & settings

2007-06-11 Thread Sandro Dentella
> Okay, if you're calling functions directly, you can probably use > activate() and deactivate(). Something like > > >>> from django.utils.translation import activate, deactivate > >>> activate('en') > >>> # Do tests here > >>> deactivate() > > Or am I mis

Re: tests, localization & settings

2007-06-11 Thread sandro dentella
> Firstly, trying to do that works for me. So there's something else > going wrong. Are you running under psyco or something? no. Simple python2.4. I'll investigate that further. > not something Django supports in general. So one solution is to use > two different settings files if you want to t

tests, localization & settings

2007-06-11 Thread sandro dentella
I'm writing some tests for a project. I'd like to be able to decide if/ when localization should take place from within the test, but it seems I cannot overwrite settings values (below is the traceback). I see that in tests/runtest.py it changes that value so I'm a little puzzzled... Should I be

integrity error silently failing

2007-06-05 Thread Sandro Dentella
hat's ok, but too late... It seems to me too big a mistake so I hope I'm just missing something, if not I'll file a new ticket for this. I think in no way a db error should be ignored... I tried with a fresh svn co of rel 5427. Any comments? sandro *:-) -- Sandro Dentella *:-

Re: Unicode-branch: testers wanted

2007-05-29 Thread Sandro Dentella
o I'm -1 on > trying to do anything like this. I consider this a slippery situation. I forsee many cases in which application db and test db will be different and a simple check in run_test/create_test_db could prevent people from scratchind their head to understand why tests pass and applic

Re: Unicode-branch: testers wanted

2007-05-28 Thread Sandro Dentella
On Mon, May 28, 2007 at 04:26:17PM -0500, Jeremy Dunck wrote: > > On 5/28/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > Okay... time to fix that problem then. Probably need to introduce a > > settings for tests only for database encoding. I should have done that > > when I first saw the p

Re: Unicode-branch: testers wanted

2007-05-25 Thread Sandro Dentella
> > File "/usr/lib/python2.4/urllib.py", line 1162, in urlencode > > v = quote_plus(str(v)) > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf2' in > > position 1: ordinal not in range(128) > > This should be fixed in [5338]. well... you already know it works like a charm!

Re: Unicode-branch: testers wanted

2007-05-24 Thread sandro dentella
Hi Malcom, I really welcome this branch and thank you all for the effort. Before I consider a bug what follows I'd ask if this should entitle me to use non ASCII letters in tests with test.client. I tried something like self.client.get(url, dict(name=u'F\xf2')) to get back an error f

Re: Encoding trouble: db interaction

2007-05-21 Thread sandro dentella
well, ok. It's the utf-8 encoded version of u'F\xf2' I imagine. But why if I change DEFAULT_CHARSET to ' latin-1' it does not get encoded in 'latin-1'? is the db encoding winning over DEFAUL_ENCODING? sandro *:-) oh, i'd like to be an ascii speaking... ;-) --~--~-~--~~---

Encoding trouble: db interaction

2007-05-21 Thread Sandro Dentella
After some weeks of relative good relationship with unicode I met a new problem. Digging into it I see things I cannot understand and I'm not sure how these are related to my problem. I'm using postgresql, psycopg2, DEFAULT_CHARSET='utf-8', db encoding unicode. In [1]: from django.contrib.auth

tests: best pactices help

2007-05-20 Thread Sandro Dentella
Hi again!, some "easy" questions to use tests in the best way. 1. 'manage.py test' finds unittest in tests.py *and* models.py. It doesn't seem to find docstring other that in tests.py. I pasted the Animal example in a model but no test was run till I put it into tests.py. Am

Re: tests: one failure --> all test declared failed

2007-05-20 Thread Sandro Dentella
Solved, I apologize, url.py is correct, and the way to make a bad url was by introducing a 'raise TypeError' in the view, but I used -w/o realizing- that same view for login: stupid me! This is another good point to move to the new syntax for client.login()... but I didn't want to before I had

tests: one failure --> all test declared failed

2007-05-19 Thread Sandro Dentella
ws/defaults.py", line 88, in server_error t = loader.get_template(template_name) # You need to create a 500.html template. File "/misc/src/django/trunk/django/template/loader.py", line 79, in get_template source, origin = find_template_source(template_name) File "/misc/src/d

Re: loaddata and foreignKey: manage.py silently failing

2007-05-14 Thread Sandro Dentella
> Yes, this seems to be the problem. The serializer doesn't currently > handle to_field as a special case. I'll work on a fix. > > However, there is another way to solve you problem. Are you sure that > you want Nation.code to be unique=True, and not primary_key=True? If > you set primary_key=Tru

Re: loaddata and foreignKey: manage.py silently failing

2007-05-13 Thread sandro dentella
I produced the example (2 field, 2 models, 2 records!) I opened ticket http://code.djangoproject.com/ticket/4288 but now I cannot add files due to InternalError of the trac system! So I put it here: http://www.e-den.it/misc/fixture_failing.tgz Anyhow my understanding is that is all due to the Fo

Re: loaddata and foreignKey: manage.py silently failing

2007-05-12 Thread Sandro Dentella
> Interesting. The "installed n fixtures" message is printed before the > transaction is commited, which might be causing the confusion, but if > the commit isn't succeeding, you should be seeing other errors (i.e., > db failures). Is it possible that stderr is getting redirected > somewhere other

Re: gettext and _: what changed?

2007-05-11 Thread Sandro Dentella
> No. Prior to 1.0 we are going to remove the implicit and automatic > aliasing of gettext() to _() throughout the code anyway. It's a bit of a > Python design wart -- i.e. they *really* didn't think it through. The > problem is that if you rely on the it always being in builtins, doctests > (and

gettext and _: what changed?

2007-05-11 Thread sandro dentella
Hi, here again... I think that this is an error, at least again a different behaviour compared to version of some weeks ago (r4871) ## english version gives no problem (Pdb) print "New Ticket #%(id)s '%(title)s' for project %(project)s" % (Item(instance)) New Ticket #3 'test 3' for proje

test.client: where are context & template?

2007-05-10 Thread sandro dentella
I'm trying to use test.client to test some pages that are login protected. 1. the docs say that syntax is: """ c = Client() c.login(username='fred', password='secret') # Now you can access a login protected view """ while the signature is: def login(self, path, username,

loaddata and foreignKey: manage.py silently failing

2007-05-10 Thread sandro dentella
hi, I'm trying to play with initial_data fixture. I dumpdata (json format) and reload it cleanly if there are no foreign key contraints on the table. If the tables i'm dumping have foreign keys (in my case holydays/ nation bith in the same fixture), I get an error from the db that abort

Re: TypeError: expected string or buffer on django.utils.functional.__proxy__

2007-05-10 Thread Sandro Dentella
Thanks a lot for your answer that explained what I was underevaluating. My example was not the real one and while trying to strip it as simple as possible I missed to say that I used 'smart_unicode' to get unicode object... and smart_unicode changed in r4904 to "respect deferred evaluation". I

TypeError: expected string or buffer on django.utils.functional.__proxy__

2007-05-09 Thread sandro dentella
Hi, the following code raises error as per subject: import re from django.db import models from django.newforms.models import form_for_model from django.utils.translation import gettext_lazy as _ class Abc(models.Model): choice = models.CharField(maxlength=10, help_text

Re: Adding fields dinamically to a model

2007-05-03 Thread sandro dentella
hi, i'd like to dinamycally add fields to a model (UserProfile) so that it gets populated wit all the field needed by each application. Any idea of how to accomplish this? A first try that cannot work would have been: class UserProfile(models.Model): user = models.OneToOne

Adding fields dinamically to a model

2007-05-03 Thread sandro dentella
hi, i'd like to dinamycally add fields to a model (UserProfile) so that it gets populated of all the field needed by each application. Any idea of how to accomplish this? I first try that cannot work would have been: --~--~-~--~~~---~--~~ You receive

Re: gettext & UnicodeDecodeError

2007-04-16 Thread Sandro Dentella
Thanks Malcom for the explanation, I can wait the refactoring that in fact is necessary. I'm sorry I cannot help on this both for lack of time right now and becouse the matter is just becoming a little more familiar only in these days... sandro *:-) --~--~-~--~~~-

Re: gettext & UnicodeDecodeError

2007-04-13 Thread Sandro Dentella
ented in gettext module, but I can't find it nor in django.util.translation nor in python gettext module... ('module' object has no attribute 'ugettext') any further hint? TIA sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page -

gettext & UnicodeDecodeError

2007-04-11 Thread Sandro Dentella
Hi all, I'm having problems understanding an error that raises with gettext and an accented letter. Italian translation of 'priority' is 'priorità', the text to be translated is: subject = _("Priority changed in ticket #%(id)s %(title)s") % ( {'id':instance.id, 'titl

user, signal & _thread_locals

2007-03-15 Thread Sandro Dentella
Hi all, I'm using _thread_locals as in: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser to keep track of the user that triggered operation in contexts where request.user is not available (eg: managers). I realize now that signal do not preserve it (I guess that are run i

Re: can I mimic authenticated user from shell?

2007-03-06 Thread Sandro Dentella
ode.djangoproject.com/wiki/CookBookThreadlocalsAndUserto get > > > the user: it works perfectly from the browser but fails to get the > > > user from the shell even if I write: > > > > > _thread_locals = local() > > > _thread_locals.user = u -- Sandro Dentel

Re: newforms, foreignKeys & constraints

2007-01-30 Thread Sandro Dentella
Hi all, I'm trying to learn newforms. I create a form with form_for_model and now present it in the template. A foreign key renders as a select widget, that is ok, but how can I limit the values filtering them out? Should I pass the widget when creating the Form using formfield_callback? Ca

Re: Debugging Django: print statements?

2007-01-23 Thread sandro dentella
I'd like to stress the first answer was much simpler: pdb module. You just need to 'import pdb' in you code (dev environment) and place a 'pdb.set_trace()'. When the view arrives there you get an interactive pdb shell in the console, you can view variables, step throught the code and so on. What e

ManyToMany and form

2007-01-19 Thread Sandro Dentella
s is the fact that I must write by hand the widget?) Is there a working example? thanks sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL work --~--~-~--~~~---~--~~ You received this message because you a

security and connection to db

2006-12-13 Thread Sandro Dentella
connect as a different user? TIA sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL work --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users&quo

Re: moving django applications

2006-11-13 Thread Sandro Dentella
e would end up in one single configuration, the main one... I was rather thinking at adding a variable in the context using something in the middleware (I this I saw the way to add to context), that would allow me to use a "PREFIX" variable to all URL

Re: moving django applications

2006-11-10 Thread Sandro Dentella
assed the full URL." so that ursl.py must be aware of the location, it'd e nice to be able to say "trim off /mysite/" when doing the regex for the urlpattern. How does normally people build URLS within templates, isn't there a way to be able to reuse them easily i