Re: Obscure error installing Django
I've tracked it down to something similar to this: http://code.djangoproject.com/ticket/5530#comment:1 The ImportError that is been raised on http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/base.py#L20 is causing the session error. It probably should be changed also to a raise ImproperlyConfigured so the error is reported correctly: For some reason the FastCGI process was using the outdated version the server has instead of 1.2.2 that I had installed (even though it is on sys.path). Thanks for your help. On Nov 1, 1:40 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-01 at 04:50 +0000, Julio César Carrascal Urquijo wrote: > > > > > I'm installing Django on a shared hosting account but I've been > > fighting the las two hours with this error: > > > /home//django_src/django/contrib/sessions/middleware.py in > > process_request(self= > object>, request=, > > POST:<QueryDic...gi.url_scheme': 'http', 'wsgi.version': (1, 0)}>) > >13 engine = __import__(settings.SESSION_ENGINE, {}, {}, > > ['']) > >14 session_key = > > request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) > >15 request.session = engine.SessionStore(session_key) > >16 > >17 def process_response(self, request, response): > > request = , > > POST:<QueryDic...gi.url_scheme': 'http', 'wsgi.version': (1, 0)}>, > > request.session undefined, engine = > 'django.contrib.sessions.backends.db' fr...ngo_src/django/contrib/ > > sessions/backends/db.pyc'>, engine.SessionStore undefined, session_key > > = None > > > AttributeError: 'module' object has no attribute 'SessionStore' > > args = ("'module' object has no attribute 'SessionStore'",) > > > It's probably something I missed because It goes away if I disable the > > session middleware (that means I can't use auth or admin apps) so at > > least the core of Django is working. > > > I took a look at the values of settings.SESSION_ENGINE and engine: > > > * settings.SESSION_ENGINE was 'django.contrib.sessions.backends.db' > > * engine.__file__ was '/home//django_src/django/contrib/sessions/ > > backends/db.pyc' > > > which seems correct, but... > > > * dir(engine) was ['__builtins__', '__doc__', '__file__', '__name__', > > 'settings'] > > > ... an empty module. Anyone knows why this might be happening? > > I have no suggestions to offer here. I can't repeat this using Python > 2.3 and latest subversion trunk (as you're using). I don't have > mod_fastcgi set up for testing, though, so it might be something special > going on there, but I can't imagine what it would be. > > If you run the same commands from the "manage.py shell" prompt, does it > work? That is, do something like > > >>> from django.conf import settings > >>> engine = __import__(settings.SESSION_ENGINE, {}, {},['']) > >>> dir(engine) > > That should show more than you saw above. If it doesn't, I'm back to > being stuff, because I don't know what's going on. If there are > differences, your checkout is incomplete somehow. > > Regards, > Malcolm > > -- > I don't have a solution, but I admire your > problem.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Obscure error installing Django
I'm sorry. I'm using: 1) Python 2.3, Django from SVN and django-admin.py reports 0.97-pre- SVN-6635. 2) Subversion checkout on an empty folder. 3) It's running through FCGI (mod_fcgi) and a new user just for Django so I don't think it is another installation. Thanks On Oct 31, 11:57 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-01 at 04:50 +0000, Julio César Carrascal Urquijo wrote: > > > I'm installing Django on a shared hosting account but I've been > > fighting the las two hours with this error: > > Before going any further, you're going to have to say: > > (1) Which version of Django? In particular, what does "django-admin.py > --version"report? > > (2) How did you install it? Over the top of an older installation (if > so, remove all *.pyc files)? > > (3) Are there any other installations of Django on the machine? If so, > have you confirmed that you're running against the correct installation? > > Regards, > Malcolm > > -- > Plan to be spontaneous - tomorrow.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Obscure error installing Django
I'm installing Django on a shared hosting account but I've been fighting the las two hours with this error: /home//django_src/django/contrib/sessions/middleware.py in process_request(self=, request=, POST:) 13 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 14 session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) 15 request.session = engine.SessionStore(session_key) 16 17 def process_response(self, request, response): request = , POST: , request.session undefined, engine = , engine.SessionStore undefined, session_key = None AttributeError: 'module' object has no attribute 'SessionStore' args = ("'module' object has no attribute 'SessionStore'",) It's probably something I missed because It goes away if I disable the session middleware (that means I can't use auth or admin apps) so at least the core of Django is working. I took a look at the values of settings.SESSION_ENGINE and engine: * settings.SESSION_ENGINE was 'django.contrib.sessions.backends.db' * engine.__file__ was '/home//django_src/django/contrib/sessions/ backends/db.pyc' which seems correct, but... * dir(engine) was ['__builtins__', '__doc__', '__file__', '__name__', 'settings'] ... an empty module. Anyone knows why this might be happening? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Directed graph implementations for Django
I'm a newbie on Django my self but maybe this is what you are looking for: class Category(models.Model): code = models.CharField(maxlength=200, unique=True) products = models.ManyToManyField('Product') class Product(models.Model): parent = models.ForeignKey('Post') code = models.CharField(maxlength=200, unique=True) I've also read that you can specify signals for most operations on a model (Like when a model is inserted, updated or deleted from the database) though I can't find the URL right now. There's some mention of it here: http://www.djangoproject.com/documentation/db-api/ On Sep 16, 9:54 pm, "Paul Dorman" <[EMAIL PROTECTED]> wrote: > Hi all, > > definite newbie here. I'd like to implement a category type system in > Django. I've looked in the cookbook and Googled a bit, but to no avail. What > I'm after should be pretty simple: a directed graph for categories, where > objects and perhaps categories can be a member of one or more categories. > For example, a 'server' is an 'infrastructure component' (for the techies), > as well as an 'asset' (for the financial types). In my grand scheme when an > object is associated with one or more categories (one is the minimum), the > application will execute method calls stored (with optional parameters) in > the database (serialized as JSON or XML). With the 'server' example, it > might be that being in the 'infrastructure component' category triggers an > email to be sent to the system administrator, and the existence in the > 'asset' category would trigger an automated update to the asset register. > The methods are stored according to the standard CRUD set of operations, so > that a user can create a new category in the view, and then specify actions > which occur when an object is created, read, updated, or deleted (provided > by the application itself). Actions are triggered for both objects (the > things that are categorized) and for child categories (so for example it may > be that a parent category can be locked in such a way as to prevent any more > child categories from being added). > > Note that categories are purely containers with generic actions (for crud > operations on objects in the category) and distinct from objects, which I > imagine would have a category_id FK. And note also that my objects are all > using the same model, with the bulk of data serialized as XML. > > Has anyone out there in Djangoland done something like this? The graph's the > thing - I'm happy to deal with the CRUD triggers myself. If there's a model > out there that would be a good starting point that would be great. > > One additional thing I'm wondering about is how Django can work with stored > procedures. For example, it might be more efficient if the application can > ask the database for the methods to run when an object is created, and > have the database return the methods for not only the object's bottom-level > category, but for all parent categories as well. > > P.S. > > Congratulations on the great sprint! > > P.P.S. I hope I haven't just embarrassed myself with my naïveté. > > -- > "Science fiction writers are the only ones who care about the future" > -- Kurt Vonnegut --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Efficient way to import many-to-many relations
I have the following models (Well, very simplified): class Category(models.Model): code = models.CharField(maxlength=200, unique=True) posts = models.ManyToManyField('Post') class Product(models.Model): parent = models.ForeignKey('Post') code = models.CharField(maxlength=200, unique=True) Now, I have a large file with products that I need to import and each record has a list of categories that need to be associated with the product: def import_from_file(filename): ... for r in product_records(file): p = Product() p.code = r['code'] p.parent = Product.get(code = r['parent_code']) ... p.save() for category in r['category_codes']: c = Category.get(code = category) c.posts.add(p) This sort of works but it is too inefficient to import all products. What I really like to do is something along the lines of: cursor.execute("""insert into store_product (code, parent_id, ...) select %s, id as parent_id, ... from store_product where code = %s""", r['code'] r['parent_code']) and cursor.execute("""insert into store_category_products (product_id, category_id) select %s, id as category_id, ... from store_category where code in (%s)""", p.id, r['category_codes']) Is possible to express this within the django db-api or should I just give up and use raw cursors? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing db_table in _pre_save()
That's it. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Accessing db_table in _pre_save()
I'm using a cursor inside the _pre_save() method for one of my models and figured it would be wise to use the table name gerated by Django instead of just hard-coding the name. Is it possible to access the table name of a model from one of it's methods? Thanks. (I'm using Django 0.95, btw) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Using django models on external scripts.
Hi. I would like to use django models on external scripts to initialize/modify the database. Is it possible? I've followed the instructions of the tutorial (set DJANGO_SETTINGS_MODULE='website.settings' and importing website.settings works on python shell) but haven't been able to get it to work with this simple script: from models import Format [f.save() for f in ( Format(order= 1, name='One'), Format(order= 2, name='Two'), )] Executing "initialize.py" on the command line always shows the error: EnvironmentError: Could not import settings ''website.settings'' (is it on sys.path?): No module named 'website.settings'. (Yes, it is on sys.path). and if I try to import the script under manage.py shell it shows: AttributeError: 'Format' object has no attribute 'id'. I'm using the latest Magic Removal Branch on Windows XP and Python 2.4.3. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---