Re: Trouble installing PIL

2008-05-23 Thread Ivan Illarionov
There is one common problem with PIL: if you tried to install it *before* you install JPEG and other libraries, it won't recompile C extensions with newer headers and libraries. The solution is to rebuild PIL with -f switch: python setup.py build_ext -f (sudo) python setup.py install Hope this h

Re: Feel free to test queryset-refactor branch

2008-04-13 Thread Ivan Illarionov
Glad to hear that queryset-refactor is almost ready. Currently, I noticed that there are few SQL portability issues and few old queryset API issues (eg in admin). I already filed #6956 and #6957. I do some heavy testing of this branch and I will report anything that goes wrong. Regards, -- Ivan

Re: Best practices for creating Manager methods?

2008-02-24 Thread Ivan Illarionov
> def create_user(self, username, email, password=None): > def make_random_password(self, length=10, > allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'): > > These two methods seem to involve situations where they need to act on > a model, but the object instance hasn't been

Re: Flash and Django

2008-02-01 Thread Ivan Illarionov
http://djangoamf.sourceforge.jp/index.php?DjangoAMF_en On 1 фев, 18:33, "Ronaldo Z. Afonso" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new in Django and Web development and I just want to know if it's > possible to have a flash script showing elements that was retrieve from > a data base by django?

Re: how to speed up objects saving

2008-02-01 Thread Ivan Illarionov
> I'll try to redefine save methods in all the objects to see how much time it > saves You may want to redefine the __init__ methods as well (it's called when you create your objects before save), it adds overhead of two more signals that are probably unused and can be removed for speed. You ca

Re: how to speed up objects saving

2008-02-01 Thread Ivan Illarionov
You have two options: 1. Execute raw SQL 'INSERT' queries 2. Override the Model.save() or create new save_fast() method in your Model class. The main speed eaters in Model.save() are dispatcher.send() calls - so if you copy/paste the content of save method from Django code without dispatcher.send

Re: Any way to know if a value has changed before saving?

2008-01-31 Thread Ivan Illarionov
> def save(self): > if self.stuff != > magic_function_that_tells_what_is_in_database_for('stuff') > do_this() > super(A, self).save() This 'magic function' is self.__class__.objects.get(id=self.id).stuff if self.stuff != self.__class__.objects.get(id=self.id).stuff: do_this()

Re: How to know if an object is being created in the save() method?

2008-01-30 Thread Ivan Illarionov
Example of post_save with 'created' flag is in Django tests: http://code.djangoproject.com/browser/django/trunk/tests/modeltests/signals/models.py --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: How to know if an object is being created in the save() method?

2008-01-30 Thread Ivan Illarionov
There is 'post_save' signal with 'created' parameter. But, unfortunately, this feature is undocumented... On Jan 31, 6:44 am, Julien <[EMAIL PROTECTED]> wrote: > Hello there, > > Does the title says it all? When overriding the save method of an > object, I'd like to know if that object is being

Re: We're having an extremely difficult to diagnose problem:

2008-01-30 Thread Ivan Illarionov
If you don't want to rely on Django's smart_str, you can do following: if isinstance(value, unicode): value = value.encode('utf-8', 'ignore') return textile.textile(value, encoding=settings.DEFAULT_CHARSET, output=settings.DEFAULT_CHARSET) textile.textile() certainly breaks with your error if

Re: We're having an extremely difficult to diagnose problem:

2008-01-30 Thread Ivan Illarionov
The problem here is not about wrong encoding of strings - it's all about unicode/string relationship and from-unicode-to-string/from- string-to-unicode problem. I really think that it will be fixed if you replace return textile.textile(value, encoding=settings.DEFAULT_CHARSET, output=settings.DEF

Re: 1.3x-3x Model Instantiation Optimization

2008-01-30 Thread Ivan Illarionov
> Hm, a code running fast is really good but this solution seems to be really > experimental and hard-to-use, as well as making code kinda unreadable. It > would be great if it's implemented in next django releases to make django > fast :). Is it possible to do it? It depends on Django developers

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
Jan 30, 8:25 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > You pass unicode value to textile.textile. I was able to repeat your > error by doing the same: textile.textile breaks with similar error > when it recieves a unicode string. It can be fixed by encoding your > value as ut

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
You pass unicode value to textile.textile. I was able to repeat your error by doing the same: textile.textile breaks with similar error when it recieves a unicode string. It can be fixed by encoding your value as utf-8 before passing to textile.textile. Your error log has: return textile.textile(

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
You have this in your log: func ignore_failures False Maybe try to change this to True. And double check that everything is converted with 'ignore'. Another option: store the textiled xhtml in database. --~--~-~--~~~---~--~~ You received thi

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
> Our database is utf8 we explicitly convert ignoring errors to utf8 > before passing to textile. Also it's not 1 page that poops it's every > site pooping at once. That means that the problem is inside something that shows on every page. --~--~-~--~~~---~--~~ You r

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
I had A LOT of similar problems when I need to work with cyrillic. I can easily replay your problem. Fortunately I'm on localized Windows machine. So: >>> path = r'C:\Documents and Settings\vanilla' >>> os.path.isdir(path) True >>> os.listdir(path)[-1] '\xd8\xe0\xe1\xeb\xee\xed\xfb' >>> a = os.lis

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov
It looks that you have encoding problem. You have wrong characters somewhere. The solution is to find the text that causes problems and create custom encode and/or decode function that fixes this. --~--~-~--~~~---~--~~ You received this message because you are subsc

1.3x-3x Model Instantiation Optimization

2008-01-29 Thread Ivan Illarionov
After discussion on Django developers group about Model.__init__(*args) deprecation I found the way to dramatically optimize instantiation of Django models. Here is a code: http://pastebin.com/m8e7e365 You may add this code to your Django model class and then instead of obj = YourModelClass(titl

Re: Newbie Question

2008-01-29 Thread Ivan Illarionov
> Fortnately, Python makes this very easy with the built-in > property() call: > > class MyModel(Model): > surname = CharField(...) > forenames = CharField(...) > def _get_name(self): > return self.forenames + ' ' + self.surname > name = property(fget=_get_name) Python (2.

Re: Best practice for implementing multilingual content in template

2008-01-28 Thread Ivan Illarionov
Made some corrections: http://pastebin.com/d6337d211 On Jan 28, 10:45 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > IMO code_berzerker's approach is the best for complex models. But in > many cases that don't require a lot of flexibility it can be better to > use s

Re: Best practice for implementing multilingual content in template

2008-01-28 Thread Ivan Illarionov
IMO code_berzerker's approach is the best for complex models. But in many cases that don't require a lot of flexibility it can be better to use simpler approach with text fields for each language and function/ property to get the right field from templates. I even wrote the metaclass to make this

Re: Django multilingual

2008-01-27 Thread Ivan Illarionov
Models that need flexibility have `lang` and `is_translation_of` fields. Views (or custom managers) filter the output based on `lang` and add the link to other language if translation exists. Some models just have two separate text fields for each language and views (or custom managers) display th

Re: Django multilingual

2008-01-26 Thread Ivan Illarionov
Piotr, having django-multilingual features in the core won't make them any better. Complex models and use-cases will still need custom/manual solutions. It will add unneeded overhead to single-language sites and may even break the sites that use explicit custom solutions (like mine). I am develop

Re: django multi application, multi database, need to sync..

2008-01-18 Thread Ivan Illarionov
And it's also important to not really delete records from database. Use the 'delete' boolean field to mark unneeded records. On 18 янв, 06:18, otonk <[EMAIL PROTECTED]> wrote: > > Create the sync script using the Python DB API directly (no Django > > ORM). And then trigger it either automatically

Re: django multi application, multi database, need to sync..

2008-01-17 Thread Ivan Illarionov
On 17 янв, 05:58, otonk <[EMAIL PROTECTED]> wrote: > hi, i am currently designing two or more django application, one > application act as the master application, contains all the data, the > other application has partial function of the master application. The > master database belongs to the mas