Designing a web based game that would run in a browser - Where should I start? - python

I would like to design a web based game preferably in Python ( using Django maybe) though I'm open to any language other than Java/Flash/ActionScript. The idea I have in mind is more about data models than graphics and will leverage social networking sites. I would like to extend it with a mobile web interface in the future. Please give your invaluable suggestions and recommend some resources with which I can get started.

Step 1. Design a good game.
Step 2. Be sure that it fits the HTTP model of simple request/reply GET/POST processing. Be sure that the game is still good. Some people try to do "real time" or "push" or other things that don't fit the model well and require lots of sophisticated GUI on the desktop.
Step 3. Find a web framework. Django is okay. Others are good too.
Learn the web framework. Don't start with your game. Start with the tutorials.
Step 4. Rethink your game. Be sure that it fits the framework's model, as well as the HTTP model. Be sure that the game is still good. In particular, if your focus is "more about data models than graphics" then you have to really be sure that your game's data model fits your framework's capabilities.
Step 5. Rethink your framework. Is Django still the right choice? Perhaps you need to go back to step 3 and learn another framework. There's nothing wrong with learning a second framework. Indeed, until you learn another framework, you won't fully get Django.
Step 6. Now you should have enough background to actually implement your game.

If you are considering using Django as your framework, here are just some basic points about it you might find helpful to consider:
Firstly, the Django libraries are written in Python. Therefore, at least a basic knowledge of python is required to develop a site using Django.
Secondly, Django includes its own template system that is useful for integrating with html - http://docs.djangoproject.com/en/dev/topics/templates/ .
Thridly, as you've stated that you are more concerned with data models (which I am assuming means you are going to want to store information in some way especially considering it is related to social networking ?) Django also provides for a way to integrate with databases like MySQL and SQLite and the tutorial even walks you through how to set one up if you haven't already - http://www.djangobook.com/en/2.0/chapter05/ - and how to integrate with a legacy database if you have - http://docs.djangoproject.com/en/dev/howto/legacy-databases/?from=olddocs .
Lastly, Django enables you to run your site off of their development server which can be really useful for testing and running your site locally before deploying it to the web via Apache or another web server of your choosing - http://docs.djangoproject.com/en/dev/intro/tutorial01/#the-development-server .
I would really encourage you to do the online tutorial - http://docs.djangoproject.com/en/dev/intro/ - or take a look at Holovaty and Moss's "The Definitive Guide To Django" (available on http://www.djangobook.com/).
Hope this helps!

Related

Flask Custom Login and Template Rendering

I am new to learning Python for web development and have decided to go with Flask as my framework of choice as of now. I have chosen this primarily for its bare-bones approach on web development and I want to make as much of my web app custom and on my own as possible. I have made a very basic MVC framework in PHP and would like to make something like this in Python. I was researching some ways to interact with a database and add user login/register support and my original thoughts were that I wanted to do this all custom with my own methods and objects and what not. Similar to how I have done in PHP, so I can learn as much about developing my own back-end efficiently for long term production projects. In some research I found the basic objects in Flask such as Login Manager, Login-Form and Flask-Admin, etc. I don't like the idea of using these nicely packaged things that I have very little control over and have not dev'd custom.
Using that kind of stuff I also feel that I am not learning how all of that stuff works on the lowest level so I could not reproduce some of the benefits they are giving me later on in life when project circumstances change and maximum flexibility, customization, maintainability, and efficiency is needed. Obviously I am not in that position right now, but I DO know how to write this back end stuff in PHP and am just wondering if that means anything as far as managing sessions and Authentication on my own in Python/Flask, or if my thinking is totally out of ocontext and its not even close to managing the same stuff.
It is a really great idea to learn how authentication works at a low level -- it's particularly important as many people never learn this stuff, and it's quite interesting!
What I'd recommend you do is take a look at the official Flask tutorial (http://flask.pocoo.org/docs/0.10/tutorial/), as it covers a lot of this (working directly with sessions, etc.).
What I would not recommend, however, is using this sort of thing in production.
Using your own authentication code is almost never a good idea -- it's much better to rely on a well supported library that has been audited by other people for security issues.
In the Flask world you've got a couple choices:
Flask-Login: https://flask-login.readthedocs.org/en/latest/
Flask-Security: https://pythonhosted.org/Flask-Security/
Flask-Stormpath: http://flask-stormpath.readthedocs.org/en/latest/
Of those 3, I really like Flask-Stormpath -- but I'm super biased as I wrote it =)
Flask-Stormpath supports the widest array of customization / etc., and allows you to do whatever you want with it.
Hope that helps!
Flask official doc have some app examples. One of them is MiniTwit a micro Twitter clone. As it is a complete app, you could found much of what you're looking for. If you want to make something greater, try Full Stack Python Flask tutorial

Multi-tenant SAAS in Django

I have developed Multi-tenant SAAS apps in PHP/Laravel but recently I had a challenge to develop one in Django/Python. I am still learning Django though and I really like Django rest framework (DRF). But I have difficulties to figure out the highlighted areas below, If someone shows some light, I will be good to go:
How to handle subdomains/domains and selecting the right tenant db
How to manage and dynamically handle different database in django
Can multi-tenant apps backend still be managed from Django admin interface
I will be using queues and other apps scalling techniques, need tips and tricks if any
Any example out there
Any challenge experience when developing SAAS through Django
Well...
django-subdomains
There are people who asked in SO questions about dynamic databases in django (including, ahem... me). I'm not entirely sure I understood what you mean by "dynamically handle different database" so I guess just go to the links I just mentioned and pick out the best one for your project. (also - perhaps this is more relevant?)
Check out django-multitenant-schemas and this answer too.
There was a video of the guys behind Disqus (one of the largest django app in the world) explaining how they handle scaling. Here another interesting article on the subject. Also, the legendary SO question Does Django Scale.
(and 6.) Check out this answer
I hope that's detailed enough. I know this might be a disappointing only-links answer, but this is the reality of it - Django is a newer framework, and web development with python is still less common than php. With that in mind, understand that for all the awesomness of django (and it is awesome), with more complex needs there's more you'll have to do yourself.
In this case, you'll have to figure out how to do each part of the way seperatly and then combine it all. You can easily find a way to create a REST django app for example, but then you'll need to figure out how to combine it with another package (such as the above subdomains).
You can find a million examples out there of people doing freaky things with django. It's really powerful (when I learned about dynamic models I was blown away). But the more complex your app, the more you'll need to do yourself.
Pick it up, one step at a time, and come back to SO with specific issues you're having (or the django users google group). Good luck!

Python frameworks for developing facebook apps

I'd like to ask you about your experiences in developing facebook applications in Python. Which of the popular web frameworks for this language you think best suits this purpose? I know "best" is a very subjective word, so I'm specifically interested in the following:
Most reusable libraries. For example one might want to automatically create accounts for new logged in facebook users, but at the same time provide an alternative username + password logging functionality. I need authentication to fit into this nicely.
Facebook applications tend to differ from CMS-like sites. They are action intensive. For more complicated use-cases, usually some kind of caching for the data fetched from Open Graph API is required in order to be able to perform some queries on local and facebook data at once (for example join some tables based on friendship relation).
I'd definitely prefer popular solutions. They just seem to be much more stable and better thought through. I've previously developed a facebook application in Grails and I as much as I liked the architecture and the general ideas, the amount of bugs and complication that I ran into was just a little bit too much. Also Groovy is still quite an exotic language to develop in, and this time I'm not going to work on my own.
I'm not new to Python, but definitely new to web development in Python. Though after the experience with Grails and all its twists and turns I doubt Python could really scare me.
I would almost undoubtedly go with Django as the easiest and most popular framework for developing any type of web applications, if there's a need for a full-stack framework.
Specifically, in regards to Django's app universe, it is plentiful with many active applications -- but that has its downfalls too. There's no standard application for any 'one' thing, but there are a few applications that will do basically 90% of all that's needed. Sometimes the code is poorly written, but most of the time, the apps work and do what they are needed to do, so there's almost no need for someone to dive right in to the code.
Narrowing down our options, I have had great luck with Omab's Django-Social-Auth, which was absolutely a snap to integrate. It required 3 variables in my settings.py and I was up and running.
The only issue might be if you do not want to use the django.contrib.auth.User model, but, if you are not thinking about using that, I would think about that decision twice :)
To narrow it down even further, pyfacebook is another option for integrating Facebook. It comes with a djangofb application so it's just drop, add to settings.py and all is well. It even comes with an example Django application as part of the distribution. I've had pretty good luck with this application, but, I still think Omab's much easier to integrate.
Finally, Facebook's own python-sdk is easy to integrate from a raw standpoint, where they just give you access to their APIs using a simple Python API. However, it seems to cater more to the AppEngine folks, so YMMV.
I've used Django for quite some time. As of late I use Jinja2 instead. No particular reason, but it's another option
If you do not want to start on Django now. Try learning Flask(which is comparatively a lot easier to begin than Django) and then start building app with Flask.

Will learning Django translates well into other applications?

Does anyone have experience using Python in different variaty of applications?
A little background - I am a 3D artist in an animation studio. I do programming in PHP and use Zend framework for my personal project. Python has always been a language I wanted to learn because it can be used within many applications our studio is using (3D MAX, MAYA to name a few) My supervisor knew about my web background and wanted me to create a web base time line manager for the company. From the requirement I'm expecting quite a simple backend ... so it might be a good opportunity to finally learn Python. The bulk of the work will be on AJAX for the interactive front end.
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
a little curious about Django features as well. How well does the framework cover in terms of web application compare to Zend? Our application is pretty basic in the back end and I would love to know if Django will be able to cover them.
authenticate against Windows active directory
quick database update via AJAX interaction (drag and drop time line mostly)
Other basic stuff like discussion forum and directory browsing/file manager
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
No
authenticate against Windows active directory
Yes. You may need to customize an Authentication Backend.
quick database update via AJAX interaction (drag and drop time line mostly)
Django has nothing to do with Ajax. Use piston to create pleasant RESTful API that Ajax can use.
Other basic stuff like discussion forum and directory browsing/file manager
There are many, many canned applications for Django that you can plug in and integrate.
I love python as a language - but it's not the answer to everything. I know this is throwing mud in a python group, but python has one serious limitation - the rigid source code format.
While going through a django tutorial - I noticed that you cannot insert python source code into a template, and that this was presented as a 'feature' for separating programmers and designers.
I later realized that it's a limitation of django - and any other environment where python source code might get accidentally mangled. This also includes HTML WYSIWIG editors and database based 'manglers' (like Drupal).
In my opinion it's a very serious limitation with no easy cure - especially with the need to use other tools to manage the complexity of HTML / CSS / JavaScript.
I found Django a really good way to learn python. There's very little that's quirky, magical or un-pythonic in the framework. A bit of setup and you're away, writing standard python code.

How complicate can a Django application go?

I'm tasked to create a simple CRUD MVC application, and I thought it's a good opportunity to learn python. Because of its great documentation, I'm thinking now that I'll go with Django.
Now, this simple CRUD MVC application could become quite complicated in the future. I might have receive and issue JMS messages, display charts that are updated periodically (I'm thinking about ajax) and what not.
Given this I'm a little worried, since while I'm told it's easy to call Java code from python (I'm a Java developer), I'm also told that Django is generally best for content based web application, and can be restrictive.
Do you think it is okay to go with Django in this case?
simple CRUD MVC application
Django does this "out of the box" The admin interface is a simple, CRUD, MVC application. You don't do much programming to make this happen. You create the model. That's it. Use the Django admin for your CRUD application. Done.
I might have receive and issue JMS messages, display charts that are updated periodically (I'm thinking about ajax) and what not.
That's the point. Since you didn't waste time writing the CRUD application, you are able to write the other, more interesting stuff.
Look at http://hjb.python-hosting.com/ for a Python-JMS bridge.
We have FLEX front-end and Django-based RESTful web services. The Django apps create PDF's, and other things. The FLEX does pretty pictures and charts.
Django is generally best for content based web application, and can be restrictive.
Doesn't mean anything. Provide a quote or a link to whatever it is you're talking about.
Mozilla is currently rewriting two of our largest sites on Django. These are both fairly complex applications that interact with numerous online and offline services. With Python's large collection of libraries, anything Django doesn't do itself we've usually been able to find, or create pretty easily. For example, we have both cron jobs and on-demand offline tasks, backed by AMQP, which is similar to JMS.
Short answer: you can get pretty darn complicated if that's what you need to do, and odds are there's already a Python project or library to do what you need.

Categories

Resources