Pyramid+SQLAlchemy: create filter with multiple OR conditions

…my first step with Python…

When you add filter with multiple criterion conditions joined by AND, you simply put all conditions one after one separated by comma:

query = DBSession.query(SomeTable).filter(
                SomeTable.name.contains(search_str),
                SomeTable.description.contains(search_str),
                SomeTable.another_field.contains(search_str)
        )

But in case you need to join filter conditions with OR, the way is more tricky… I found this approach working for me:

Add import:

from sqlalchemy import or_

And then, your filter should look like this:

query = DBSession.query(SomeTable).filter(
            or_(
                SomeTable.name.contains(search_str),
                SomeTable.name.contains(search_string2),
                SomeTable.description.contains(search_str),
                SomeTable.another_field.contains(search_str)
            )
        )

Enjoy!

Internet Explorer limits number of external CSS files to 32

Do you know IE has a limit of 32 external CSS files? Do you know each file should be up to 288Kb to get parsed?

I didn’t know and found this just a little bit of time ago. As Google says IE has a bug (well, someone names this a limitation which makes sense): number of external CSS files you can import is 32, everything beyond the 32th file will be ignored. In addition to this – CSS file size cannot exceed 288Kb, otherwise it will be ignored as well. This limit is present in Internet Explorer 6/7 and 8.

Seems IE is the only browser with such a limit, other browsers worked well for me with 33 external style sheets (Firefox, Opera, Safari, Google Chrome, Konqueror).

Solution: aggregate multiple CSS files in bigger ones. As my experience shows – most files are 5-20Kb in size, and one 40Kb file is faster than 8x5Kb.





How do I create DIVs with rounded corners

In this post I want to describe a way I use to get a “DIV” with nice rounded corners like this one. This way isn’t something new, but as I noticed it is used not so often as other ways. Let’s go through it and see its advantages and disadvantages.

Read the rest of this entry »

just few words

1.5 months ago, 6 weeks or 42 days. I haven’t updated my simple blog since that time.

I haven’t a time to deal with my CakePHP projects, but got a pretty nice experience with other things.

Currently I work with Propel based custom framework with extensive usage of jQuery which I found very nice and going to use with CakePHP (when I have a time of course :) ).

Propel is very handy thing as well, it plays role of database communication layer, in other words Propel is ‘model’ component of a framework.

Well, I’m new to these things and sometimes spend a lot of time to figure simple things, but I’m sure when say “Propel rocks! jQuery rocks!” :)





Hello World!

Hello World, this is the first entry in my blog where I’m going to write about some web development stuff, especially CakePHP framework which I’ve started to learn a couple days ago. The blog is named ‘simple’ as everything consists of simple things. Let’s wait a bit and see what it all look like.

Read the rest of this entry »