126 lines
2.8 KiB
Python
126 lines
2.8 KiB
Python
# -*- 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)
|
|
|
|
|
|
"""
|
|
import pdb
|
|
import pprint
|
|
|
|
import notesdb as ndb
|
|
from notesdb import * # pylint: disable=unused-wildcard-import
|
|
from notes_log import log
|
|
import sco_utils as scu
|
|
from sco_utils import * # pylint: disable=unused-wildcard-import
|
|
|
|
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
|
|
|
|
def has_role(self, role):
|
|
return True
|
|
|
|
|
|
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.URL1 = self.URL
|
|
self.URL0 = self.URL
|
|
self.BASE0 = "localhost"
|
|
self.REMOTE_HOST = "localhost"
|
|
self.REMOTE_ADDR = "127.0.0.1"
|
|
self.HTTP_REFERER = ""
|
|
self.REQUEST_METHOD = "get"
|
|
self.QUERY_STRING = ""
|
|
|
|
|
|
REQUEST = DummyRequest()
|
|
|
|
# handful shorcut
|
|
pp = pprint.pprint
|