[04:02:25] [connected at Mon Nov 15 04:02:25 2004] [04:02:26] <> *** Looking up your hostname... [04:02:26] <> *** Checking ident [04:02:26] <> *** Found your hostname [04:02:57] <> *** No identd (auth) response [04:02:57] <> *** Your host is sterling.freenode.net[freebsd.widexs.nl/6667], running version dancer-ircd-1.0.35 [04:02:58] [I have joined #peak] [04:02:58] ** sterling.freenode.net set the topic to http://dirtsimple.org/2004/11/generic-functions-have-landed.html [04:51:26] etrepum_ is now known as etrepum [07:13:02] ** apoirier has joined us [07:16:59] ** vlado has joined us [09:37:59] ** rdmurray has left IRC ("User disconnected") [09:38:24] ** rdmurray has joined us [11:02:26] ** vlado has left IRC (Connection reset by peer) [11:03:33] ** vlado has joined us [11:50:38] ** rdmurray has left IRC ("User disconnected") [11:52:57] ** vlado has left IRC ("Leaving") [12:13:03] ** [nicknam] has joined us [12:21:35] ** apoirier has left IRC (Read error: 60 (Operation timed out)) [12:44:55] [nicknam] is now known as apoirier [14:22:49] ** rdmurray has joined us [14:49:15] ** apoirier has left IRC ("Using KVIrc 3.0.1") [15:21:32] i have an app that needs to reread a config file every n seconds, but when it goes to reread it, i get the AlreadyRead exception... i was expecting this, but what do I need to do in order to reassign to that property? [15:23:12] i have an app that needs to reread a config file every n seconds, but when it goes to reread it, i get the AlreadyRead exception... i was expecting this, but what do I need to do in order to reassign to that property? [15:27:51] You can delete the attribute, but that only helps if the attribute value is computed. The config system is designed to be read-once. [15:44:29] ahh, i see [15:45:01] so, i have a config file that may be updated by another process [15:45:41] can i read the file into another namespace? [15:45:51] Do you need PEAKs features in that config file? Maybe you could just use one of python's native config file formats. [15:46:16] Hmm. I suppose you could create a new context and read it into that, and pull stuff out of it. I'm not sure. [15:46:58] well, I want to use peak's features [15:47:55] But do you need those features for the particular data the other process is going to update? [15:49:06] no, i just want to be able to bind attributes to foo.foo.bar [15:49:28] the file itself could prolly be read with ConfigParser [15:50:40] Is it just that you want the attribute to be bound to the config data? You could use a normal python property for that. [15:50:55] yeah i guess you're right [15:52:15] PJE said that there are multiple contexts in config space, so in theory I think you could read your config file into a new context. But then you'd still have to use a normal python property to be able to access that data, because the config context of your classes would still be their original context. At least, I think that's how it works. [15:52:32] yeah [15:52:41] peak is really cool, btw [15:52:42] Hmm. context is the wrong word I think, but I can't remember what he called it. [15:52:47] Yeah, I think so too. [15:53:55] using the peak.naming URL classes eliminates a buttload of annoying object-instantiation problems [15:54:33] true. [17:02:41] ** pje has joined us [17:03:08] arg, what kind of config file are you reading? [17:03:27] And rdmurray, did you find the enum conversion you needed? [17:03:34] Nope. [17:03:44] But I got distracted and didn't look very hard. [17:03:53] just use 'TheEnum(thestring)', I think. [17:04:28] >>> from peak.api import * [17:04:28] >>> class E(model.Enumeration): [17:04:28] e=model.enum() [17:04:28] [17:04:29] >>> E('e') [17:04:33] E.e [17:04:35] >>> [17:04:41] cool [17:05:00] And of course there's also the normal .mdl_fromString() [17:05:33] as in MyEnum.mdl_fromString(s) [17:05:38] Ah. [17:05:43] I should have tried that. [17:06:02] Does mdl_fromString get called automatically at any point? [17:06:10] I don't think so. [17:06:26] I don't remember enough about how Enumeration is implemented at the moment. [17:06:53] I meant in general. Like does it get called if you assign a string to an attribute. [17:07:00] Oh, no. [17:07:24] But SomeClass.someFeature.fromString() is a pointer to someFeature.referencedType.mdl_fromString() [17:07:43] Ah. That's good to know. [17:07:46] PEAK doesn't try to guess what you mean when you assign something; it figures you mean to assign what you assigned. [17:07:54] good :) [17:08:05] All of the fromString/toString stuff is for serialization and UI purposes. [17:08:26] In peak.schema, though, it will be broken out and not part of the model and feature classes. [17:08:44] Instead, there'll be functions like 'fromString(type,value)'. [17:08:50] (Generic functions, of course.) [17:09:03] Or perhaps even fromString(feature,value). [17:09:34] The latter would be better, I think. [17:09:35] But anyway... they'll be separate, not embedded, making it possible to extend them, reuse in different contexts... [17:09:53] And most importantly, to reduce the overwhelming complexity of the innards of the model system. :) [17:09:58] :) [17:10:15] Well, there's no reason the function can't take either types *or* features, being as it'll be generic. :) [17:10:24] arg, are you around? [17:10:33] true [17:11:00] When I first dialoged with him it took him maybe fifteen minutes to notice my response. [17:11:09] Especially since implementing the feature part would consist of something like: 'return fromString(feature.referencedType,value)' :) [17:11:30] * pje nods [17:12:12] Of course, even things like referencedType are going to switch to being functions, like getReferencedType(feature). [17:13:09] Why is that? [17:13:26] Oh, extensability. [17:13:28] duh [17:13:32] To allow schemas as a whole to be reused. [17:13:52] One of the specific use cases is "class replacement therapy" ;) [17:14:03] As in, this version of the app, you want to replace a class with some subclass. [17:14:28] However, I'm not 100% certain that that won't be taken care of via workspace references. [17:14:58] That is, a workspace-specific class knows what workspace it's in, so it *could* use referencedType attributes that delegate back to a function on the workspace. [17:15:24] But, whatever the API looks like, it will pass through a workspace somewhere, even if it's the "Null Workspace". [17:17:13] I still need to hunt up and read the workspace post. [17:17:37] Me too. :) [17:17:45] Or, I will whenever I get around to implementing it. [17:17:57] :) [17:18:00] That's why I write up those things and send 'em to the list. Get it down while I'm thinking about it for later. :) [17:26:55] Hmm. Do you happen to know of a date input conversion package for python? [17:27:06] dateutil, perhaps? [17:27:25] * rdmurray googles [17:27:50] https://moin.conectiva.com.br/DateUtil [17:28:04] thanks [17:29:47] Dates give a wonderful example of why it was a broken idea to put mdl_fromString into peak.model and expect it to be a complete solution. :) [17:32:14] Anyway, DateUtil has a remarkable variety of input parse formats, time zone processing, repetition rules, iCalendar support... [17:32:47] I think it has been suggested by some that it should become a stdlib module. [17:33:25] It certainly looks comprehensive from a quick look at it. [17:34:46] Yeah, with examples like "Monthly, on the second-to-last Monday of the month, for 6 months" [17:35:48] Heh. Or "the next 4 Friday the 13ths". :) [17:37:00] I think I may have a need for one or two of those features :) [18:21:10] Is there any way to go the other way on Enums? Get back just the portion of the name after the dot? [18:21:33] Did you try anEnum.mdl_toString()? [18:21:46] Also, try anEnum.name... I think that might be without the dot. [18:21:56] For that matter. [18:21:58] Well, I did self.__class__.attrib.toString() [18:22:11] No, that won't work without a value. [18:22:25] well, I gave it a value :) [18:22:33] And got the dotted name. [18:22:46] >>> from peak.api import * [18:22:46] >>> class E(model.Enumeration): [18:22:46] e=model.enum() [18:22:46] [18:22:47] >>> E('e').name [18:22:49] 'e' [18:22:51] >>> [18:22:54] great [18:23:35] Can I associate my own attributes to an enum value? Like give it a 'value' of my choice? [18:23:46] e = model.enum(someValue) [18:23:56] Cool. [18:24:16] I thought I'd looked at the source code, but I must not have, to have missed all this. [18:24:16] >>> class E(model.Enumeration): [18:24:16] e=model.enum(1) [18:24:16] [18:24:16] >>> E(1) [18:24:17] E.e [18:25:20] >>> E(1)==1 [18:25:20] 1 [18:25:38] 'E.e' will hash and compare equal to 1. [18:26:20] How can I turn it into an integer? [18:26:29] You can't. [18:26:41] It's an enumeration. [18:26:45] Rats. [18:27:00] Why would you want it to be an integer, if it's an enumeration? [18:27:00] I guess I really want named values :) [18:27:16] You can always use it as a dictionary key: {E.e:1} [18:27:33] The names are for the user interface, the integers are for operations inside the model. [18:27:39] Or you can cheat and pull out its '_hashAndCompare' attribute, but of course that's not guaranteed to hang around. [18:27:51] k [18:27:52] Yeah, but then it's not an *integer*, is it? [18:27:55] I'll just use the dict. [18:27:57] It's an enumeration? [18:28:24] Well, I suppose. [18:28:32] I guess I'm just being lazy :) [18:28:57] There's also another way you can do it... [18:29:03] class E(model.Enumeration): [18:29:22] __dontcare = model.enumDict(mapping) [18:29:40] This will create the name/value pairs from the dictionary. [18:31:02] So you can then reuse the dictionary. [18:31:23] Heck, here's the really silly part... if you don't use enumDict, just make a dictionary like this: [18:31:32] {1:1, 2:2, 3:3...} [18:31:44] or dict([(i,i) for i in range(whatever)]) [18:32:05] Because the enums will hash and compare equal to the integers, so you don't need to put enums or names in the keys. :) [18:36:36] Btw, a lot of this stuff is covered in 'peak help model.Enumeration' [18:37:22] I think I'll stick with using the external dictionary to convert the enumeration. If I can just figure out where this rogue value is coming from. [18:38:01] I suppose I could always add a 'value' property to enumerations, to make it easier. [18:51:59] Well, gotta run. [18:52:14] If 'arg' ever shows back up, tell him to post his question to the list. [18:52:25] * pje waves [18:52:27] ** pje has left IRC ("Client exiting") [19:56:55] ** gaby has left IRC ("It's not like I'm leaving or anything...") [20:11:14] * arg returns [20:16:39] PJE said to post your question to the mailing list, and he'll try to answer. [23:07:32] ** hazmat has joined us