Find the answer to your Linux question:
Results 1 to 2 of 2
I need help running spyce server pages on Ubuntu 10.10 I installed Spyce using mod_python on Centos just fine, but on Ubuntu, it is giving me an "invalid syntax" error ...
  1. #1
    Just Joined!
    Join Date
    Jul 2011
    Location
    Houston, Texas, USA
    Posts
    9

    Trouble running Spyce on Ubuntu 10.10

    I need help running spyce server pages on Ubuntu 10.10

    I installed Spyce using mod_python on Centos just fine, but on Ubuntu, it is giving me an "invalid syntax" error on a pythong script.

    I have the following packages (relevant to this post) installed:
    • python 2.6.6
    • apache2
    • libapache2-mod-python


    In the file /etc/apache2/sites-available/default, I have the following configuration embedded:

    Code:
            <Directory /var/www>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
           <IfModule mod_python.c>
                    AddHandler python-program .spy
                    PythonHandler run_spyceModpy::spyceMain
                    PythonPath "sys.path+[r'/usr/share/spyce']"
                    PythonDebug On
               </IfModule>
            </Directory>
    When I try to run a test file, I get the following error thanks to PythonDebug being turne On:

    MOD_PYTHON ERROR

    ProcessId: 2374
    Interpreter: 'localhost.localdomain'

    ServerName: 'localhost.localdomain'
    DocumentRoot: '/var/www'

    URI: '/spyce/docs/examples/hello.spy'
    Location: None
    Directory: '/var/www/'
    Filename: '/var/www/spyce/docs/examples/hello.spy'
    PathInfo: ''

    Phase: 'PythonHandler'
    Handler: 'run_spyceModpy::spyceMain'

    Traceback (most recent call last):

    File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

    File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

    File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

    File "/usr/share/spyce/run_spyceModpy.py", line 19, in spyceMain
    return spyceMainVersion(apacheRequest)

    File "/usr/share/spyce/run_spyceModpy.py", line 36, in spyceMainVersion
    import spyceModpy

    File "/usr/share/spyce/spyceModpy.py", line 10, in <module>
    import spyce, spyceException, spyceUtil

    File "/usr/share/spyce/spyce.py", line 418

    def _startModule(self, name, file=None, as=None, force=0):

    ^

    SyntaxError: invalid syntax

    in the file spyce.py, I am gettig a syntax error with one of the parameters of the _startModule function, 'as=None'. I don't understand why this is happening. On centos, it runs fine with no problems. I first thought that maybe I had an older version of Python on Ubuntu, but the Centos server is also running Python 2.6.6 as well.

    Any help is greatly appreciated!

    -hrfister

  2. #2
    Just Joined!
    Join Date
    Jul 2011
    Location
    Houston, Texas, USA
    Posts
    9
    I found a 'WORK AROUND'!

    It appeared like no one had a clue as to what was going on and I felt a little glad I wasn't alone. After a little bit of googling, a couple of guys stated that 'as' is a keyword in certain versions of python. It appeared as to the pythong that mod_python used did not like the token 'as' used as either a variable or a parameter on a function. A couple of guys advised to rename 'as' to '_as' in all the files in the directory where spyce was installed. I didn't want to do this at first thinking it was going to be a 'SLOPPY' solution, but after hours and days of trying to figure this out, and for time purposes, I went ahead and modified the files that had toke 'as=' in them.

    It appears to me like not to many people use Spyce Server Pages and there very few documentation out on the web. So I did what I had to do and if anyone runs into this same problem, below is what worked for me.

    I went ahead and searched for all files in my spyce install directory that was using the token 'as=' such as as=xyz in a parameter in functions. I backed up each and everyone with the following multiple commands:

    #cp docs/examples/formtag.spy docs/examples/formtag.spy_bak ; cp docs/examples/tag.spy docs/examples/tag.spy_bak ; cp docs/doc.spy docs/doc.spy_bak ; cp modules/taglib.py modules/taglib.py_bak ; cp spyceCompile.py spyceCompile.py_bak ; cp spyce.py spyce.py_bak


    I then edited the following files...

    spyceCompile.py
    docs/examples/formtag.spy
    docs/examples/tag.spy
    docs/doc.spy
    modules/taglib.py
    spyce.py



    ...by searching and replacing all instances of ' a=' to ' _a='. It wasn't as easy since this changed strings with substrings of "as=". An example of this was the following string 'libas=libname' changed to 'lib _as=libname' and then in spyce.py, the variable 'as' was being used multiple times as follows:


    Code:
    sys.stderr.write(as+'.start\n')
    :
    self._modstarted.append((as, mod))
    :
    else: mod = self._codeenv[as]
    :
    for as, mod in self._modstarted:
    :
    sys.stderr.write(as+'.finish\n')
    :
    for as, mod in self._modstarteddefault:
    :
    sys.stderr.write(as+'.finish\n')

    after a manual search and replace using CTRL-S for this using emacs, I replaced them:

    Code:
    sys.stderr.write(_as+'.start\n')
    :
    self._modstarted.append((_as, mod))
    :
    else: mod = self._codeenv[_as]
    :
    for _as, mod in self._modstarted:
    :
    sys.stderr.write(_as+'.finish\n')
    :
    for _as, mod in self._modstarteddefault:
    :
    sys.stderr.write(_as+'.finish\n')
    I reset apache2
    #/etc/init.d/apache2 restart

    AND IT FINALLY WORKED!

    I hope this helps out anyone who may have struggled with this like I did. Also, if anyone can suggest a "cleaner" solution, by all means, please let me know.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •