Thursday, April 28, 2011

django: trying to access my robots.txt: "TypeError at /robots.txt 'str' object is not callable"

Exception Type: TypeError at /robots.txt

Exception Value: 'str' object is not callable

What gives?

Views:

ROBOTS_PATH = os.path.join(CURRENT_PATH, 'robots.txt')


def robots(request):
""" view for robots.txt file """
return HttpResponse(open(ROBOTS_PATH).read(), 'text/plain')

Settings:

CURRENT_PATH = os.path.abspath(os.path.dirname(__file__).decode('utf-8'))

URLs:

(r'^robots\.txt$', 'robots'),
From stackoverflow
  • Try:

    from appname.views import robots
    (r'^robots\.txt$', robots), 
    

    Or:

    (r'^robots\.txt$', 'projectname.appname.views.robots'),
    

    Django can't figure out where your 'robots' function is.

    pythondjango : Had to remove the quotations. Dumb error. You're the man.

How to setup APE server on windows.

Hi

Can any one help me set-up APE Server on windows machine... I have installed it in Ubuntu in Virtual Box. But can't access on host windows...

From stackoverflow

How can I compile C++ code using another C++ program?

I want to create a program that modifies another c++ source,compiles it and runs the exe. I mean with something like gcc may be I can but on a windows os gcc may not be present. Is it possible?

From stackoverflow
  • I think your options are fairly limited for windows:

    1. Check for an install of a compiler (possibly limit this to a short list) and use that compiler
    2. Bring along a compiler in your application's install package
  • Cowboy answer:

    Only if:

    • the source code doesn't need a lot of files/headers/libraries
    • they can be easily collected by your application
    • the application have connection with some server of yours

    The application could:

    • collect the files in a zip
    • send them over the wire to an compiler service (accesible vía HTTP)
    • the server compile it with its own installation
    • and return the binary executable inside the response.

    Of course: it depends on so many variables that seems not very feasible. And the zip+http thing could be difficult from a C/C++ app.

    Alexander Ivanov : hmm it can be slow...and it depends on internet connection. But it's interesting idea ;)
    Steve Jessop : +1 for audacity.
    helios : Thanks... anyway I was thinking on it and realized about managing zip and http in C... and it was not that nice... :S
    Steve Jessop : You can (should) grab a library for that sort of thing. Even so it's going to be more work than some languages. As it happens I have implemented both HTTP client and zip file writer libraries in the past: not in C but in a language at about the same level, so I was sitting on top of zlib and a Berkely-style sockets interface. I don't really recommend it, for a very simple http client it's not all that difficult, just very tedious. Use libcurl and libtar instead (tar since compression isn't actually essential here anyway, so keep it simple)...

Could you tell me where I can find specification of simple_item_list_1 or simple_item_list_2?

Could you tell me where I can find specification of simple_item_list_1 or simple_item_list_2? Or tell me how to use them both?

From stackoverflow
  • You can find these resources, and others, in your SDK. They are in $ANDROID_SDK/platforms/$VERSION/data/res, where $ANDROID_SDK is where you unpacked the SDK on your machine, and $VERSION is some Android version (e.g., android-8 for Android 2.2).

    kspacja : Okay. I can read source of this XML files, but I still don't know, what object I have to give to contructor of ArrayAdapter, when I use simple_list_item_2. For example, for simple_list_item_1, constructor of ArrayAdapter looks like this: new ArrayAdapter(this, android.R.layout.simple_list_item_1, new String[] {"Car", "Cat"});
    CommonsWare : @kspacja: `ArrayAdapter` doesn't support `simple_list_item_2`. Here is a sample project showing the user of `simple_list_item_1`: http://github.com/commonsguy/cw-android/tree/master/Selection/List/
    kspacja : How to do this with simple_list_item_1 I know. How do I know, that ArrayAdapter doesn't support simple_list_item_2? How do I know what support what?

AIR installer to install 3rd party app

Say I've got a working AIR app that needs to also bundle a driver (licensing okay) for some hardware that the app uses. Anyone know if its possible to launch the driver installer at the end of the app install?

I'm not finding good documentation on this and im wondering if there is a standard pre-install / post-install script I can create to handle stuff like this.

Thanks Stabby

From stackoverflow
  • You should be able to use the NativeProcess API to accomplish this.

    : Okay so I can launch processes, but my question is where to put this code to run when the installer runs - not every time the app runs. Is there a post-install hook somewhere, or a special place I can put NativeProcess code that only runs on the first install?
    Inigoesdr : Well, you have a few options. The easiest would be find a way to check to see if the program is already installed on launch, so it only gets installed when it's not already. For example, write a dummy text file after you finish the installer that you can check for in the AIR app. There is also the encrypted local storage you can use to store a flag that says the installer has already run. (https://www.adobe.com/devnet/air/ajax/articles/encrypted_local_store.html)
    : I see. This is not good - adding a bunch of logic to handle something that should be native to the AIR installer. You said "..after you finish the installer.." - how where you suggesting I run something after the installer?
    Inigoesdr : I originally interpreted your question as "I have a proprietary installer I made", but now that I read it again you didn't really say it like that. That said, you could use something like NSIS(http://nsis.sourceforge.net/Main_Page) to make your own, or wrap one that you are getting from a third party. It might just be easier to make an installer(via NSIS or similar) that runs your driver installer and then runs the .air file.

What AMF Servers Support Remote Shared Objects?

Greetings. I'm planning on building a Flex based multiplayer game, and I'm researching what will be required for the server end. I have PHP experience, so I started looking at ZendAMF.

Now in this game, I'll need the concept of rooms, and real time updates to clients in those rooms, so it looks like I'll be using remote shared objects (correct, yes?). I'm not seeing where ZendAMF can support this.

So I found this page: http://arunbluebrain.wordpress.com/2009/03/04/flex-frameworks-httpcorlanorg/

It seems to indicate that ZendAMF isn't going to do what I want. WebORB for PHP seems to be the only PHP based solution that does messaging, but on that page it doesn't mention "real-time" next to it like the Java based ones below it do.

What should I be looking at for the server piece with my requirements? Do I need to make the jump to something like BlazeDS and try to pick up a bit of Java knowledge?

Thanks.

From stackoverflow
  • Both ZendAmf and weborb use http long pulling. Think of it as pinging to check for updates. If you really need TRUE realtime push notification then PHP will not be your answer due to it not having threads or long running processes. WebOrb has several servers in other languages along with BlazeDS, RubyAMF, PyAmf, and of course LCDS from adobe that allows for true messaging.

    GrayB : Are BlazeDS and LCDS the only servers that support Shared Objects? I'm not seeing that RubyAMF supports this. Seems like it's in the same position as PHP
  • I think you already know the answer, but for other people looking into this as well:

    All *AMF solutions use HTTP as transfer protocol and can't have permanent connection. AMF is sent encoded through HTTP and then it's closed.

    When you want to use "real" real-time (RTMP,RTMPT), you have choices like: opensource: Red5 (Java), BlazeDS (Java), FluorineFX (.NET) commercial: Wowza Media Server (Java), WebORB (.NET and Java)

    David : For commercial servers, I think you forgot Flash Media Server
  • I'd highly reccommed flash media server if you have the cash. I've had good expereince with it in the past

Monday, April 25, 2011

Disabling the VB background compiler in VS2008

Does anyone know how to disable the background compiler for VB in VS2008?

For my sins I have to work on a large VB.NET project and it often locks up for 20 seconds at a time whilst doing the very helpful background compilation which is extremely frustrating.

I'd rather work blind between compiles and be able to do some work.

From stackoverflow
  • No there is no way to disable the background compiler.

    Have you installed Visual Studio 2008 SP1. There were several bugs we fixed in the RTM version of VS 2008 which can cause the IDE to hang under certain circumstances.

    We take issues with the background compiler very seriously. If you can give us a repro of the problem it will definitely be investigated. If you can produce such a repro or even send us a memory dump when the IDE is locked please file a bug on Connect: https://connect.microsoft.com/VisualStudio

    A couple of other steps you can take. Do you have any Add-ins installed in VS? If so try uninstalling them 1 at a time. I've seen several cases where 3rd party add-ins caused lock ups in the IDE which were completely unrelated to the C#/VB framework.

    Garry Shutler : I have got VS fully updated. The only add-ins I have installed are Resharper, Gallio and Test-Driven.NET. I have tried running native as I had read about add-ins causing problems and still came across the same problem. I'm using MSTest against a .NETCF 3.5 solution to throw some more into the mix.
    Garry Shutler : I will see if I can find a way to consistently reproduce it but I've only found it on this large solution and I don't think I'd be able to provide you with our source. How would I go about giving you a memory dump from when it's hanging?
    Garry Shutler : Also, do you know what the reasoning behind not providing a way to disable the background compiler? I know it's useful most the time, but just being able to switch it off would be very useful for me right now.
    JaredPar : @Garry, the majority of the IDE features depend on the result of the background compiler. Turning it off would effectively disable the majority of the IDE.
  • I have run into this very same problem with one of my forms that is very control intensive. It takes me a minute to change properties. All the other forms in the solution are pretty snappy.

    The background compiler is now no longer a help and now an active hindrance to my productivity!

    I'm not convinced that the IDE requires the background compiler to function, given that the C# IDE provides all the same features without a background compiler!

    Or can you at least investigate perhaps providing some attributes that can be sprinkled in the code saying something like 'Code in this method is OK. Don't look at it'