lib

pythonsecurity.h

00001 /***************************************************************************
00002  * pythonsecurity.h
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 #ifndef KROSS_PYTHON_SECURITY_H
00021 #define KROSS_PYTHON_SECURITY_H
00022 
00023 #include "pythonconfig.h"
00024 
00025 #include <qstring.h>
00026 
00027 namespace Kross { namespace Python {
00028 
00029     // Forward declaration.
00030     class PythonInterpreter;
00031 
00056     class PythonSecurity : public Py::ExtensionModule<PythonSecurity>
00057     {
00058         public:
00059 
00066             explicit PythonSecurity(PythonInterpreter* interpreter);
00067 
00071             virtual ~PythonSecurity();
00072 
00085             PyObject* compile_restricted(const QString& source, const QString& filename, const QString& mode);
00086 
00087 #if 0
00088             //TODO
00089             void compile_restricted_function(const Py::Tuple& args, const QString& body, const QString& name, const QString& filename, const Py::Object& globalize = Py::None());
00090             void compile_restricted_exec(const QString& source, const QString& filename = "<string>");
00091             void compile_restricted_eval(const QString& source, const QString& filename = "<string>");
00092 #endif
00093 
00094         private:
00096             PythonInterpreter* m_interpreter;
00098             Py::Module* m_pymodule;
00099 
00101             inline void initRestrictedPython();
00102 
00104             Py::Object _getattr_(const Py::Tuple&);
00105     };
00106 
00107 }}
00108 
00109 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys