IRC log of #schooltool for Tuesday, 2011-03-15

*** menesis has quit IRC01:39
*** replaceafill has quit IRC04:03
*** aks has joined #schooltool05:08
*** aks has quit IRC06:03
*** replaceafill has joined #schooltool06:25
*** aks has joined #schooltool06:33
*** th1a has quit IRC06:56
*** yvl has quit IRC07:43
*** yvl has joined #schooltool07:51
aelknerhey yvl07:52
yvlgood evening aelkner07:52
aelknerand good afternoon to you07:52
aelknerwhat to discuss first...07:53
aelkneractually, i just realized, it's morning for you :)07:53
yvlright :)07:53
aelknerhave you had your coffee?07:53
yvlnot yet07:54
yvlgimme 3 minutes :)07:54
aelknersure thing07:54
yvland I'm good :)07:56
aelkneryvl, did you mean now you're good?08:01
yvlI have my coffee08:02
yvlhttp://forum.wordreference.com/showthread.php?t=3396308:03
aelkneryeah, i'm good is the less proper, hence, cooler way to say i'm fine08:04
aelkneranyway08:04
yvlright08:05
aelknercan i ask you first about what you thought i could do with the widget to get rid of isAdding()?08:05
aelkneryou see, the widget gets called in the add or edit view08:05
yvlwell, I forgot it's formlib08:05
aelknerand the context is different08:05
aelknerand also, the condition of what to expect from the request is different08:06
aelkneranyway, i looked at the registration and the zope formlib code where the widget gets looked up08:06
yvlcomponent.getMultiAdapter((field, request), viewType)08:07
aelknerand i don't see any difference in the adapter call in edit or add08:07
aelknerright08:07
aelknerviewType is IInputWdiget08:07
aelknerbut that's in edit and add both08:07
yvlyes08:07
aelknerso i don't now what you would suggest it would do08:08
yvlumm08:08
aelkneri would do08:08
yvllistening08:08
aelknerno, that's my question08:09
aelknerwhat would you suggest?08:09
yvlah08:10
yvlwell, you could set up custom widget in one of the views08:10
yvlbut I'm not sure if it's worth the hassle08:10
yvlI mean -08:11
yvlhave the common widget, then special child class for adding08:11
yvland set a custom widget in the adding view08:11
aelkneroh08:11
yvlit's a good refactoring exercise08:12
yvlso it's your choice really08:13
aelknerin the addform directive, there are things like:08:13
aelkner<widget field="presenting_concerns" width="54" height="10" />08:13
aelknerbut that is just for adjusting the attributes of the automatically found widget08:14
aelknerhow would one suggest a custom widget?08:14
aelkneroh, is this assuming z3c.formlib?08:14
replaceafillaelkner, i think it assumes zope.app.form08:16
yvlno, zope.app.form has it08:16
yvlbut yes, it's just **keywords passed to custom widget factory08:16
aelknerdo we have an example in schooltool core?08:17
yvllookin08:17
* replaceafill thinks <addform... />, <editform ... />, <menuItem... /> should die and go to hell!!!08:18
yvlfrom zope.app.form import CustomWidgetFactory08:18
yvlview.persons_list_widget = CustomWidgetFactory(YourWidgetClass, param1=x, param2=x)08:20
yvlparams are optional08:20
aelknerso you're saying in the __init__ for the add view say:08:20
aelknerself.persons_list_widget = CustomWidgetFactory(YourWidgetClass, param1=x, param2=x)08:21
aelknerit would help if we had done this kind of thing before in core08:21
yvljust not the init08:22
yvldef _setUpWidgets(self):08:22
yvlself.persons_list_widget = CustomWidgetFactory(YourWidgetClass)08:22
yvlBaseClass._setUpWidgets(self)08:23
yvlI think in the old days there may have been custom widgets in core08:23
yvlbtw, hey replaceafill  :)08:25
replaceafillhey yvl :P08:25
aelknerreplaceafill, you still up?08:25
* yvl has slow reaction time this morning for some reason :)08:25
replaceafillaelkner, nope... zzzzzz08:25
replaceafillzzzz08:25
aelknertalked to the family yet?08:26
replaceafillyvl, not enough coffee?08:26
yvlyes! :D08:26
replaceafillaelkner, indeed08:26
aelknerare you sprinting this week?08:26
aelknerwith jelkner?08:26
replaceafillnot the whole week08:26
replaceafilli'm going back on wednesday08:26
aelknerah, well are you working with jelkner and/or filip08:27
replaceafillyep08:27
aelknercool08:27
replaceafill:)08:27
replaceafillfilip is the one doing the work actually, i just clean his laptop screen when it's dirty08:28
yvl:D08:28
replaceafillbring him coffee and stuff08:28
aelknerso you're having lots of fun i see :)08:30
aelkneryvl, i'll look into the whole custom widget thing later, but i'd like to talk catalog08:32
yvlsure08:32
aelknercan you explain the task performed by the contact catalog diff you referred me to?08:32
yvlI removed the catalog utility there08:33
yvland replaced it with another catalog implementation08:33
yvlthe one I wrote :)08:33
aelknerwhat is point of the new style catalog?08:33
yvlwell, first - less evolution08:33
yvlyou change the version string, app takes care of the rest08:33
yvlif you change cataloged attributes defined explicitly in attributes = ('', '')08:34
yvlapp creates relevant indexes08:34
yvland it's not a subscriber,  so people can replace / remove it08:35
yvlclass PersonCatalog(AttributeCatalog):08:36
yvl    version = '1 - replaced catalog utility'08:36
yvl    interface = IBasicPerson08:36
yvl    attributes = ('__name__', 'title', 'first_name', 'last_name')08:36
yvlgetPersonCatalog = PersonCatalog.get08:36
yvland thats it for the person catalog08:36
aelknerso it allows for customization where the subscriber wouldn't?08:37
yvlyes08:37
yvlalso, in zcml:08:37
yvl  <adapter factory=".person.PersonCatalog"08:37
yvl           name="schooltool.person.person.PersonCatalog" />08:37
yvl  <adapter08:37
yvl      for="schooltool.person.interfaces.IPersonContainer"08:37
yvl      factory=".person.getPersonCatalog"08:37
yvl      provides="zope.catalog.interfaces.ICatalog" />08:37
yvland that's it08:37
yvlbut mostly I did this for evolution08:39
aelknerto prevent for the need for future evolutions?08:39
yvlyes08:41
yvlat least to reduce it08:41
yvlalso, UtilitySetup is going away at some point08:42
yvlso it would be nice to do replace the catalog now08:42
yvlas for first_name / last_name refresh problem...08:45
yvlI would add 'student' index to the catalog08:46
yvland store the intid of the student of messages/goal08:46
yvls08:46
yvlthen, looking at app/catalog.py08:46
yvlmkay, catalog.py uses subscribers :/08:47
yvlanyway08:47
aelkneroops :)08:47
yvlyou'd need an adaptersubscriber to (IntIdAddedEvent, IContact)08:48
yvlalso, modified event and removed event08:48
aelknerand what do i do, for instance in the added event subscriber08:49
yvlthat fires similar event to08:49
aelknerthis is called whenever a contact is added, right?08:49
yvlrelated intervention objects08:49
yvladded, when added08:49
yvland so on08:49
yvlyes08:49
yvlso, obj_id = util.getId(obj)08:49
yvlthen get interventions catalog08:49
yvlif you use the new style catalogs, it's08:50
yvlInterventionCatalog.get()08:50
yvlintervention_object_intids =  catalog['student'].values_to_documents.get(obj_id)08:51
yvlif intervention_object_intids:08:51
yvlfor intid in intervention_object_intids08:51
yvlnotify(IntIdAdded event for util.getObject(intid))08:51
yvlbut also it would be good to put XXX'es there08:52
yvlthat this event forwarding is done ONLY because:08:52
yvl1) schooltool table formatter does not support values drawn from multiple catalogs08:53
yvl   (I mean, easily - I know it can be hacked)08:53
yvlwell, there's no reason number two08:54
aelknerwhy are you talking about a student catalog?08:54
aelknerwe don't have one08:54
yvlit's not a student catalog08:54
yvlit's intervention catalog08:54
aelknerand the only one that is causing a problem is the persons_responsible catalog08:54
yvlwith additional index08:55
yvlstudent08:55
aelknerok, wait08:55
yvlah, righ, that one also08:55
aelknerlet's slow down for a sec08:55
aelknerright now we have on intervention catalog08:55
aelknerthat has multiple indeces08:55
aelknerit is setup in the old way08:55
aelknervia utility call08:55
aelknerso changing that is one thing08:56
aelknerbut dealing with the problem at hand, we have a persons_responsible index that is a list of ids08:56
aelknerincluding the student_id:2, for example08:56
aelknerwhat would we be changing the to, a list of intids instead?08:57
aelknerintids of contacts?08:57
yvla tuple preferably, yes08:57
aelknerso that cold be done without changing to new style, rght?08:57
yvlyes08:57
aelkneri just want to separate the tasks08:57
yvlsorry, I should have started with this08:57
yvlsure08:57
aelknerit is important to solve the crisis first08:57
yvl:)08:58
yvltrue08:58
aelknerten worry about new style stuff, am i right?08:58
yvlabsolutely08:58
aelknerok, remember, i confuse easily :)08:58
aelknerso in theory, i could keep it simple in my next change08:59
aelkneri could update the getPersonsResponsible adapter08:59
aelknerto return the list of initds rather than obj.persoins_responsible08:59
yvlbut that adapter is used in other places, isn't it?09:00
aelknerno, only by the index09:00
aelknerthat's why it lives in catalog.py09:00
aelknerit's the only case where i need to adapt an object of unknow type (goal or message)09:01
aelknerto an attribute09:01
aelknerit was the first time i ever did anything like that09:01
aelknerbut i understood it was necessary because the index is defined as follows:09:01
aelknerdef _setUpWidgets(self):09:01
aelknerno, sorry09:02
aelknerbad paste buffer09:02
aelknercatalog['persons_responsible'] = ConvertingIndex(09:02
aelkner        converter=interfaces.IInterventionPersonsResponsible)09:02
aelknerthat's it09:02
aelknerso the auto-magic of catalog would call that adapter for a goal or message and get back the attribute09:02
aelknerthen it would just put that as the key of the index entry09:03
aelknerso if i just change the adapter to return a list of initids09:03
aelknerthen the only other thing that needs to change is the table filter widget09:04
aelknerthat currently says:09:04
yvlhmm09:04
yvlI see it is used for crowds09:04
aelkneruser_contact = IContact(IPerson(self.request.principal))09:04
aelkner        pr_idx = catalog['persons_responsible']09:04
aelkner        items = [item for item in items09:04
aelkner                 if user_contact in pr_idx.documents_to_values[item['id']]]09:04
aelknerwhich fails, of course because the idex currently has lists of ids09:05
aelknerand need to evolve09:05
aelknerso i would change the adapter as suggested09:05
yvlumm, IF you are willing to change to new catalogs09:06
aelknerand in the filter i would change to have user_contact = IContact(IPerson(self.request.principal))09:06
yvlyou can postpone writing evolution09:06
aelkneruser_contact = initids.getId(user_contact)09:06
aelkneror something like that09:06
yvlyeah09:06
aelkneryeah is for the change to adapter and filter i just suggested, right?09:07
yvlyes :)09:07
aelknerok, and the new catalog idea would avoid need for evolving the index09:08
aelkneronly that i would need to evolve the catalog to remove the utility as you did in the diff09:08
yvlyou would still need the evolution that removes the utility09:08
aelknerbeat you :)09:08
yvlbut index update would become obsolete09:08
yvl:)))09:08
aelkneryou'll have to explain why that is the case09:09
aelknerwhy can i change an adapter and automatically the index changes?09:09
yvlwell, new-style catalogs will reindex themselves09:09
aelknerwhy?09:09
aelknerwhat event?09:10
yvlif you change the adapter, the index does not change09:10
yvlwhait what?09:10
yvlevent?09:10
aelknerwhat action causes the reindex?09:10
yvlah09:10
yvlwhen you register catalog09:10
yvlit has it's own AppStartUp09:10
yvlor...09:11
yvlCatalogStartUp event to be precise09:11
yvlthen some mechanism checks catalogs registered for this09:11
yvllooks who got expired09:11
yvlcatalogs expire when:09:12
yvltheir version string changes09:12
yvlfor AttributeCatalog, alos:09:12
yvlwhen the list of catalogged attributes changes09:12
yvlattributes = (aaa,aaa,aa)09:12
yvlor cataloged interface name changes09:12
yvlinterface = IFooSomething09:12
yvlif you add your own indexes, or reimplement some adapter, or change the interface name09:13
yvlyou need to change the version string09:13
yvlsorry, I didn't write documentation for that yet09:13
aelkneri'm confused about the correspondence09:14
aelknerin my catalog setup, i create indeced each time saying something like:09:15
aelknercatalog['first_name'] = ConvertingIndex(converter=getStudentFirstName)09:15
aelkneror:09:15
aelknercatalog['created'] = ValueIndex('created')09:15
aelknerso the catalog is a dict09:15
aelknerand the setup method populates the dict with various indeces09:16
aelkneraccessible via dict key lookup09:16
aelknerbut the values can be any index type, ConvertingIndex or ValueIndex09:16
aelkneror whatever09:16
aelkneri don't see how a list of attributes replaces that09:16
aelknerValueIndex seems to go by attribute09:17
aelknerbut ConvertingIndex goes by adapter09:17
aelknerso you see my confusion?09:18
*** yvl has quit IRC09:18
*** replaceafill has quit IRC09:27
*** yvl has joined #schooltool09:27
yvlsorry09:28
yvlit seems I pingged out or something09:28
yvlping aelkner ?09:28
aelknernp09:28
yvl<yvl> ah09:28
yvl<yvl> when you register catalog09:28
yvl<yvl> it has it's own AppStartUp09:28
yvl<yvl> or...09:28
yvl<yvl> CatalogStartUp event to be precise09:28
yvl<yvl> then some mechanism checks catalogs registered for this09:28
yvl<yvl> looks who got expired09:28
yvl<yvl> catalogs expire when:09:28
yvl<yvl> their version string changes09:28
yvl<yvl> for AttributeCatalog, alos:09:28
yvl<yvl> when the list of catalogged attributes changes09:28
yvl<yvl> attributes = (aaa,aaa,aa)09:28
yvl<yvl> or cataloged interface name changes09:29
yvl<yvl> interface = IFooSomething09:29
yvl<yvl> if you add your own indexes, or reimplement some adapter, or change the interface name09:29
yvl<yvl> you need to change the version string09:29
yvl<yvl> sorry, I didn't write documentation for that yet09:29
yvl<yvl> for reference:09:29
yvl<yvl> class PersonCatalog(AttributeCatalog):09:29
*** yvl has quit IRC09:29
*** yvl_ has joined #schooltool09:29
aelknerholy channel flood batman!09:29
*** yvl_ is now known as yvl09:29
yvlright09:29
yvl<yvl> for reference:09:30
yvl<yvl> class PersonCatalog(AttributeCatalog):09:30
yvl<yvl>     version = '1 - replaced catalog utility'09:30
yvl<yvl>     interface = IBasicPerson09:30
yvl<yvl>     attributes = ('__name__', 'title', 'first_name', 'last_name')09:30
yvl<yvl> if you rename the interface, or add/remove attributes, it will be reindexed next time the server starts09:30
yvl<yvl> Another example:09:31
yvl<yvl> class ContactCatalog(AttributeCatalog):09:31
aelknerwhy are you flooding the channel with stuff you already said?09:31
yvl<yvl>     version = '1 - replaced catalog utility'09:31
yvlwhat was the last thing I said?09:31
aelknerwhat's your chat client?09:31
yvlxchat, but that does not matter09:32
yvlwhat was the last thing I said?09:32
aelknerwhenever i rejoin, XCHAT, it gives me whatever i missed09:32
aelknerwhat about all the stuff i said?09:32
aelkneryou should look at the saved log09:32
aelknerhttp://schooltool.pov.lt/irclogs/latest.log.html09:33
yvlyes09:33
yvlthe last thing I said there was sorry, I didn't write documentation for that yet09:33
yvland then pingged out09:33
aelknerthen you see what i said/asked09:33
aelknerending with see my confusion?09:34
yvlyes09:34
aelkneri think your new catalog assumes all value indeces, right?09:34
yvlno09:34
yvlI was kind of explaining that09:34
yvlafter pinging out09:34
yvlan example of this is contact catalog:09:35
yvlclass ContactCatalog(AttributeCatalog):09:35
yvl    version = '1 - replaced catalog utility'09:35
yvl    interface = IContact09:35
yvl    attributes = ('first_name', 'last_name')09:35
yvl    def setIndexes(self, catalog):09:35
yvl        super(ContactCatalog, self).setIndexes(catalog)09:35
yvl        catalog['form_keys'] = ConvertingIndex(converter=IUniqueFormKey)09:35
aelknerah, ok09:35
aelknerfair enough09:36
yvlso you add those manually09:36
yvlif you change the way IUniqueFormKey gets the form key09:36
yvlyou need to change version string09:36
yvlif you add, say  catalog['simple_keys'] = ConvertingIndex(converter=simple_form_key)09:36
yvlagain - change the version string09:36
yvlthere :)09:36
yvlflood complete :)09:36
aelkner:)09:36
aelknerso if my catalog was already new style09:36
aelknerthen changing the version would cause it to reindex09:37
yvlyes09:37
aelknerhence the lists of ids would automatically be changed to lists of intids09:37
aelknerbecause i had changed the adapter09:37
yvlyes09:37
aelknerso starting with now, if i make it a new style, i just write the same evolution to remove the old catalog09:38
aelknerand i'm done09:38
yvlyes09:38
aelkneri'll try that then :)09:38
yvl:)09:38
aelknerno when a contact is removed09:39
aelkneri need to write my own event subscriber09:39
aelkneradaptersubscriber09:39
aelknerfor (IntIdAddedEvent, IContact)09:40
aelknerno09:40
aelkner(IntIdRemovedEvent, IContact)09:40
aelkneri don't care about new contacts being added09:40
aelknerbecause they wouldn't be in my index anyway09:40
aelkneronly the ones that are removed are important09:41
yvlor modified09:41
yvlbut that would solve first_name, last_name caching problem09:41
aelknerwhat first_name, last_name caching problem?09:41
aelknerdidn't know we had one09:41
yvlchange the last name of the contact09:41
yvlcatalogs won't be updated09:41
yvlbecause contact is not a intervention message09:42
yvlsorry09:42
yvlby contact I meant student09:42
aelknerso you are referring to a problem where the student's name changes09:42
yvlyes09:42
aelknerand the intervention catalog would not change09:43
yvlyes09:43
aelknerwow, didn't realize we had that hanging over us09:43
yvlit's not that bad, because the situation is unlikely09:44
yvlbut I wanted you to know that09:44
yvlif you cache the object itself, it's one thing09:44
aelknerso that's always been the case with all of our indeces that rely on attibutes from other objects09:44
yvlyep09:44
yvlscary, ain't it? ;)09:45
aelkneryeah09:45
yvlmore importantly, persons_responsible also relies on relationships09:46
yvlthat are stored somewhere09:46
aelkneryeah, so if a contact is removed from the system09:47
aelknerit will automatically disappear from all intervention objects that refer to it09:47
aelknerbut not from the indeces?09:47
yvlyes09:47
aelknerunless i write the adaptersubscriber for (IntIdRemovedEvent, IContact)09:48
yvlwell, you actually cache objects by relationship there09:48
yvlso *that*  should be hooked with RelationshipAdded and RelationshipRemoved subscribers09:49
yvlthose are somewhat crappy at the moment09:49
yvlsee app/relationship.py09:50
yvland configuration09:50
yvl  <subscriber09:50
yvl      for="schooltool.relationship.interfaces.IRelationshipAddedEvent"09:50
yvl      handler=".relationships.updateStudentCalendars"09:50
yvl      />09:50
aelknerlots of providedBy calls :)09:51
yvlyes09:51
yvlwell, for you it won't matter09:51
yvlbecause you need to ping catalog for both adding and removing relationships09:51
aelknerping catalog?09:52
yvlI'll get to that09:52
aelknerwhat do mean  by that?09:52
yvlyou'll need to check if event.rel_type != URIPersonsResponsibleOrSomething09:52
yvlthen get object = event[URIMessage]09:52
yvlor similar, I don't recall exact URIs09:53
yvlthen,09:53
yvlobj_intid = getIntId(object)09:53
yvlcatalog = InterventionCatalog.get.()09:54
yvlcatalog.index_doc(obj_intid, object)09:54
yvlthis will make catalog to index the message again09:54
yvlthus re-reading the persons_responsible09:54
aelknerreadapting to IPersonsResponsible you mean09:55
yvlyes09:55
aelknerso i use the subscriber to IRelationshipAddedEvent09:56
aelknerto so the code you just laid out there09:56
aelknerto do the code, i mean09:56
yvlyes09:57
aelkneradn i need one for IRelationshipRemovedEvent09:57
aelknerthat does the same09:57
yvlyes09:58
yvlyou can use the same method for both subscribers09:58
yvlone more thing09:58
aelknerif they are classes, i can ave a base class for both09:59
yvlyou need to check if obj_intid is in catalog09:59
yvlno, they're simple functions09:59
yvlthat is sufficient09:59
aelknerok09:59
yvloh, you meant event09:59
yvls09:59
yvlthey have a base class, but you should not use it09:59
aelknerbut they can call the same method that does the lookup09:59
yvlbecause IRelationshipEvent is also used for IBeforeRelationshipAdded09:59
yvlyes10:00
yvlthe check if int_id is in catalog is important10:00
yvlsay, you delete a message10:00
yvlrelationships get removed of course10:00
yvland message is unindexed from catalogs10:00
yvlin random order10:01
yvlso you can accidentally index it again, if you're not careful10:01
yvloh, and you the check is:10:02
yvlif obj_intid in catalog.extent:10:02
yvl     catalog.index_doc(obj_intid, object)10:02
aelknerso only reindex if it's in the index10:02
yvlyes10:02
yvlall of this should come from core, but you know how it is10:03
yvlI didn't implement that yet :D10:03
aelknerwell, you only have a thousand different projects on your plate10:04
yvl:D10:04
aelknerspeaking of which10:04
aelkneri'm going to leave it at that for tonight, allowing you to get to your own stuff10:05
aelkneri'll look it over carfully tomorrow and try stuff out10:05
yvlsure10:05
aelknerwill i be able to find you reliably at 2am all week?10:05
aelknerthat would help me to know that i can10:05
yvlat 3am - definitely10:05
yvlI usually come to work 2am-4am your time10:06
yvlmost likely 2am-3am10:06
aelknerok, i'll be keeping a late sleep schedule to allow for that10:06
yvlor we can switch to early mornings10:06
aelkneryou can see that although email s nice10:06
aelknerthis ype of back and forth gets a lot more done10:07
yvltrue :)10:07
yvlwell then10:07
yvlgood night to you, sir :)10:07
aelknerif i can't hold out till 3am for some reason, i can always try to wake up early and catch you that way10:07
aelknerand good day to you :)10:08
yvljust email me that you want to chat10:08
aelknerwill do, if i need to catch you early morning after i sleep, i'll email you the night before10:09
aelkneranyway, thanks for the edumication :)10:09
aelknerit was an experience10:10
yvlyou're welcome :)10:16
*** alga has joined #schooltool11:39
*** menesis has joined #schooltool12:19
*** aks has quit IRC13:21
*** povbot has joined #schooltool14:04
*** alga has joined #schooltool14:08
*** ignas has joined #schooltool14:37
*** menesis has quit IRC14:44
*** th1a has joined #schooltool15:06
*** menesis has joined #schooltool15:48
*** yvl has quit IRC16:47
*** yvl has joined #schooltool16:53
*** alga has quit IRC16:57
th1ayvl: ayt?17:02
*** menesis has quit IRC19:34
*** ignas has quit IRC20:14
*** menesis has joined #schooltool20:34
*** alga has joined #schooltool22:59

Generated by irclog2html.py 2.15.1 by Marius Gedminas - find it at mg.pov.lt!