Example #1
0
 def reply_letter(self, data):
     account = self.manager.get(data['az'])
     user = self.manager.get(data['az'])
     if user is not None:
         info = data.by_schema[IMessage]
         message = Message()
         grok.notify(grok.ObjectCreatedEvent(message))
         from dolmen.forms.base import set_fields_data
         if 'attachment' in info.keys():
             from StringIO import StringIO
             f = StringIO(decodestring(info['attachment']))
             # f.filename="download"
             f.filename = info['filename']
             info['attachment'] = f
         set_fields_data(IMessage, message, info)
         directlyProvides(message, IAnswer)
         user['nachrichten'][info['doc_id']].add(message)
         print "I ADDED A MESSAGE"
         # with transaction.manager as t:
         #     print t
         grok.notify(AfterSaveEvent(message, self.request))
         #import pdb; pdb.set_trace()
         #IWorkflowInfo(message).fireTransition('finish')
         self.request.response.setStatus(202)
         return
     raise KeyError('Unknown user.')
Example #2
0
 def __call__(self, form):
     if form.current.actions['save'](form.current) is SUCCESS:
         if super(MySaveAction, self).__call__(form) is SUCCESS:
             grok.notify(AfterSaveEvent(form.context, form.request))
             form.redirect(form.url(self.redirect_url))
         return SUCCESS
     return FAILURE
Example #3
0
 def handleAdd(self):
     data, errors = self.extractData()
     if errors:
         self.flash('Es sind Fehler aufgetreten')
         return
     obj = self.createAndAdd(data)
     if obj is not None:
         # mark only as finished if we get the new object
         self._finishedAdd = True
         grok.notify(AfterSaveEvent(obj, self.request))
Example #4
0
def worker():
    print '################################################################'
    print 'Start...'
    print '################################################################'
    uvcsite = root['app']
    component.hooks.setSite(uvcsite)
    hfm = component.getUtility(IHomeFolderManager).homeFolderBase
    for homefolder in hfm.values():
        #for item in homefolder:
        #    print item
        if 'Sunfallanzeigen' in homefolder:
            for item in homefolder['Sunfallanzeigen'].values():
                #pid = str(item.principal.id)
                #print pid
                #print IWorkflowState(item).getState()
                if IWorkflowState(item).getState() == 2:
                    print '################################################################'
                    print 'Fehlerhafte Unfallanzeige gefunden:'
                    print "%s/%s" % (homefolder.__name__, item.title)
                    print '################################################################'
                    print 'Bitte Dokument anschauen und Fehler beheben !'
                    print 'Dann Code der Nachverarbeitung aendern:'
                    print '1. Dokument neu erstellen und versenden, NICHT fixen !!!'
                    print '2. Dokument fixen, OHNE Erstellung !!!'
                    print '################################################################'
                    ##### Status: 0 = Nur schauen, was laeuft falsch
                    #####         1 = Dokument neu erstellen
                    #####         2 = Dokument fixen (Status gesendet)
                    ##### Nachfolgenden Status setzen:
                    status = 0  # <----- Dort: 0, 1 oder 2
                    if status == 0:
                        print "-----> Es wurde noch keine Aktion ausgeführt"
                        print "Status: ", status
                    elif status == 1:
                        modprincipal = item.principal
                        alsoProvides(modprincipal, MoE)
                        event_obj = geteventobject(modprincipal)
                        try:
                            grok.notify(AfterSaveEvent(item, event_obj))
                        except InvalidTransitionError:
                            print "-----> Dokumente wurden erstellt, Status umstellen zum fixen !!!"
                            print "Status: ", status
                        except Exception, e:
                            print e
                            pass
                    elif status == 2:
                        IWorkflowInfo(item).fireTransition('fix')
                        print "-----> Dokumente gefixt !!!"
                        print "       Status umstellen auf --> 0 <--"
                        print "Status: ", status
                        print 'FIX of object %s' % item
Example #5
0
 def PUT(self):
     errors = []
     content = self.context.getContentType()()
     interface = content.schema[0]
     serializer = IJSONSerializer(content)
     serializer.work(self.body, interface, errors)
     if not errors:
         self.context.add(content)
         result = dict(result='success',
                       name=content.meta_type,
                       id=content.__name__)
         grok.notify(AfterSaveEvent(content, self.request))
     else:
         result = errors
     return json.dumps(result)
Example #6
0
    def PUT(self):
        errors = []
        content = self.context.getContentType()()
        grok.notify(grok.ObjectCreatedEvent(content))
        interface = content.schema[0]
        serializer = ISerializer(content)
        serializer.work(self.body, interface, errors)

        if not errors:
            self.context.add(content)
            result = etree.Element('success',
                                   name=content.meta_type,
                                   id=content.__name__)
            grok.notify(AfterSaveEvent(content, self.request))
        else:
            result = etree.Element('failure')
            result.extend(errors)
        return etree.tostring(result, encoding='UTF-8', pretty_print=True)
Example #7
0
 def submit_letter(self, data):
     account = self.manager.get(data['az'])
     user = self.manager.get(data['az'])
     if user is not None:
         info = data.by_schema[IMessage]
         message = Message()
         grok.notify(grok.ObjectCreatedEvent(message))
         from dolmen.forms.base import set_fields_data
         if 'attachment' in info.keys():
             from StringIO import StringIO
             f = StringIO(decodestring(info['attachment']))
             # f.filename="download"
             f.filename = info['filename']
             info['attachment'] = f
         set_fields_data(IMessage, message, info)
         directlyProvides(message, IQuestion)
         user['nachrichten'].add(message)
         grok.notify(AfterSaveEvent(message, self.request))
         self.request.response.setStatus(202)
         return
     raise KeyError('Unknown user.')