Clone wiki

agatsuma / Ideology

Python - just a tool. Perhaps, not a best, with problems, but it can give us all what we want. We can do anything with this tool. Agatsuma - like a magic wand, can give you anything, what you want. But! You need to discover a spell, you need to call higher powers of the world! You need to know inners of the world, you need to create spell on the Python! Spells - pieces of your power, of agatsuma power. It's what your can.

Why Python?

This is really great question. Of cause, every tool has some problems and limits. In Python(as we see), we have small amount of cons:

If you'll try to mixin into default type, you'll get an error:

TypeError: can't set attributes of built-in/extension type 'Int'

So, about default types redefining/mixing:

For the curious: there are two reasons why changing built-in classes is disallowed. 
First, it would be too easy to break an invariant of a built-in type that is relied
upon elsewhere, either by the standard library, or by the run-time code.
Second, when Python is embedded in another application that creates multiple Python
interpreters, the built-in class objects (being statically allocated data
structures) are shared between all interpreters; thus, code running in one
interpreter might wreak havoc on another interpreter, which is a no-no.
[[|Unifying types and classes in Python]]
  • Python has no private methods. This is very popular topic for holywars. Every developer knows about "private" objects(methods) modifiers in classes of Java, C#, C++, Ruby. But what we have in python? Nothing? We have more flexible way to define a private objects of classes: if you want to create private method/var, just name it like "name" or "_name". Most people calls it "shitty python naming style", but it's better if you want to get control of your application.

So: Style Guide for Python Code

What i want to say? Encapsulation is for kids. For real projects and big boys it's just a great wall, which, sometimes, need to break.

  • There is no "const variables"(atoms). Yes, it's a problem. But! It isn't necessary to use atoms in real projects with OOP. Anyway, Python is so great language, we can implement everything, anything what we want. So, we created Atoms for you.
  • Shitty lambda. Perhaps, it isn't like a lambdas in ruby or haskell, but it's enough for good developers. If you want more from python lambdas, you need to think about it again.


As i said, it's like a wand. Like a wand with powers. You need to choose spells you want to use versus your enemy and use wand for it. Agatsuma - great modular platform, which gives you frames and tools for easy-to-use modules creating. You can create your module and use it with other modules w/o special works!


Spell - module of Agatsuma. Everything in Agatsuma is Spells. Want to implement Blog system? Create Blog System Spell! Want to use sessions, db? Use Sessions Spell, Database Spell!

Main idea - each spell consists of spells by functionality depends. From main idea to realization. From top layer, to bottom.

For example:

You want to create a chat client over IRC proto. It will be:
IRC Chat Client Spell as main project.
It splits into/depends on: GUI Spell, Network Spell.
Each of its splits into/depends on different spells:
NetworkChatSpell depends on ChatProtocolSpell.
ChatProtocolSpell depends on NetworkBackendSpell.

This is abstraction layer. We need to implement it:

So, you have great application with great spells! And one thing you must to remember: you can switch between Spells implementations w/o pain in the ass!

Spell declaration

class FooSpell(AbstractSpell, i-faces):
...class Dependencies(DependenciesSchema):
......plugins = [Atom.ns1.ns2.IFooPluginSpell]
......plugin = Atom.ns1.ns2.IFooPluginSpell
......myplugin = Atom.ns1.ns2.MyFooPluginSpell
...class Settings(SettingsSchema): = type
...def method(args):