
|
n00b help
Just trying to ensure I get it. Python & Django n00b, ActionScript & Flex veteran. I managed to get the HelloWorld working in another project & app. AMF through Django with authentication.... not so much...
It seems if I follow the instructions here:
I just need to have an "amfgateway.py" file in my app folder. This is basically a FrontController, and from it, I can define functions that my Flex client can call. Looking at the example on Joel's blog, however, has me confused. So, bunch of questions:
----------------------------------
How do I wire up my Remoting tag? Assuming I have this in my amfgateway.py services dict:
services = {
'cloud.echo': echo }
And my modified urls.py in the main project has this added:
(r'^gateway/', 'powerz.cloud.amfgateway.echoGateway'),
Then I'd have a RemoteObject tag in Flex like:
<mx:RemoteObject id="remoteObj" destination="powerz.cloud.amfgateway.echoGateway" endpoint="http://localhost:8000">
<mx:method name="echo" result="onResult(event)" fault="onFault(event)"/>
</mx:RemoteObject>
Right?
----------------------------------
What is the difference between this:
And the client example here:
Are both just examples to use during development? What do I actually have to deploy for production? Are errors from authentication something I can recognize on the Flex client vs. a regular scripting error?
Thanks for your time.
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi! On 4 Jul 2009, at 21:47, Jesse Warden wrote: Just trying to ensure I get it. Python & Django n00b, ActionScript & Flex veteran. I managed to get the HelloWorld working in another project & app. AMF through Django with authentication.... not so much...
It seems if I follow the instructions here:
I just need to have an "amfgateway.py" file in my app folder. This is basically a FrontController, and from it, I can define functions that my Flex client can call. Looking at the example on Joel's blog, however, has me confused. So, bunch of questions:
You don't _need_ to have an amfgateway.py file, it's just a convention. What you do need is a way for Django to map the url to the gateway instance (done in urls.py). 'amfgateway' could be called 'views', 'foo', 'bar' - your choice ..
----------------------------------
How do I wire up my Remoting tag? Assuming I have this in my amfgateway.py services dict:
services = { 'cloud.echo': echo }
And my modified urls.py in the main project has this added:
(r'^gateway/', 'powerz.cloud.amfgateway.echoGateway'),
Then I'd have a RemoteObject tag in Flex like:
<mx:RemoteObject id="remoteObj " destination="powerz.cloud.amfgateway.echoGateway" endpoint="http://localhost:8000"> <mx:method name="echo" result="onResult(event)" fault="onFault(event)"/> </mx:RemoteObject>
Not quite. If you set the endpoint to ' http://localhost:8000/gateway/' and destination to 'cloud' then it should all work as expected. Destination is just a convenient way to add a namespace to the method that you are calling. So if you called remoteObj.echo, Flash sends an POST request to endpoint using a concatenation of destination and the method name ('cloud.echo' in this case - notice how this maps to the services dict in amfgateway.py).
'powerz.cloud.amfgateway.echoGateway' is the fully qualified import name in Python. Nowhere does PyAMF/Django expose this name publicly.
----------------------------------
What is the difference between this:
^-- Is this url correct? It is the source code for DjangoGateway used for PyAMF, not an example. And the client example here:
Are both just examples to use during development? What do I actually have to deploy for production? Are errors from authentication something I can recognize on the Flex client vs. a regular scripting error?
Any exceptions that are raised during the execution of the service method ('cloud.echo' in the example above) will be converted to an ErrorMessage/ErrorFault and returned to the Flash client. Any decoding/encoding errors will cause an HTTP status 500.
Note that PyAMF does not support RemoteObject.setCredentials but as the FP supports session cookies I would suggest doing it that way. Hope all that makes (some) sense. Any more questions/queries let me know.
Cheers,
Nick _______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi Jesse,
I use NetConnection not RemoteObject. Generally I create a factory class so that I have a central place using a single connection and my various classes that need it grab an instance of my configured NetConnection (I guess this is a ServiceLocator).
I'd like to fix my example if it is confusing :> On Jul 4, 2009, at 3:47 PM, Jesse Warden wrote: Just trying to ensure I get it. Python & Django n00b, ActionScript & Flex veteran. I managed to get the HelloWorld working in another project & app. AMF through Django with authentication.... not so much...
It seems if I follow the instructions here:
I just need to have an "amfgateway.py" file in my app folder. This is basically a FrontController, and from it, I can define functions that my Flex client can call. Looking at the example on Joel's blog, however, has me confused. So, bunch of questions:
----------------------------------
How do I wire up my Remoting tag? Assuming I have this in my amfgateway.py services dict:
services = { 'cloud.echo': echo }
And my modified urls.py in the main project has this added:
(r'^gateway/', 'powerz.cloud.amfgateway.echoGateway'),
Then I'd have a RemoteObject tag in Flex like:
<mx:RemoteObject id="remoteObj " destination="powerz.cloud.amfgateway.echoGateway" endpoint="http://localhost:8000"> <mx:method name="echo" result="onResult(event)" fault="onFault(event)"/> </mx:RemoteObject>
Right?
----------------------------------
What is the difference between this:
And the client example here:
Are both just examples to use during development? What do I actually have to deploy for production? Are errors from authentication something I can recognize on the Flex client vs. a regular scripting error?
Thanks for your time.
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again?
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Just answered my own question, yes, I can test login's locally. On Sun, Jul 5, 2009 at 10:08 AM, Jesse Warden <jesse.warden@...> wrote:
Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again?
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
I am new to pyamf.
I see in the python code there is client.py and server.py, so could you please explain me more clear about that?
I guess we just use server.py and client.py is just similar to flex client site, is that right?
Thanks, -LN On Sun, Jul 5, 2009 at 9:33 PM, Jesse Warden <jesse.warden@...> wrote:
Just answered my own question, yes, I can test login's locally.
On Sun, Jul 5, 2009 at 10:08 AM, Jesse Warden <jesse.warden@...> wrote:
Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again?
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
If you run server.py that will create an AMF gateway that you can connect to with a compatible client (Flash, PyAMF client etc.).
client.py is an example on how to use the PyAMF client to communicate with the server.
You can run both from the shell:
jason: nick$ python server.py
And in another:
jason: nick$ python client.py Hello World jason: nick$
Hope that all makes sense ..
Nick On 17 Jul 2009, at 08:53, oso che bol wrote: Hi,
I am new to pyamf.
I see in the python code there is client.py and server.py, so could you please explain me more clear about that?
I guess we just use server.py and client.py is just similar to flex client site, is that right?
Thanks, -LN On Sun, Jul 5, 2009 at 9:33 PM, Jesse Warden <jesse.warden@...> wrote: Just answered my own question, yes, I can test login's locally. On Sun, Jul 5, 2009 at 10:08 AM, Jesse Warden <jesse.warden@...> wrote: Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again? _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi Nick,
Much thanks.
Best Regards, -LN On Fri, Jul 17, 2009 at 3:10 PM, Nick Joyce <nick@...> wrote:
Hi,
If you run server.py that will create an AMF gateway that you can connect to with a compatible client (Flash, PyAMF client etc.).
client.py is an example on how to use the PyAMF client to communicate with the server.
You can run both from the shell:
jason: nick$ python server.py
And in another:
jason: nick$ python client.py Hello World
jason: nick$
Hope that all makes sense ..
Nick On 17 Jul 2009, at 08:53, oso che bol wrote:
Hi,
I am new to pyamf.
I see in the python code there is client.py and server.py, so could you please explain me more clear about that?
I guess we just use server.py and client.py is just similar to flex client site, is that right?
Thanks, -LN On Sun, Jul 5, 2009 at 9:33 PM, Jesse Warden <jesse.warden@...> wrote:
Just answered my own question, yes, I can test login's locally.
On Sun, Jul 5, 2009 at 10:08 AM, Jesse Warden <jesse.warden@...> wrote:
Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again?
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
When we are trying to do Class Mapping between Flex and Python Object, we must register a class, which have the SAME name in python site and flex RemoteClass ex org.pyamf.example.User. Is that right?
Thanks, -LN On Fri, Jul 17, 2009 at 3:57 PM, oso che bol <ndlgroup1@...> wrote:
Hi Nick,
Much thanks.
Best Regards, -LN
On Fri, Jul 17, 2009 at 3:10 PM, Nick Joyce <nick@...> wrote:
Hi,
If you run server.py that will create an AMF gateway that you can connect to with a compatible client (Flash, PyAMF client etc.).
client.py is an example on how to use the PyAMF client to communicate with the server.
You can run both from the shell:
jason: nick$ python server.py
And in another:
jason: nick$ python client.py
Hello World
jason: nick$
Hope that all makes sense ..
Nick On 17 Jul 2009, at 08:53, oso che bol wrote:
Hi,
I am new to pyamf.
I see in the python code there is client.py and server.py, so could you please explain me more clear about that?
I guess we just use server.py and client.py is just similar to flex client site, is that right?
Thanks, -LN On Sun, Jul 5, 2009 at 9:33 PM, Jesse Warden <jesse.warden@...> wrote:
Just answered my own question, yes, I can test login's locally.
On Sun, Jul 5, 2009 at 10:08 AM, Jesse Warden <jesse.warden@...> wrote:
Thanks y'all! After Nick's explanation, I got my view's wired up. I re-read (for the 6th time) the Django tutorial on URL's py and I think I get it now. That + pointing it to a specific method via services object that DjangoGateway uses to know what call goes where. Wrapping my head around a URL pointing to a class' public variable was... weird at first.
Joel, your example makes sense; the pyamf.register__class doesn't have a line break next to import User in your blog in Safari and Firefox, so it didn't compile, but I figured it out eventually, thanks! Still reading your authentication stuff... I'm assuming I can actually test cookies locally and just use Safari's delete cookies to try again?
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
On 17 Jul 2009, at 10:01, oso che bol wrote:
> Hi,
>
> When we are trying to do Class Mapping between Flex and Python
> Object, we must register a class, which have the SAME name in python
> site and flex RemoteClass ex org.pyamf.example.User. Is that right?
That is correct, otherwise there is no way to map the two classes
together. The mapping is case-sensitive.
>
> Thanks,
> -LN
Cheers,
Nick
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
When i do try simpleview example, i got this error messages for get_user function: "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 224, in __call__\n', ' File "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 125, in __call__\n', 'TypeError: get_user() takes exactly 2 arguments (3 given)\n']
I am using pyamf 0.4.2, django 1.0
Thanks, -LN On Fri, Jul 17, 2009 at 5:33 PM, Nick Joyce <nick@...> wrote:
On 17 Jul 2009, at 10:01, oso che bol wrote:
Hi,
When we are trying to do Class Mapping between Flex and Python Object, we must register a class, which have the SAME name in python site and flex RemoteClass ex org.pyamf.example.User. Is that right?
That is correct, otherwise there is no way to map the two classes together. The mapping is case-sensitive.
Thanks,
-LN
Cheers,
Nick
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Without looking at any code, its hard to know but I would think that expose_request=False on the gateway?
Django views all have the http request object as the first argument and the DjangoGateway supports that by default.
If that is not the issue, then please supply some code to reproduce and we can take it from there.
Cheers,
Nick On 17 Jul 2009, at 12:10, oso che bol wrote: Hi,
When i do try simpleview example, i got this error messages for get_user function: "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 224, in __call__\n', ' File "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 125, in __call__\n', 'TypeError: get_user() takes exactly 2 arguments (3 given)\n']
I am using pyamf 0.4.2, django 1.0
Thanks, -LN On Fri, Jul 17, 2009 at 5:33 PM, Nick Joyce <nick@...> wrote: On 17 Jul 2009, at 10:01, oso che bol wrote: Hi,
When we are trying to do Class Mapping between Flex and Python Object, we must register a class, which have the SAME name in python site and flex RemoteClass ex org.pyamf.example.User. Is that right? That is correct, otherwise there is no way to map the two classes together. The mapping is case-sensitive. Thanks, -LN Cheers, Nick
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi Nick,
Thanks you for your response.
My simpleview.py import logging
import pyamf from pyamf import amf3
AMF_NAME_SPACE = 'com.htk.simple'
amf3.use_proxies_default = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
def create_user(username, password, email):
user = User(username, password, email) return user
class User(object): """ This model is associated with User in flex site
""" def __init__(self, username=None, password=None, email=None): self.username = username self.password = password self.email = email
class UserService(object): """ Define User-related service """ def __init__(self, users): self.users = users
def get_user(self, username): try: return self.users[username] except KeyError: return "Username '%s' not found" % username
try: pyamf.register_class(User, 'com.htk.simple.User') except ValueError: print "Classes already registered"
My amfgateway.py
from simpleview import User, UserService users = {
'lisa': User('lisa', 'h1k3r', ' lisa@...'), } services = { 'user': UserService(users), }
gw = DjangoGateway(services, expose_request=True)
My Flex code which call get_user: public function initializeService(): RemoteObject
{ var channel:AMFChannel = new AMFChannel("pyamf-channel", URL);
var channels:ChannelSet = new ChannelSet(); channels.addChannel(channel); var remoteObject:RemoteObject = new RemoteObject("user");
remoteObject.showBusyCursor = true; remoteObject.channelSet = channels;
remoteObject.addEventListener(FaultEvent.FAULT, onRemoteServiceFault); remoteObject.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onRemoteServiceFault);
return remoteObject; }
public function getUser(event:MouseEvent):void {
var operation:AbstractOperation = _service.getOperation('get_user'); operation.addEventListener(ResultEvent.RESULT, resultHandler);
operation.send(txtUsername.text) }
Thanks and Regards, -LN On Fri, Jul 17, 2009 at 6:13 PM, Nick Joyce <nick@...> wrote:
Without looking at any code, its hard to know but I would think that expose_request=False on the gateway?
Django views all have the http request object as the first argument and the DjangoGateway supports that by default.
If that is not the issue, then please supply some code to reproduce and we can take it from there.
Cheers,
Nick On 17 Jul 2009, at 12:10, oso che bol wrote: Hi,
When i do try simpleview example, i got this error messages for get_user function: "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 224, in __call__\n', ' File "/usr/lib/python2.5/site-packages/PyAMF-0.4.2-py2.5-linux-i686.egg/pyamf/remoting/gateway/__init__.py", line 125, in __call__\n', 'TypeError: get_user() takes exactly 2 arguments (3 given)\n']
I am using pyamf 0.4.2, django 1.0
Thanks, -LN On Fri, Jul 17, 2009 at 5:33 PM, Nick Joyce <nick@...> wrote:
On 17 Jul 2009, at 10:01, oso che bol wrote:
Hi,
When we are trying to do Class Mapping between Flex and Python Object, we must register a class, which have the SAME name in python site and flex RemoteClass ex org.pyamf.example.User. Is that right?
That is correct, otherwise there is no way to map the two classes together. The mapping is case-sensitive.
Thanks, -LN Cheers, Nick
_______________________________________________ PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
On 17 Jul 2009, at 12:26, oso che bol wrote: Hi Nick,
Thanks you for your response.
My simpleview.py import logging import pyamf from pyamf import amf3
AMF_NAME_SPACE = 'com.htk.simple' amf3.use_proxies_default = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
def create_user(username, password, email): user = User(username, password, email) return user
class User(object): """ This model is associated with User in flex site """ def __init__(self, username=None, password=None, email=None): self.username = username self.password = password self.email = email class UserService(object): """ Define User-related service """ def __init__(self, users): self.users = users def get_user(self, username): try: return self.users[username] except KeyError: return "Username '%s' not found" % username
Here is the issue. Like I said, using the DjangoGateway supplies the http request object like a standard view by default. You can switch this off by setting expose_request=False or by adding the request object as the first argument to the function.
def get_user(self, request, username): # ...
Cheers,
Nick _______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi Nick,
Thanks very much. It worked.
Btw, could you please point me out how i got Log Output on server side because i imported logging module, but i don't know how to setting Logger module to expose log information
Thanks, -LN On Fri, Jul 17, 2009 at 6:32 PM, Nick Joyce <nick@...> wrote:
On 17 Jul 2009, at 12:26, oso che bol wrote:
Hi Nick,
Thanks you for your response.
My simpleview.py import logging
import pyamf from pyamf import amf3
AMF_NAME_SPACE = 'com.htk.simple'
amf3.use_proxies_default = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
def create_user(username, password, email):
user = User(username, password, email) return user
class User(object): """ This model is associated with User in flex site
""" def __init__(self, username=None, password=None, email=None): self.username = username self.password = password self.email = email
class UserService(object): """ Define User-related service """ def __init__(self, users): self.users = users
def get_user(self, username): try: return self.users[username] except KeyError: return "Username '%s' not found" % username
Here is the issue. Like I said, using the DjangoGateway supplies the http request object like a standard view by default. You can switch this off by setting expose_request=False or by adding the request object as the first argument to the function.
def get_user(self, request, username): # ...
Cheers,
Nick _______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
You should be able to set the logger property on the gateway:
gw.logger = loggerInstance
For info on logging, I suggest you check out the docs [1]
Cheers,
Nick
On 17 Jul 2009, at 12:37, oso che bol wrote: Hi Nick,
Thanks very much. It worked.
Btw, could you please point me out how i got Log Output on server side because i imported logging module, but i don't know how to setting Logger module to expose log information
Thanks, -LN On Fri, Jul 17, 2009 at 6:32 PM, Nick Joyce <nick@...> wrote: On 17 Jul 2009, at 12:26, oso che bol wrote: Hi Nick,
Thanks you for your response.
My simpleview.py import logging import pyamf from pyamf import amf3
AMF_NAME_SPACE = 'com.htk.simple' amf3.use_proxies_default = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
def create_user(username, password, email): user = User(username, password, email) return user
class User(object): """ This model is associated with User in flex site """ def __init__(self, username=None, password=None, email=None): self.username = username self.password = password self.email = email class UserService(object): """ Define User-related service """ def __init__(self, users): self.users = users def get_user(self, username): try: return self.users[username] except KeyError: return "Username '%s' not found" % username
Here is the issue. Like I said, using the DjangoGateway supplies the http request object like a standard view by default. You can switch this off by setting expose_request=False or by adding the request object as the first argument to the function.
def get_user(self, request, username): # ...
Cheers,
Nick _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|

|
Re: n00b help
Hi,
Thanks for your guide, i got it worked.
When i tried Login example of Django, i got this issues:
2009-07-17 10:18:32 DEBUG django.__call__: AMF Request: <Envelope amfVersion=0 clientType=3>
(u'/1', <Request target=u'login'>[u'username', u'password']</Request>) </Envelope> 2009-07-17 10:18:32 DEBUG django.__call__: AMF Response: <Envelope amfVersion=0 clientType=3>
(u'/1', <Response status=/onResult>None</Response>) </Envelope>
I noticed that result is None and in flex site, nothing happen
Please help to give your advice. Thanks and Regards, -LN On Fri, Jul 17, 2009 at 6:43 PM, Nick Joyce <nick@...> wrote:
Hi,
You should be able to set the logger property on the gateway:
gw.logger = loggerInstance
For info on logging, I suggest you check out the docs [1]
Cheers,
Nick
On 17 Jul 2009, at 12:37, oso che bol wrote: Hi Nick,
Thanks very much. It worked.
Btw, could you please point me out how i got Log Output on server side because i imported logging module, but i don't know how to setting Logger module to expose log information
Thanks, -LN On Fri, Jul 17, 2009 at 6:32 PM, Nick Joyce <nick@...> wrote:
On 17 Jul 2009, at 12:26, oso che bol wrote:
Hi Nick,
Thanks you for your response.
My simpleview.py import logging
import pyamf from pyamf import amf3
AMF_NAME_SPACE = 'com.htk.simple'
amf3.use_proxies_default = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
def create_user(username, password, email):
user = User(username, password, email) return user
class User(object): """ This model is associated with User in flex site
""" def __init__(self, username=None, password=None, email=None): self.username = username self.password = password self.email = email
class UserService(object): """ Define User-related service """ def __init__(self, users): self.users = users
def get_user(self, username): try: return self.users[username] except KeyError: return "Username '%s' not found" % username
Here is the issue. Like I said, using the DjangoGateway supplies the http request object like a standard view by default. You can switch this off by setting expose_request=False or by adding the request object as the first argument to the function.
def get_user(self, request, username): # ...
Cheers,
Nick _______________________________________________
PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users
|