## $Id: webservices.py 10033 2013-03-17 14:45:18Z henrik $ ## ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import grok from zope.component import getUtility from zope.catalog.interfaces import ICatalog from waeup.kofa.interfaces import IUniversity #class XMLRPCPermission(grok.Permission): # """Permission for using XMLRPC functions. # """ # grok.name('waeup.xmlrpc') #class XMLRPCUsers2(grok.Role): # """Usergroup 2 # """ # grok.name('waeup.xmlrpcusers2') # grok.title('XMLRPC Users Group 2') # grok.permissions('waeup.xmlrpc',) class StudentsXMLRPC(grok.XMLRPC): """Student related XMLRPC webservices. Please note, that XMLRPC does not support real keyword arguments but positional arguments only. """ grok.context(IUniversity) @grok.require('waeup.xmlrpc') def get_student_id(self, reg_number=None): """Get the id of a student with registration number `reg_number`. Returns the student id as string if successful, ``None`` else. """ if reg_number is not None: cat = getUtility(ICatalog, name='students_catalog') result = list( cat.searchResults(reg_number=(reg_number, reg_number), _limit=1)) if not len(result): return None return result[0].student_id return None