source: WAeUP_SRP/trunk/skins/waeup_student/getStudentId.py @ 1265

Last change on this file since 1265 was 1075, checked in by joachim, 18 years ago

optimized

  • Property svn:keywords set to Id
File size: 695 bytes
RevLine 
[1025]1## Script (Python) "getStudentId"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: getStudentId.py 1075 2006-12-18 10:01:29Z joachim $
11"""
12return StudentId from request
13"""
[1071]14
[1075]15ptls = context.REQUEST.get('PATH_TRANSLATED')
16start = ptls.find('/students/')
17if start < -1:
18    return None
19start += 10
20student_id = ptls[start:start+7]
21try:
22    int(student_id[1:])
23    return student_id
24except:
25    return None
26
[1025]27ptl = context.REQUEST.get('PATH_TRANSLATED').split('/')
[1067]28try:
29    id_index = ptl.index('students')
30except:
31    return None
[1071]32if len(ptl) <= id_index + 1:
33    return None
34student_id = ptl[id_index +1]
35if len(student_id) != 7:
36    return None
Note: See TracBrowser for help on using the repository browser.