1
0
forked from ScoDoc/ScoDoc
ScoDoc-Front/debug.py

125 lines
2.7 KiB
Python
Raw Normal View History

2020-09-26 16:19:37 +02:00
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Configuration pour debugguer en mode console
Lancer ScoDoc ainsi: (comme root)
/opt/scodoc/bin/zopectl debug
Puis
from debug import *
context = go(app)
# ou
context = go_dept(app, 'CJ')
authuser = app.acl_users.getUserById('admin')
# ou app.ScoDoc.acl_users.getUserById('toto') pour un utilisateur scodoc
authuser = authuser.__of__(app.acl_users)
Exemple:
sems = context.Notes.formsemestre_list()
formsemestre_id = sems[0]['formsemestre_id']
# Affiche tous les semestres:
for sem in sems:
print sem['formsemestre_id'], sem['titre_num']
# Recupere la table de notes:
nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_id)
"""
2020-12-26 00:11:55 +01:00
import pdb
2021-02-03 22:00:41 +01:00
import pprint
2020-12-26 00:11:55 +01:00
2021-02-03 22:00:41 +01:00
import notesdb as ndb
from notesdb import * # pylint: disable=unused-wildcard-import
2020-09-26 16:19:37 +02:00
from notes_log import log
2021-02-03 22:00:41 +01:00
import sco_utils as scu
from sco_utils import * # pylint: disable=unused-wildcard-import
2020-09-26 16:19:37 +02:00
from gen_tables import GenTable
import sco_archives
import sco_groups
import sco_evaluations
import sco_formsemestre
import sco_formsemestre_edit
import sco_compute_moy
import sco_parcours_dut
import sco_codes_parcours
import sco_bulletins
import sco_excel
import sco_formsemestre_status
import sco_bulletins_xml
# Prend le premier departement comme context
def go(app, n=0):
context = app.ScoDoc.objectValues("Folder")[n].Scolarite
print("context in dept ", context.DeptId())
return context
def go_dept(app, dept):
objs = app.ScoDoc.objectValues("Folder")
for o in objs:
context = o.Scolarite
if context.DeptId() == dept:
print("context in dept ", context.DeptId())
return context
raise ValueError("dep %s not found" % dept)
class FakeUser:
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def has_permission(self, op, context):
return True
2020-12-26 00:11:55 +01:00
def has_role(self, role):
return True
2020-09-26 16:19:37 +02:00
class DummyResponse:
"""Emulation vide de Reponse http Zope"""
def __init__(self):
self.header = {}
self.redirected = ""
def setHeader(self, name, value):
self.header[name] = value
def redirect(self, url):
self.redirected = url
class DummyRequest:
"""Emulation vide de Request Zope"""
def __init__(self):
self.RESPONSE = DummyResponse()
self.AUTHENTICATED_USER = FakeUser("admin")
self.form = {}
self.URL = "http://scodoc/"
self.URL0 = self.URL
self.BASE0 = "localhost"
2020-12-26 00:11:55 +01:00
self.REMOTE_HOST = "localhost"
2020-09-26 16:19:37 +02:00
self.REMOTE_ADDR = "127.0.0.1"
self.HTTP_REFERER = ""
self.REQUEST_METHOD = "get"
self.QUERY_STRING = ""
REQUEST = DummyRequest()
# handful shorcut
pp = pprint.pprint