DjangoAMF seems a viable solution for bridging django with flash/flex
applications.

I gave it a shot, reached all the way to authentication but then
halted.

Here is a sample view:

from amf.django import permission_required

in settings.py i have

AMF_AUTH_FUNC = 'amfapp.views.login'

@permission_required('user')
def getCredentials(request, version):
    return request

def login(request, username, password):
        return 'user'

and the actionscript file:

import mx.remoting.debug.NetDebug;

import cinqetdemi.remoting.*; // i am using this remoting helpers from
cinqetdemi
import mx.rpc.*;

import mx.utils.Delegate;

class ro.gion.Console extends MovieClip
{
        var gatewayUrl:String = "http://localhost:8000/gateway/";;
        var serviceName:String = "ConsoleService";
        var service:RemotingService;
        var user:String = "user";
        var pass:String = "pass";
        var app_version:String = "1.0";

        function onLoad()
        {
                this.init();
        }

        function init()
        {
                NetDebug.initialize();
                service = new RemotingService(gatewayUrl, "ConsoleService");

                service.addEventListener('timeout', Delegate.create(this,
onTimeOut));
                service.addEventListener('result', Delegate.create(this, 
onResult));
                service.addEventListener('fault', Delegate.create(this, 
onFault));
                service.addEventListener('busy', Delegate.create(this, onBusy));
                service.addEventListener('clear', Delegate.create(this, 
onClear));
                service.setCredentials(user, pass);
                service.getCredentials([app_version], this, onGetCredentials,
onGetCredentialsFault);
        }

        function onGetCredentials(re)
        {
        }

        function onGetCredentialsFault(fe)
        {
        }

        function onTimeOut()
        {
        }

        function onResult()
        {
        }

        function onFault()
        {
        }

        function onBusy()
        {
        }

        function onClear()
        {
        }
}

Now i dont know how to hook built in django authentication to this
If you request object to be passed back to flash (no one would want
this, but it is a good complex object test) you will not be able to
make it, it hangs, i used this to patch djangoamf (i dont know either
python or django)

in djangoamf-0.5.5/amf/utils.py

you change get_as_type to this:

def get_as_type(obj):
    """Find the name of ActionScript class mapped to the class of
given python object.
       If the mapping for the given object class is not found, return
the class name of the object."""
    if hasattr(obj, '__module__'): # <- this is my addition to
utils.py
        type = obj.__module__ + '.' + obj.__class__.__name__
        if class_mappings:
            for as_class, py_class in class_mappings.iteritems():
                if type == py_class:
                    return as_class
        return type
    return None

and then again in djangoamf-0.5.5/amf/amf0.py

def write_custom_class(d, output):
    #amf.logger.debug("amf0.write_custom_class(%s)", repr(d))
    write_byte(TYPED_OBJECT, output)
    type = amf.utils.get_as_type(d)
    write_utf(type, output)
    items = None # <- here is first change in amf0.py
    if 'iteritems' in dir(d): # d is a dict
        items = d.iteritems()
    else:
        if hasattr(d, '__dict__'): # <- here is another change amf0.py
                items = d.__dict__.iteritems()
    if items != None:
        for key, value in items:
                write_utf(key, output)
                write_data(value, output)
    write_int(0, output)
    write_byte(END_OF_OBJECT, output)

now you will be able to return request object with no issues (i hope)

Now what i dont grasp is how to use this authentication scheme with
builtin django authentication even if DjangoAMF developer mentions it
is supported.

I would love to see these posts having some follow ups.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to