Skip to content.
Sections

Quantum Magic & Love Quarks

Personal tools
You are here: Home » Notes
 
Views

plone Debugger template

Document Actions
last edited 3 years ago by pf
Using the try:except structure....    

def getRaw(self, instance, **kwargs):
      try:
        if self.accessor is not None:
            accessor = self.getAccessor(instance)
        else:
            # self.accessor is None for fields wrapped by an I18NMixIn
            accessor = None
        kwargs.update({'field': self,
                       'encoding':kwargs.get('encoding', None),
                     })
        if accessor is None:
            args = [instance,]
            return mapply(self.get, *args, **kwargs)
        return mapply(accessor, **kwargs)
      except:
        import pdb, sys
        e, m, tb = sys.exc_info()
        pdb.post_mortem(tb)

Using the pdb breakpoint:

    def getRaw(self, instance, **kwargs):
        import pdb; pdb.set_trace()

Also, this chat transcript from #plone


[8:44pm] RaFromBRC: peterf: http://paste.plone.org/142
[8:45pm] RaFromBRC: try putting that in Field.py as your getRaw() method, then kill zope and start up 'zopectl fg' again
[8:45pm] RaFromBRC: you may have to kill zope by hand (kill -9 `cat $INSTANCE_HOME/var/Z2.pid`)
[8:46pm] peterf: so we redefine getRaw with some debug dumps...
[8:46pm] RaFromBRC: yes... what we did first was set a breakpoint
[8:46pm] RaFromBRC: this time we're doing a "post_mortem"... i.e. it will pop us into the debugger after the error happens, so we can examine the state
[8:47pm] lcaamano: well, gotta go ... thanks ateoh211, peterf ... I'll go dig some more ... good luck on your debugging
[8:48pm] peterf: OK cool I'll comment the existing method and then paste this...
[8:48pm] jpfarias left the chat room. ("Fui embora")
[8:48pm] RaFromBRC: peterf: you don't have to comment it really... just wrap the try: except: around it
[8:48pm] RaFromBRC: most of that call is the same
[8:48pm] RaFromBRC: there's just a try: at the beginning and an except: clause at the end
[8:49pm] peterf: Ah, yes, I see...
[8:50pm] peterf: good enuf.. peterf restarts his Zope...
[8:50pm] RaFromBRC: then reproduce the error... this time when the debugger pops up, the error will have already happened
[8:50pm] RaFromBRC: peterf:  let me know when the debugger pops up
[8:50pm] peterf: oops. /* is not comment in python ;-)
[8:53pm] peterf: debugger has popped up!  > /var/lib/plone2.1/zope/Products/Archetypes/utils.py(120)mapply()
[8:53pm] peterf: -> code = m.func_code
[8:53pm] RaFromBRC: okay, type 'u' to go up the stack frame one call
[8:53pm] RaFromBRC: (back up to the getRaw method)
[8:53pm] peterf: yep, ok
[8:53pm] RaFromBRC: then type 'p self.accessor'
[8:54pm] peterf: contact_email
[8:54pm] peterf: aha.
[8:54pm] RaFromBRC: is contact_email a method on your object?
[8:54pm] peterf: hmmm. should be a field name
[8:55pm] RaFromBRC: type 'p self'
[8:55pm] peterf: <Field contactEmail(string:rw)>
[8:55pm] peterf: but my schema:    StringField('contact_email',
[8:56pm] peterf: must be a disconnect here. I changed these names...
[8:56pm] stevee left the chat room. ("Snak 5.0.2 IRC For Mac - http://www.snak.com")
[8:56pm] peterf: so the old schema is still around somehow?
[8:56pm] RaFromBRC: oh, contactEmail is an old name?
[8:56pm] peterf: yes
[8:56pm] RaFromBRC: yes, schema objects live on the instances themselves
[8:56pm] RaFromBRC: sometimes they need to be updated
[8:56pm] peterf: AH!
[8:57pm] RaFromBRC: there's a 'update schema' tab in the ZMI of the archetypes tool
[8:57pm] peterf: yeah. I thought I did this once...
[8:57pm] peterf: maybe again?
[8:57pm] RaFromBRC: can't hurt
[8:57pm] peterf: maybe "all objects?
[8:57pm] RaFromBRC: sure
[8:58pm] RaFromBRC: make sure your custom type is selected
[8:58pm] peterf: yes
[8:58pm] RaFromBRC: you're not using ATSchemaEditorNG are you?
[8:58pm] peterf: not here
[8:58pm] RaFromBRC: good
[8:59pm] peterf: odd there were a couple other types already selected...
[8:59pm] RaFromBRC: that's fine... AT thinks they might be out of sync
[9:00pm] peterf: ah... CroppMember is one of them...
[9:00pm] fabiorizzo joined the chat room.
[9:00pm] peterf: and AT.Fact
[9:00pm] arcannon left the chat room. ("Bye bye...")
[9:01pm] tessier joined the chat room.
[9:01pm] peterf: peterf is still waiting for AT tool to come back...
[9:01pm] peterf: goes to refill his sa-ke...
[9:01pm] RaFromBRC: :)
[9:01pm] edgordon left the chat room.
[9:03pm] peterf: still waiting...
[9:03pm] peterf: more sa-ke... ;-)
[9:03pm] RaFromBRC: you might want to make sure you're not caught up by your debug session
[9:03pm] peterf: hmm
[9:04pm] peterf: so exit the pdb
[9:04pm] RaFromBRC: type
[9:04pm] RaFromBRC: type "q"
[9:04pm] RaFromBRC: probably should have stopped and restarted zope, actually, commenting out the pdb stuff before restarting
[9:04pm] RaFromBRC: but it could also be just taking a while, too... it definitely is slow when there are a lot of objects to update
[9:05pm] peterf: q it is... hmm
[9:05pm] peterf: can't pickle function objects
[9:05pm] peterf: I'll restart
[9:05pm] RaFromBRC: that's the error that the at tool gave you?
[9:05pm] peterf: yeah
[9:06pm] RaFromBRC: remove the pdb stuff, then restart, then give it another go
[9:06pm] peterf: aok
[9:06pm] natea: lcaamano, if you want to store lots of MP3s on the file system, check out ATAudio at http://plone.org/products/ataudio
[9:06pm] RaFromBRC: maybe unselect all types except your custom one before clicking the update button
[9:06pm] peterf: yes, did so...
[9:06pm] peterf: I think it was hanging on the pdb, perhaps.
[9:07pm] peterf: peterf goes to edit the method and restart zope.
[9:07pm] RaFromBRC: peterf: i have to go soon, but you got a little more info from the pdb anyway...
[9:08pm] fabiorizzo left the chat room.
[9:08pm] peterf: yes, very good!! It's making good sense! We'll be in touch!
[9:09pm] peterf: hmm still getting that pickle
[9:09pm] peterf: error
[9:10pm] RaFromBRC: peterf: seems like something is outta whack
[9:10pm] RaFromBRC: gives his expert opinion..
[9:10pm] peterf: ;-)
[9:10pm] peterf: yes, I concur
 

Powered by Plone