Hello everyone,
I'm developing a mod_python application that is based on XML\XSLT
transforming.
I used 4Suite libraries for that, but as the speed was unacceptable
for me, I switched to lxml. Everything became much easier and 10 times
faster, but I've encountered the subject problem.
In brief - all my data and xslt are stored and transferred in UTF-8.
With 4Suite everything was fine all the time. With lxml it works fine
from the console, but inside mod_python it occasionaly dies, ~ one
time out of three. Strange - the same code with the same data works or
dies by its own means.
As far as I have found, there was a similar problem with PyXML and
encodings module, but there was no clear solution.
So, my configuration is the following:
Python 2.5.1
Server version: Apache/2.2.4 (FreeBSD)
mod_python-3.3.1
And the relevant parts of my code are these:
def extApplyXslt(xs lt, data, logger ):
try:
strXslt = urllib2.urlopen (xslt).read()
# i have to read the xslt url to the python string
except urllib2.HTTPErr or, e:
.......
except urllib2.URLErro r, e:
.............
try:
xslt_parser = etree.XMLParser ()
xslt_parser.res olvers.add( PrefixResolver( "XSLT") )
# and now I have to use the string; a more elegant solution,
anyone?
f = StringIO(strXsl t)
xslt_doc = etree.parse(f, xslt_parser)
# and here where the problem comes
transform = etree.XSLT(xslt _doc)
except Exception, exc:
logger.log(logg ing.CRITICAL, exc.__str__() )
try:
result_tree = transform(data)
return etree.tostring( result_tree, 'utf-8')
except Exception, exc:
print "xslt processing error!", exc.__str__()
return ""
It dies with the message 'cannot unmarshal code objects in restricted
execution mode'. By profiling I detected the point where problem
occurs:
transform = etree.XSLT(xslt _doc)
So, I would be grateful for any suggestions how to get rid of this.
I'd really like to use lxml. Maybe I should initialize the xslt
processor in somehow other way?
Thanks in advance,
Dmitri 3 2540
Dmitri Fedoruk wrote:
def extApplyXslt(xs lt, data, logger ):
try:
strXslt = urllib2.urlopen (xslt).read()
# i have to read the xslt url to the python string
except urllib2.HTTPErr or, e:
.......
except urllib2.URLErro r, e:
.............
try:
xslt_parser = etree.XMLParser ()
xslt_parser.res olvers.add( PrefixResolver( "XSLT") )
# and now I have to use the string; a more elegant solution,
anyone?
Sure, lxml.etree can parse from file-like objects. Just hand in the result of
urlopen().
Apart from that, I saw that you found your way to the lxml mailing list, I'll
respond over there.
Stefan
On Sep 13, 5:05 pm, Dmitri Fedoruk <dfedo...@gmail .comwrote:
So, my configuration is the following:
Python 2.5.1
Server version: Apache/2.2.4 (FreeBSD)
mod_python-3.3.1
update:
lxml-1.3.4
libxslt-1.1.21
libxml2-2.6.29
On Sep 14, 3:04 am, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
wrote:
Try forcing mod_python to run your code in the first interpreter
instance created by Python.
PythonInterpret er main_interprete r
Thank you very much, that solved the problem! A more detailed
discussion can also be found in the lxml-dev mailing list ( http://comments.gmane.org/gmane.comp...xml.devel/2942 )
Dmitri This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Connell |
last post by:
I'm porting a mod_python / XML app that has been running in Apache 1.3
and I am running into trouble with Apache 2.0. Specifically, I'm
getting a restricted execution mode error when I import the ExpatPy
piece. Any body know what, why or how to fix?
Thanks!
|
by: wolf |
last post by:
i would like to briefly share my experiences with
installing mod_python on a w2000 box. i must say that i
believe the installation process to be unnecessarily
complicated by the simple fact that the installer itself
seems to be buggy -- in my case, no combination of
mod_python 3.0.4, 3.1.2b and python 2.2.3, 2.3.3 ever
came to completion. rather, the installer would exit --
after an initial declaration of having successfully
found python...
|
by: Denis S. Otkidach |
last post by:
When I execute python code from C++ application with
PyEval_EvalCode and this code contains imports of other modules
then I got the error "RuntimeError: cannot unmarshal code objects
in restricted execution mode". How can I switch into
noraml (unrestricted) mode?
Python 2.2.2, Linux. Actual code looks like the following:
tstate = Py_NewInterpreter();
main_module = PyImport_AddModule("__main__");
|
by: Arso - Italy |
last post by:
Hi
someone have already used eric3 for debugging code running on apache
using mod_python ?
After the execution of the patch for apache.py, how the debug is activated ?
More thanks for any response.
--
|
by: Rune Hansen |
last post by:
I've posted this question on the mod_python mailing list but didn't get
much response, so I thought I'd post it here.
(My first attempt connected to an unrelated thread..sorry.
Note-to-self:-must-get-more-coffee-before-posting-)
It seems to me that for each path element in a URI a mod_python handler
will be invoked. This applies to PythonAuthenHandler,
PythonHeaderParserHandler and so on.
| |
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Srijit Kumar Bhadra |
last post by:
I am new to lxml. I am interested to know the equivalent code using
lxml (http://cheeseshop.python.org/pypi/lxml/1.1alpha). The code is
taken from http://effbot.org/zone/xml-writer.htm
from elementtree.SimpleXMLWriter import XMLWriter
import sys
w = XMLWriter(sys.stdout)
html = w.start("html")
|
by: Michael |
last post by:
Hey everyone,
Is it possible to automatically insert headers/footers using
mod_python?
I will be not be using PSP's, so I cannot use the PSP/include solution.
Furthermore, the header will be dynamic; it won't be a static HTML
page.
In short, I've been looking for a page layout facility using
mod_python.
|
by: yinglcs |
last post by:
Hi,
I am trying to setup Apache with Trac which uses mod_python. I get the
following error:
assert have_pysqlite 0
And I have verify this via command line as well, that seem no
problem.
# python
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |