[01:22:42] ** hazmat has joined us [01:49:12] ** whit has joined us [01:57:09] ** whit has left IRC () [04:02:27] [connected at Thu May 19 04:02:27 2005] [04:02:27] <> *** Looking up your hostname... [04:02:27] <> *** Checking ident [04:02:28] <> *** Found your hostname [04:02:58] <> *** No identd (auth) response [04:02:58] <> *** Your host is zelazny.freenode.net[zelazny.freenode.net/6667], running version dancer-ircd-1.0.35 [04:02:58] [I have joined #peak] [04:02:58] ** zelazny.freenode.net set the topic to http://dirtsimple.org/2005/04/generic-functions-reloaded.html [05:22:52] ** apoirier has joined us [06:00:01] ** erikrose has left IRC (Remote closed the connection) [06:00:34] ** erikrose has joined us [07:28:05] ** bryn has joined us [12:06:02] ** jack-e|away has left IRC (Remote closed the connection) [13:10:01] ** sprout has joined us [13:11:27] ** whit has joined us [13:38:41] ** etrepum has left IRC (zelazny.freenode.net irc.freenode.net) [13:41:33] ** etrepum has joined us [16:20:41] ** apoirier has left IRC (Read error: 113 (No route to host)) [17:06:38] ** apoirier has joined us [17:31:56] ** hazmat has left IRC ("This computer has gone to sleep") [17:50:48] ** hazmat has joined us [18:41:28] ** bryn has left IRC (Read error: 145 (Connection timed out)) [18:51:08] ** bryn has joined us [19:10:54] ** apoirier has left IRC ("KVIrc 3.2.0 'Realia'") [19:19:54] ** cogumbreiro has joined us [19:19:58] lo all [19:20:16] hi erikrose, it's me s1x [19:34:37] ** debugger has joined us [19:35:23] hello [19:55:54] hi debugger [19:58:46] ** pje has joined us [19:59:28] erikrose, the reason the bulletins example uses SELECT MAX() is because SQLite uses exclusive transactions [20:00:21] pje: so it's safe to do it [20:01:03] Only with SQLite. [20:01:05] pje: but tell me something if it's autoincrement on is there any way to get the last ROWID? [20:01:07] It'd be crazy with any other DB except maybe Gadfly. :) [20:01:35] Heck if I know. If I ever get around to updating the bulletins example between now and peak.schema, I imagine I'll have to find out. :) [20:02:11] the more I use Peak the more I love it :D [20:04:01] lol [20:04:03] ** etrepum has left IRC (zelazny.freenode.net irc.freenode.net) [20:04:20] sqlite uses ROWID as the default PK [20:05:04] if u assign one PK *with* int and not null as PK he will alias ROWID with that one [20:05:16] Well, what do the docs at SQLite.org say is the right way to get the last PK or ROWID? [20:05:37] there's a function to do it [20:05:39] ** etrepum has joined us [20:05:41] Or in the alternative, what do the PySQLite docs say is the right way? [20:05:43] i've seenit somewhere [20:05:58] to get the last? i didn't see that posted anywhere [20:06:04] but u can do a MAX(rowid) [20:06:08] since it is unique [20:06:29] but I think there's a function, just don't know how it gets exposed in peak.storage [20:06:38] This is probably a useful application of PEAK's "application-specific database hooks" feature. [20:07:07] You can basically define a namespace in your configuration that includes values that can vary by database type [20:07:32] Such that you could have a name that maps to the right function to create a key, for the current backend (e.g. SQLite vs. PostgreSQL) [20:07:32] http://sqlite.org/capi3ref.html#sqlite3_last_insert_rowid [20:07:34] here u go [20:08:11] The way it works is like this... you create sections in an .ini for different drivers, e.g.: [20:08:26] please do continue [20:08:28] [sqlite.appConfig] [20:08:29] i am all "ears" [20:08:44] getPrimaryKey = some_module.sqlite_getRowID [20:08:58] [pgdb.appConfig] [20:09:10] getPrimaryKey = some_module.postgres_get_sequence [20:09:23] And then in your code, you would use something like: [20:09:46] oid = conn.appConfig.getPrimaryKey(tableName) [20:09:55] er, make that: [20:09:55] wow [20:10:00] oid = conn.appConfig.getPrimaryKey(conn,tableName) [20:10:07] that would be great [20:10:24] And in practice, you should probably use more qualified names, e.g. 'tableDM.getPrimaryKey' instead of just 'getPrimaryKey' [20:10:56] But then you have to do this: [20:11:18] oid = conn.appConfig['tableDM.getPrimaryKey'](conn,tableName) [20:11:26] Or better yet, just add this to your class: [20:11:52] getPrimaryKey = binding.Obtain('conn/appConfig/tableDM.getPrimaryKey') [20:12:00] Assuming 'conn' is your connection attribute, of course. [20:12:04] ehehe [20:12:21] Then use self.getPrimaryKey(self.conn, tableName) [20:12:53] I created the appConfig namespace to help support migrating a Sybase application to work with Oracle [20:13:18] But of course it can also work nicely for building flexibility in from the start. [20:13:59] the problem is pysqlite doesn't support this [20:14:07] the rowid thingy [20:14:20] Well, submit a patch. :) [20:14:39] ehehe [20:16:26] i have some questions about peak.model [20:16:50] Go ahead [20:16:54] i have a little helper class that i've defined called TableDM [20:17:03] one thing it uses is Fields [20:17:26] i have an example somewhere [20:17:50] http://wiki.s1x.homelinux.net/Peak/TableDM [20:18:09] this version has a bunch of bugs but the usage is mostly there [20:18:21] see the example please [20:18:44] ok I have typed Fields which map directly to a the model.Attribute's [20:20:11] i am currently requiring the "user" to define the wildcards and ways to convert from one to another. Is there anything in Peak that already handles this? [20:21:38] so that if i have a model.Integer I do not have to redefine the types in my TableDM again... [20:21:58] ah forget it... i'm too vague... i don't know what to ask :( [20:21:59] lol [20:22:37] bummer... and I was imagining the questions in my mind so that I could ask u on the IRC next time... [20:22:51] Maybe email would be better [20:22:56] yeah [20:23:08] one question was what type of metadata can I add into a model? [20:23:09] There is a mapping *from* SQL types to whatever types you want [20:23:18] where? [20:23:44] Using e.g. '[sqlite.sql_types]' [20:24:02] You use the names defined by the DBAPI module, like INTEGER, VARCHAR, etc. [20:24:13] yes [20:24:24] And you specify a converter object, which takes two args: a DBAPI field description and a value [20:24:34] So if you do, e.g. [20:24:39] [sqlite.sql_types] [20:24:49] INTEGER = lambda d,v: long(v) [20:24:57] Then all your INTEGER fields will be made longs. [20:25:10] There isn't currently a mechanism for going the other way. [20:25:28] i see [20:25:55] I've been thinking that maybe each DB would have an interface for "a value that I can use", and adapt Python-supplied values to that interface. [20:26:13] E.g. to convert Python datetime objects into the DB's TIMESTAMP type. [20:26:27] yes that would be great [20:27:10] But in truth I think the problem is rather more complex than that, and in any case the generic function solution in peak.schema will let us just start doing what we need to. [20:27:31] And then we can go back and make a pretty API after we know what we really need it to do, still retaining the ability to special-case things. [20:27:45] yes [20:28:19] For that matter, if I'd had generic functions "back in the day", I probably wouldn't have created the 'appConfig' namespace [20:28:33] :) [20:28:50] It would've been just as easy to make generic functions for any function that needed to vary behavior by SQL driver. [20:29:30] In fact, you may prefer to do that for your 'getPrimaryKey', since then you won't have to make sure the stuff gets into an .ini file; just set it up in Python and you're good. [20:29:59] :) [20:30:04] I've got to go for now. TTYL. [20:30:11] * pje waves [20:30:14] ** pje has left IRC ("Client exiting") [20:36:20] ** whit has left IRC (Read error: 145 (Connection timed out)) [20:53:37] ** cogumbreiro has left us [20:54:18] ** whit has joined us [20:57:30] ** whit has left IRC (Client Quit) [21:16:36] ** hazmat has left IRC ("This computer has gone to sleep") [21:27:27] ** sprout has left IRC ("Snak 5.0 IRC For Mac - http://www.snak.com") [22:12:06] ** debugger has left IRC ()