Deepwalker

  • Archive
  • RSS
  • Ask me anything

Trafaret - data converter

  • 2 months ago
  • Comments
  • Permalink
  • Share
    Tweet

M2M in Aldjemy

Recently I have added M2M support in Aldjemy. So sample from first post is not actual anymore.

Old:

User.sa.query().join(User.sa.user_groups).join(User.sa.user_groups.property.mapper.class_.group).filter(Group.sa.name=="GROUP_NAME")

New:

User.sa.query().join(User.sa.groups).filter(Group.sa.name=="GROUP_NAME")

Far more better!

    • #aldjemy
    • #django
    • #sqlalchemy
  • 5 months ago
  • 3
  • Comments
  • Permalink
  • Share
    Tweet

FreeSWITCH creator used DMCA to ban alternative codec from github. Funny guy.

Got this from github today about https://github.com/Deepwalker/fs_itu_g729 :

Hello, the following site contains a module for my software FreeSWITCH that violates the MPL License it was released under. The poster put this module up and did not follow the license. In addition the repo contains a copy of unauthorized G729 code which is protected by patent by Sipro. see: http://www.sipro.com/g7291_about.php We sell a similar module to to this one legally and by allowing this module to exist it puts us in jeopardy. The code combines this unauthorized G729 code with the non-compliant code from my software and it constitutes an illegal act. They are simply using your site as a means of distribution. Clearly it’s never been edited and only is used to access the files. As you can see my name even appears in the file: https://github.com/Deepwalker/fs_itu_g729/blob/master/mod_g729.c I have a good faith belief that use of the copyrighted materials described above on the infringing web pages is not authorized by the copyright owner, or its agent, or the law. I swear, under penalty of perjury, that the information in this notification is accurate and that I am the copyright owner, or am authorized to act on behalf of the owner, of an exclusive right that is allegedly infringed.

Do you know, Antony, that Africa bigger then Texas? Sure? This mod will be hosted in near future on other hosting, and you cant ban it from the internet. But DMCA usage can damage your carma. I’m sure that there is nothing illegal in this codec code, but I’m to lazy to promote YOUR product, that I will never ever use due it sucks.

Others, you can get all freeswitch g729 staff there ftp://icf.org.ru/pub/soft/codecs

    • #freeswitch
    • #dmca
  • 8 months ago
  • 2
  • Comments
  • Permalink
  • Share
    Tweet

Flask and API

I search for API framework for Flask, but dont find, and this is why I create own one.

Before Flask I used Svarga framework. It was good thing, and I participated in its development, but sometime ago core devolpers decide that Flask is good enough, and noone need frameworks zoo.

So Svarga history is ended, but Svarga has several good things. Today I will tell you about one of them - Bundle.

So, what is Bundle? Bundle is class based url/views collection, and you can read about it in svarga documentation - http://svargahq.net/docs/shortcuts.bundle.html .

What pros for Bundle over Blueprint? Blueprint is collection of plain views, and this mean, that you dont parametrise it. And Bundles can be parametrised, inherit, overload methods and so on. You can create some good piece, that can be reused many times. Main example - CRUD. You can create Bundle, that will list, create, update, delete any model, and use it like this:

Now I have not ported AdminBundle from Svarga, instead of that I created APIBundle. What it about - you use APIBundle in usual bundle fashion way:

This is good enough. Someone can disllike class-style and so on, but ther is nothing astonished or weired in this sample - usual API implementation, but may be we need to go deeper? Yeah, I think we need:

As you can see, we have automatic dumping of API description. We usually write what methods we understand, what url we use, and get pretty, json friendly, description of our API. For what? For automatic API binding generation, of course:

So we implement API, and then get description and bindings generation for free. Good.

What next - human description generation, js binding generation.

I want to discuss this idea, so, comment appreciated.

Full example there https://github.com/Deepwalker/flask_bundle

    • #flask
    • #api
    • #bundle
    • #svarga
  • 8 months ago
  • 32
  • Comments
  • Permalink
  • Share
    Tweet

SQLAlchemy for Django with Aldjemy


I dont like Django. I dont like django ORM, django templates, django forms and many other parts of django. But we use it, its `lingua franca` for python web development, it has many packages (not always good ones) and many developers know django well enough.

So we need to live with django flaws. But we can make life easer with really good python projects, like SQLAlchemy.

In some Django projects we need complex queries, and contrib ORM cant help us with this. Imagine that we have old big project, where we need such types of queries. What will we do? Write raw SQL or use SQLAlchemy? I think SQLA is best choice, because raw SQL bad in DRY-fication.

What we can get in SQLAlchemy opposite to django ORM? Its main questions that I hear from django lovers. So I have an answer - we can get arbitrarily SQL query. You want `group by`, `order by` and so on? This is not serious task for SQLA. You want distinct define joins with any conditions? SQLA can help you. And - you want included queries? No problem. You can use any SQL function, you can build any possible expression. You get all SQL power.

What cons? You need to keep separate data struct description, unless you can inspect DB, or, this is what I do in aldjemy, inspect django models and build SQLA tables and mappers from this.

Just add `aldjemy` to the end of INSTALLED_APPS, and aldjemy will collect all your models and add an `sa` attribute to them.

Then start your ./manage.py shell_plus and type:

User.sa.query.join(User.sa.user_groups).join(User.sa.user_groups.property.mapper.class_.group).filter(Group.sa.name=="GROUP_NAME")

Hey, what is it, we need to declare joins epxlicit? Indeed, this is SQLA, and you need to build your SQL query with explicit declarations. But, do you need to use SQLA for users by group selecting? Of course not! Wait for a time when you will need really complex query, and solve this problem with mature SQL query building tool.

See for project on github aldjemy

Or just install it from PyPi:

pip install aldjemy

    • #django
    • #sqlalchemy
    • #python
  • 9 months ago
  • 4
  • Comments
  • Permalink
  • Share
    Tweet

About

Avatar

Me, Elsewhere

  • @deepwalker on Twitter
  • My Skype Info
  • deepwalker on github

Following

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr