Hi! I have something like this: cur.execute(""" select svc.post.id_post, svc.post.id_post_zone, svc.post.post_name as post_name, svc.post_zone.zone_name as zone_name, svc.post.id_post_type, svc.post_type.post_type_name, svc.post_type.post_color from svc.post inner join svc.post_zone on svc.post.id_post_zone = svc.post_zone.id_post_zone inner join svc.post_type on svc.post_type.id_post_type = svc.post.id_post_type where svc.post.id_post = :id """, {'id':post} ) And want to do something with that sql text if its sql (colorize or Command-R it via SQLDeveloper etc.). But scope for that string is "source.python ... string.quoted.double.block.python" Is it possible to fine tune scope selector? Any advice?
Alexey Blinov wrote:
And want to do something with that sql text if its sql (colorize or Command-R it via SQLDeveloper etc.). But scope for that string is "source.python ... string.quoted.double.block.python" Is it possible to fine tune scope selector? Any advice?
At the moment, you have to either modify the python grammar, or create your own new grammar which sources it. It's hard to do such extensions in an easy way which works for large numbers of users, and I can't wait for TM 2.0, which will supposedly make this sort of thing trivial. :)
Anyway, take a look at the language grammar section of the manual. If you have any specific grammar questions, the place to go for real-time help is the textmate IRC channel.
-Jacob
Doesn't PHP include the SQL grammar for strings that start with a SELECT? We could do this for Python as well if there are no strong objections.
Alexander Ross wrote:
Doesn't PHP include the SQL grammar for strings that start with a SELECT? We could do this for Python as well if there are no strong objections.
Well, if it's all-caps "SELECT" I suppose I wouldn't really mind. But I don't want "select an item" or whatever becoming SQL.
I'm not a PHP man ;) And i hate to use UPPERCASE if can not to use it.
On 10/9/07, Ciarán Walsh ciawal@gmail.com wrote:
On 9 Oct 2007, at 17:02, Jacob Rus wrote:
The PHP grammar requires the keyword to be in uppercase for just that reason
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Alexey Blinov wrote:
I have something like this: cur.execute(""" select svc.post.id_post, svc.post.id_post_zone, svc.post.post_name as post_name, svc.post_zone.zone_name as zone_name, svc.post.id_post_type, svc.post_type.post_type_name, svc.post_type.post_color from svc.post inner join svc.post_zone on svc.post.id_post_zone = svc.post_zone.id_post_zone inner join svc.post_type on svc.post_type.id_post_type = svc.post.id_post_type where svc.post.id_post = :id """, {'id':post} )
Off topic: have you tried any of the Python ORMs lying around? My good friend keeps raving about SQLAlchemy. :)
On 10/9/07, Jacob Rus jacobolus@gmail.com wrote:
Off topic: have you tried any of the Python ORMs lying around? My good friend keeps raving about SQLAlchemy. :)
Hmm... maybe i'll try SQLAlchemy for other project but this one it not good to start any ORM at all ;) There are alot of huge and dirty sql's i have to use. Alot of function calls, select from select, unions etc. As i know ORM idea doesn't like it ;) And i don't need cross-DB software.
On 10/9/07, Alexander Ross alex.j.ross@gmail.com wrote:
I agree that we'd have to use ALLCAPS to turn on the SQL highlighting.
Allcaps... i can live w/o .sql scope in this way ;)
Off topic: have you tried any of the Python ORMs lying around? My good friend keeps raving about SQLAlchemy. :)
Hmm... maybe i'll try SQLAlchemy for other project but this one it not good to start any ORM at all ;) There are alot of huge and dirty sql's i have to use. Alot of function calls, select from select, unions etc. As i know ORM idea doesn't like it ;) And i don't need cross-DB software.
FYI on your future projects, from what I understand, SQLAlchemy is meant to be quite good in this arena as well, being that it's not just a simple ActiveRecord pattern.
(not that I've used it very heavily ... just what I hear)
On 10/9/07, Alexander Ross alex.j.ross@gmail.com wrote:
I agree that we'd have to use ALLCAPS to turn on the SQL highlighting.
Allcaps... i can live w/o .sql scope in this way ;)
+1 on the ALLCAPS for SQL scope as well.
-steve
OK… I'm going to go ahead and add an include for SQL to any python string that begins with an all capital SELECT. (I know caps are ugly Alexei, maybe this will teach you not to embed sql in your strings. :D )
I'm not sure if I should also add an sql-include for unicode strings. Opinions?
Also, I don't think it makes sense to add an sql-include for raw strings, so I won't be doing that.
–Alex
On 10/9/07, Alex Ross alex.j.ross@gmail.com wrote:
OK… I'm going to go ahead and add an include for SQL to any python string that begins with an all capital SELECT. (I know caps are ugly Alexei, maybe this will teach you not to embed sql in your strings. :D )
Touché ;-) I'll try SQLAlchemy (or other one). Or any other suggestion? I'd like not to embed or do right way my code. And I open for ideas ;)
Touché ;-) I'll try SQLAlchemy (or other one). Or any other suggestion? I'd like not to embed or do right way my code. And I open for ideas ;)
I've added the sql-include to python strings... you should be seeing it in the next Cutting-Edge update, or sooner if you update your own bundles.
SQLAlchemy is pretty much the de-facto python SQL package these days. There is also SQLObject, but I haven't used it and I haven't heard as many nice things about it either.
–Alex
On 10/17/07, Alex Ross alex.j.ross@gmail.com wrote:
Touché ;-) I'll try SQLAlchemy (or other one). Or any other suggestion? I'd like not to embed or do right way my code. And I open for ideas ;)
I've added the sql-include to python strings... you should be seeing it in the next Cutting-Edge update, or sooner if you update your own bundles.
Personally, I'd also like to see similar for when a triple quoted string begins with a valid html tag that contains a namespace declaration (such as Genshi or Kid).
SQLAlchemy is pretty much the de-facto python SQL package these days. There is also SQLObject, but I haven't used it and I haven't heard as many nice things about it either.
I would also verify that when doing difficult things in sql in python, SQLAlchemy rocks. If you are doing easy things, look into Elixir (which is a layer on top of SQLAlchemy).
Ed
SQLAlchemy is pretty much the de-facto python SQL package these days. There is also SQLObject, but I haven't used it and I haven't heard as many nice things about it either.
Ok, ok ;-) Think I should try SQLAlchemy.
@Alex Ross Thanks again. Right now i downloading new TM update. Hope it will contain new Python bundle.
Ed Singleton wrote:
On 10/17/07, Alex Ross alex.j.ross@gmail.com wrote:
I've added the sql-include to python strings... you should be seeing it in the next Cutting-Edge update, or sooner if you update your own bundles.
Personally, I'd also like to see similar for when a triple quoted string begins with a valid html tag that contains a namespace declaration (such as Genshi or Kid).
What is a "valid html tag that contains a namespace declaration"? :)
-Jacob
Yes, fair enough. It is duly noted that I'm pretty much of idiot regarding [foo]ml specifications.
But kid and genshi both markup fragments of their language using snippets such as:
"""<div xmlns:py="http://purl.org/kid/ns#"> <h2>${item.title}</h2> <p py:for="thing in item.things">${thing}</p> </div>"""
When doing webstuff in python (using kid or genshi) you tend to write a lot of the fragments, and it would be outstanding if you could get them to be recognised as xhtml and coloured relevantly and all.
Ed
On 10/19/07, Jacob Rus jacobolus@gmail.com wrote:
Ed Singleton wrote:
On 10/17/07, Alex Ross alex.j.ross@gmail.com wrote:
I've added the sql-include to python strings... you should be seeing it in the next Cutting-Edge update, or sooner if you update your own bundles.
Personally, I'd also like to see similar for when a triple quoted string begins with a valid html tag that contains a namespace declaration (such as Genshi or Kid).
What is a "valid html tag that contains a namespace declaration"? :)
-Jacob
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Alexey Blinov wrote:
I'll try SQLAlchemy (or other one). Or any other suggestion? I'd like not to embed or do right way my code. And I open for ideas ;)
My coding partner, who has thus far handled all of our back-end database stuff, raves about how amazing SQLAlchemy is -- he had previous experience with SQLObject, which he found limiting (in particular, for some uses it made many more database requests than were required). And reading through his code, SA seems pretty neat, but I'll admit I myself haven't explored it in any deep way. :)
-Jacob