Disabling object persistence ?

2013-10-04 Thread Marc'h
Hello,

I'm battling with Django in order to try avoiding object persistence when 
initialising foreign key model attributes. The app I'm using Django for 
implements a facade for an already existing database. It's main purpose is 
to be used as a (read-only) ReST server returning objects built by 
aggregating attributes from the already existing database. The Django app 
itself has model classes (and associations) like any other Django app. 
Renderers and Serializers based on those supplied by the rest_framework 
modules have been written and tested. We started by configuring the Django 
app to use a SQLite file, as we're don't really care about object 
persistence. However, when building model instances (by 
extracting/aggregating data from the original non-Django managed database), 
we hit a severe perfomance bottleneck. Each time we initialize a model 
attribute which is a collection of related instances, all these are 
apparently persisted to the Django database.

For example, with a classical Order/Items association, we'd have :

01: orderattributes={...extract attributes from external database using 
> SQL...}
> 02: order=Order(**orderattributes)
> 03: orderitems=[]
> 04: for item in ...items belonging to order...
> 05:itemattributes={...extract attributes from external database using 
> SQL...}
> 06:item=Item(**itemattributes)
> 07:orderitems.append(item)
> 08: order.items_set=orderitems


When reaching line 8, it seems that every Item instance of the orderitems 
collection is persisted in the Django database, which considerably slows 
down the application.
I tried to use an in-memory SQLite database, but couldn't make it work, as 
the syntax for declaring a shared in-memory database (file::memory:...) is 
not handled correctly, yielding a file-based database instead.

Thus, I'd like to know if there is any means to by-pass the automatic 
persistence mechanism when using collection attributes which are 
foreign-key based.

Thanks for any pointers !


Marc'h







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ba9a4637-26ac-4f59-923c-ff43d24be02a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Missing trailing slash on static files

2013-05-14 Thread Marc'h
My mistake, the slash is missing between the static and images path 
components and not, as I erroneously wrote, between the app and static ones. 
Sorry for that.

Le mardi 14 mai 2013 15:52:39 UTC+2, Marc'h a écrit :
>
> Hi all,
>
> I'm having trouble configuring Django to serve static files for deployed 
> apps (using Apache + WSGI).
>
> Briefly put :
>
> - the root URL of the Django application is http://www.example.com/app
>
> - the root directory (SITE_ROOT) of the Django project is 
> /var/www/html/django/app/app (yes indeed, two final app directories)
>
> - inside the Django templates, references to static content is made 
> through the static tag as in {% static 'images/logo.png' %}
>
> - the actual file is thus located in : 
> /var/www/html/django/app/app/static/images/logo.png
>
> - the settings configuring the static directories are : 
>
> STATIC_ROOT=os.path.join(SITE_ROOT,'static')
>> STATIC_URL='/app/static'
>> STATICFILES_DIRS=(
>>   STATIC_ROOT,
>> )
>
>
>
> When a static resource is addressed from within a template, the generated 
> URL is correct, as in http://www.example.com/app/static/images/logo.png
> However, the mapping of this URL to a filename, as logged by the Apache 
> error_log, yields : /var/www/html/django/app/app/staticimages/logo.png. There 
> definitely is a slash missing between the app and static path components,
> and the file is thus not found.
>
> I've been reading through the various docs relative to static file 
> serving, but haven't found anything related to this issue. If anyone out 
> there has a clue as why the slash is stripped of, I'd be grateful to read a 
> solution to this problem.
>
> Many thanks in advance,
>
> Marc'h
>
>
>
>

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




Missing trailing slash on static files

2013-05-14 Thread Marc'h
Hi all,

I'm having trouble configuring Django to serve static files for deployed 
apps (using Apache + WSGI).

Briefly put :

- the root URL of the Django application is http://www.example.com/app

- the root directory (SITE_ROOT) of the Django project is 
/var/www/html/django/app/app (yes indeed, two final app directories)

- inside the Django templates, references to static content is made through 
the static tag as in {% static 'images/logo.png' %}

- the actual file is thus located in : 
/var/www/html/django/app/app/static/images/logo.png

- the settings configuring the static directories are : 

STATIC_ROOT=os.path.join(SITE_ROOT,'static')
> STATIC_URL='/app/static'
> STATICFILES_DIRS=(
>   STATIC_ROOT,
> )



When a static resource is addressed from within a template, the generated 
URL is correct, as in http://www.example.com/app/static/images/logo.png
However, the mapping of this URL to a filename, as logged by the Apache 
error_log, yields : /var/www/html/django/app/app/staticimages/logo.png. There 
definitely is a slash missing between the app and static path components,
and the file is thus not found.

I've been reading through the various docs relative to static file serving, 
but haven't found anything related to this issue. If anyone out there has a 
clue as why the slash is stripped of, I'd be grateful to read a solution to 
this problem.

Many thanks in advance,

Marc'h



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