Wednesday, May 28, 2014

Re: ASP .NET web service and Django

Thanks everyone. I will try using suds but if suds use C libs, like soaplib does (lxml ), than this wont work too.

@Vernon

I don't know for IronPython3. I didn't managed to set up Django 1.5, there was errors in Django six.py lib ("""Utilities for writing code that runs on Python 2 and 3""") exec_ function. There was problems with  -X:Frames and namespaces so I gave up on this.

I use this 'hacks':

IronPython 2.7.3
Django 1.4
IIS 7.5
.NET Framewok 4.0
NWSGI [http://nwsgi.codeplex.com]

I
* AttributeError: 'module' object has no attribute '_getframe'
Use startproject  and startproject with -X:Frames

II
*
STATIC_URL = 'static/' # not  '/static/'

III
To use nice Django URL, use wildcard mapping

<wsgi>            
    <pythonPaths>                                                                          
        <path path="C:\Program Files (x86)\IronPython 2.7\Lib" />      
        <path path="C:\Program Files (x86)\IronPython 2.7\Lib\site-packages" /> 
    </pythonPaths>                                                    
    <wildcard physicalPath="C:\inetpub\wwwroot\HelloWorld\helloworld\wsgi.py" />
</wsgi> 

While using wildcard mappings you will have some limitations in urls.py with regular expressions.
If you use named groups in mapping whole expression is got to be in the named group.
 And every expression is got to start with ^ and end with $.
e.g.
url(r'^(?P<notify>notify).*$', 'helloworld.views.reset_cache'), - this wan't work
url(r'^(?P<notify>notify)(?P<eventXml>.*)$', 'helloworld.views.reset_cache'), - this will work

IV
If you get something like this error wen loading images:
"Unable to translate bytes [FF] at index 0 from specified code page to Unicode."

then in Django static.py change
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\views\static.py
63 "response = HttpResponse(f.read(), mimetype=mimetype)" with
63 "response = HttpResponse(bytes(f.read()), mimetype=mimetype)"

V
If you use non-ascii caracters.
* 'Unicode Decode Error:' then change:
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\http\__init__.py
717     def next(self):
            chunk = self._iterator.next()
            if isinstance(chunk, unicode):
                chunk = chunk.encode(self._charset)
            return str(chunk)
to:         
        def next(self):
            chunk = self._iterator.next()
            if isinstance(chunk, unicode):
                chunk = chunk.encode('utf8').encode('utf8')
            return str(chunk, 'utf8')
           
VI
To use filebased cache, remove pickle.HIGEST_PROTOCOL in
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\django\core\cache\backends\filebased.py
try:         
    now = time.time()      
    pickle.dump(now + timeout, f, pickle.HIGHEST_PROTOCOL)
    pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
finally:

try:         
    now = time.time()      
    pickle.dump(now + timeout, f)
    pickle.dump(value, f)
finally:

VII
I do not use database. In order to create sqlite3 db use python

VIII
django/utils/functional.py

django 1.4:

#assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."   
assert (str is unicode) or not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types."   
# This solve:    
#     AssertionError: Cannot call lazy() with both str and unicode return types.   
# https://bitbucket.org/jdhardy/django-ironpython/commits/b70eeacda60c




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20ae092c-6b2b-4bb7-b93d-f921f0a6cf35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment