Re: django multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
First of all the error is not from django but from database.
Secondly I'm not using different databases but different schemas so
relations are possible.
The error has nothing to do with foreign key or any relation.
It just looks like django is ignoring router suggestion and directs
sql query to wrong DB.

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
Unfortunately not exactly.
Schema in Oracle is a synonym of user so you need name and password.
That's why it doesn't fit into tablespaces solution you pointed.
There is open ticket about support for multiple schemas but it's still
unfinished.

This is why I was looking for solution that would work now.
Having said that I really don't understand two things:

- why I was able to create two objects form different db connections
without any error but I can't do the opposite so retrieve related
object from original one?
- what's the purpose of allow_relation method in the router if despite
it suggestions I can bypass this limitation?

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
Anyway, look at the query that needs to be executed. This doesn't
contain any joins. The only problem is that this perfectly correct
query is send to wrong schema although the router suggests a good one.
I don't know why, is there anyone who can explain this to me?

-- 
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 get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Hello,
I have some legacy oracle database against which I run inspectdb command.
One column in the DB has type NUMBER (without precision and scale) and
what I got from django is:

entity_id = models.DecimalField(unique=True, null=True, max_digits=0,
decimal_places=-127, blank=True)

If I now run syndb trying to generate schema from the model I will get
the error:

Error: One or more models did not validate:
DecimalFields require a "decimal_places" attribute that is a
non-negative integer.
DecimalFields require a "max_digits" attribute that is a positive integer.

My question is: how should I modify entity_id type oin the model to
get NUMBER generated in oracle?

BTW. Don't you think this is bug to generate model with inspectdb
which is invalid if you run it using syncdb?

Kind regards,
Michael Nowotka

-- 
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 get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Even if I don't mention inspectdb the problem still persists.
The basic question is how to map oracle NUMBER type from some model type.
If I understand this correctly, currently this is not supported.
In principle models.FloatField should handle it and give and option to
decide if the filed should me mapped into FLOAT or NUMBER.

But maybe (this requires some more oracle knowledge) that FLOAT is
just an alias of NUMBER(38,19).

-- 
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 get oracle NUMBER with syncdb

2012-10-17 Thread Michał Nowotka
Anyway, Jani, thank you for pointing me to the software, I will give it a try.

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



Status of bug #11580 ?

2012-11-06 Thread Michał Nowotka
Hello,
There is a bug submitted 3 years ago:

https://code.djangoproject.com/ticket/11580

I have exact the same problem using django 1.4.

Are there any plans to fix that in near future?

-- 
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: Status of bug #11580 ?

2012-11-07 Thread Michał Nowotka
OK, so first of all I'm new to both lists. I already asked some questions
here and usually I get email with my question 5 minutes after post (I mean
my original question not the answer). I was waiting long and I though my
question didn't pass moderation so maybe it would be better to ask it on
probably less strict django-users group. So my apologies for my impatience.

Now about  the bug itself. Although there is not any patch attached to this
bug report you can find it in the text.  The filed_cast_sql function should
be changed from:

def field_cast_sql(self, db_type):
if db_type and db_type.endswith('LOB'):
return "DBMS_LOB.SUBSTR(%s)"
else:
return "%s"

 to:

def field_cast_sql(self, db_type):
return "%s"

or even completely removed. Since this is trivial it's only a matter of
including this small change in core. I don't have such privileges that's
why I'm asking you to do it.

Kind regards,
Michal Nowotka

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



reading raw binary data from clob columns using oracle backend

2012-11-07 Thread Michał Nowotka
Hello,
I'm working with oracle legacy DB and need to read and write binary data
(png images, and and MDL *Molfiles*).
Django's inspectdb command generated text fields for these columns, saying
that's only a guess.
Now, when I'm trying to retrieve a value from this class fields i get:
DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position
0: invalid start byte.
error.

Is there any way to read and write these columns?
Any help would be appreciated.

Regards,
Michal Nowotka

-- 
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: reading raw binary data from clob columns using oracle backend

2012-11-07 Thread Michał Nowotka
I mean BLOB, sorry.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/nI-3ngGIdA8J.
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.



IntegerField and SmallIntegerFields maps to the same db type on Oracle.

2012-12-13 Thread Michał Nowotka
Does anyone knows the reason why IntegerField and SmallIntegerFields both 
map to NUMBER(11,0) in Orcale?
I would expect SmallIntegerFiled map to something smaller ;)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LjcWQllIYv8J.
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: IntegerField and SmallIntegerFields maps to the same db type on Oracle.

2012-12-13 Thread Michał Nowotka
I agree, but if you map SmallIntegerField to say NUMBER(9) you will save
some space, correct?

-- 
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: IntegerField and SmallIntegerFields maps to the same db type on Oracle.

2012-12-13 Thread Michał Nowotka
OK, then why django makes a difference between BigIntegerField (maps to
NUMBER(19)) and IntegerField (maps to NUMBER (11)).
Thinking this way BigIntegerField, IntegerField and SmallIntegerField
should all map to NUMBER(39).

-- 
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: Kindly help for an interview with Google on python django

2013-01-31 Thread Michał Nowotka
Didn't you know that whole google search thing is actually just django
+ tastyPie + solr?

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




django server ignores POST requests?

2013-02-13 Thread Michał Nowotka
This is really strange behaviour. When I issue POST request to many
times django suddenly starts to ignore them all. I can see then in
firebug but debug server shows nothing. Restarting server doesn't
help. Even more, when I try to restart server when this happens I
always get:

Error: That port is already in use.

Restarting the whole machine helps.

I thought it may be related to

Exception AttributeError: AttributeError("'_DummyThread' object
has no attribute '_Thread__block'",) in  ignored

error I'm having but event after applying workaround:

import threading
threading._DummyThread._Thread__stop = lambda x: 42

described on 
http://stackoverflow.com/questions/13193278/understand-python-threading-bug

I'm still having the same problem.
I don't know ho to diagnose the source of the issue.

Maybe this will be helpful:

OS: ubuntu 12.04 LTS
Processor: Intel® Core™ i7-2720QM CPU @ 2.20GHz × 4
Python 2.7.3
Django 1.4.1

Any help would be appreciated.

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




[no subject]

2013-05-02 Thread Michał Nowotka
According to that webpage:
http://www.techempower.com/benchmarks/#section=data-r4 django performance
is really bad comparing to other popular web frameworks. Are there any
plans to change this situation?

Regards,
Michal Nowotka

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




Django accessing related fields prefetched by prefetch_related

2013-05-07 Thread Michał Nowotka
 

So I have this loop:

for t in ts.prefetch_related('u__v_set'):
bla = t.x
...

Running this code in debugsqlshell I see three (constant amount in general) 
sql statements:

   - one getting all t's
   - second one getting related u's
   - third one getting related v's

Now, in the same loop I would like to refer to some attribute of v (that 
was the reason I used prefetch_related). If I do it like this:

 ble = ','.join([item for item in map(lambda x: x[0], 
t.u.all().values_list('v__some_attribute')) if item])

the cash is invalidated and new sql is produced for each iteration of t.

Another try:

ble = ','.join([v.some_attribute for v in reduce(lambda x, y: x|y, 
[us.v_set.all() for us in t.u.all()]) if v.some_attribute])

this also invalidates cash. So how can I use this prefetched values at all?

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




djnago xml model specification?

2013-05-20 Thread Michał Nowotka
I'm using django with many related projects. All those projects are using 
their own models. But unfortunately this is not DRY, because each model 
differ from each other very slightly, for example some columns or tables 
from one model are missing in other, or some model defines custom save 
method while the other one does not. 

My idea was to define simple core model - the one that has all tables and 
columns and no custom methods.

Then I could dynamically create other models using code like this:



def createModelClass(modelClass):
dict = {}
for field in modelClass._meta.fields:
 if modelClass.__name__ not in EXCLUDED_FIELDS or field.name 
not in EXCLUDED_FIELDS[modelClass.__name__]:
dict[field.name] = field

dict["Meta"] = type('Meta', (ChemblCoreAbstractModel.Meta, object), 
{'unique_together': modelClass._meta.unique_together})
dict["__module__"] = mod.__name__

return type(modelClass.__name__, (CoreAbstractModel, ), dict)

#--

def getCoreModelClasses(module):
return  [x[1] for x in 
inspect.getmembers(sys.modules[module.__name__]) if
 inspect.isclass(x[1]) and issubclass(x[1], 
CoreAbstractModel) and x[1].__name__ not in EXCLUDED_MODELS]

Unfortunately I can't do this because fields remember their models 
(especially related fields). So in principle I would have to change the 
code to create new fields from scratch just reading attributes from the 
original model. 

This makes no sense: inspect model to create another model. In that case 
would be much better to create model from some XML specification that would 
be easier to read and modify and which is not bound to any particular 
django app. 

So my question is - is there any django plugin that allows to express model 
in terms of xml and then create app specific model from this xml?

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