Re: same class name in two applications in different projects

2007-08-23 Thread Michal Jedryszka

Do you also have it. When nothing comes to my mind i ask for help and
after a minute i have what i want without any help :)
djando.db.loaders - get_model

Thank you for cooperation :)


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



same class name in two applications in different projects

2007-08-23 Thread Michal Jedryszka

Hi.
I have some problem i cant figure out.
I have two separate apps in separate projects. I want to write script
that uses both apps. Problem is that in models i have two different
classes with same name (call it C).

So to make it short i have something like this:

from projA.appA.models import C as C1
from projB.abbB.models import C as C2

C2 is equal C1.

So i guess that framework does some magic behind the scenes and does
not import class again.
Seems like it uses only class name not full class path.

Can anyone tell me where should i look for to see why this is
happening?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mysql problems - guess not, but still :)

2007-03-12 Thread Michal Jedryszka

Hi.
We have some intresting situations in one of our environments.

1. When we generate request that causes object not found errors after
5 such requests we get info that we cannot connect DB. Looks like some
connection limitation but we cant reproduce it in other environments.

2. Occures when user has opened browser (opened session i guess)
during apache restart. After restart when user is refreshing page
content receives information that he can't connect to db.

We are using django.contrib.auth and django.contrib.sessions

Does anyone has similar issues, or maybe know origins of such behave.

Kind regards


--~--~-~--~~~---~--~~
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: connecting to multiple databases

2007-03-05 Thread Michal Jedryszka

I had an data import task for django application. Client moved data
from several databses into new one. All legacy databases had same
model, so there was proper django model created for them. And I had
problem with importing data from all those legacy system. I've sniffed
a bit and on the base of django code created something like this:

#Script for switching connections between databases
import django
import types
import MySQLdb as Database
from django.db.backends import util
from MySQLdb.constants import FIELD_TYPE
from MySQLdb.converters import conversions
django_conversions = conversions.copy()
django_conversions.update({
types.BooleanType: util.rev_typecast_boolean,
FIELD_TYPE.DATETIME: util.typecast_timestamp,
FIELD_TYPE.DATE: util.typecast_date,
FIELD_TYPE.TIME: util.typecast_time,
})

def switch(_conf):
instance = django.db.connection
try:
instance.connection.close()
except AttributeError:
pass
instance.connection = None
def cursor():
if not instance._valid_connection():
kwargs = {
'user': _conf['DATABASE_USER'],
'db': _conf['DATABASE_NAME'],
'passwd': _conf['DATABASE_PASSWORD'],
'conv': django_conversions,
}
if _conf['DATABASE_HOST'].startswith('/'):
kwargs['unix_socket'] = _conf['DATABASE_HOST']
else:
kwargs['host'] = _conf['DATABASE_HOST']
if _conf['DATABASE_PORT']:
kwargs['port'] = int(_conf['DATABASE_PORT'])
if hasattr(instance, 'options'):
kwargs.update(instance.options)
instance.connection = Database.connect(**kwargs)
cursor = instance.connection.cursor()
if instance.connection.get_server_info() >= '4.1':
cursor.execute("SET NAMES 'utf8'")
#if settings.DEBUG:
#return util.CursorDebugWrapper(MysqlDebugWrapper(cursor),
instance)
return cursor

instance.cursor = cursor
return

Function takes as argument hash with connection params.
Regards


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