Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Baby steps

Im­ple­ment­ing prop­er up­dat­ing is sim­ple in that send­ing stuff to PyDS is sim­ple. How­ev­er, hav­ing the GUI do the right thing is trick­y:

When you mod­i­fy an en­try and switch to an­oth­er, you have to of­fer a chance to save or dis­card.

If the us­er dis­card­s, you have to go back to the orig­i­nal data, so it must be saved some­where else. And re­mem­ber this:

>>> a={}
>>> b=a
>>> a['x']=1
>>> b['x']
1

Yeah, ob­vi­ous python se­man­tic­s. Lost an hour, though ;-)

What you want to do in­stead is:

b=copy.deepcopy(a)

If he saves, you have to up­load.

Al­so, when he mod­i­fies, you have to up­date the post list re­al­time, so you see a co­her­ent en­ti­ty. Not too hard, but it forces you to despaghet­tize code some­what.

Almost a useful app

Lacks lots of stuff, but the UI is pret­ty much done.

Stuff need­ed be­fore pub­lish­ing:

  • Up­dat­ing posts (PyDS and ad­voga­to)
  • Delet­ing posts (PyDS and ad­voga­to)
  • Post­ing new (ad­voga­to)

Stuff done:

  • Ac­count cre­ation
  • Ac­count edi­tion
  • Post edi­tion
  • Post­ing new (PyD­S)
Sadly, I have lots of work for the next two or three days, so progress will slow.

And.... evil plug­in code! (I will re­do it some­day, may­be):

#Here acctype is one of "pyds" or "advogato"
#Both are mod­ules that de­fine a class called Ed­i­tor,    #which in­her­its a QWid­get 

ex­ec ("im­port "+ac­c­type+" as blog")
self­.Ed­i­tor=blog.Prop­er­ties(­par­en­t=­self.Frame,­name=str(ac­coun­t))
 

Of course, if an evil guy could re­de­fine the list of plug­ins and in­sert an evil mod­ule in­to your PYTHON­PATH, this would RE­AL­LY suck ;-)

The fastest blog in the west

This guy posts 1200 word mag­a­zine-qual­i­ty in­for­ma­tion-­packed ar­ti­cles so ca­su­al­ly...

Now, that was easy!

I al­ways dread the mo­ment when a pack­age has to be shared, and some­thing dis­tributable has to be made. You know, don't for­get any files, and such.

Not to men­tion the an­cil­lary night­mare of make/au­tomake/au­to­con­f/a­clo­cal/etc. I sim­ply trust­ed the kind­ness of strangers for that.

And I nev­er man­aged to make RPMs or any­thing like it. But dis­tu­tils makes in­stalling, dis­tribut­ing, re­al­ly sim­ple.

Here's an ex­am­ple:
#!/usr/bin/env python

from distutils.core import setup

setup (name="klog",
       version="0.0.1",
       description="klog: a PyQt blog tool",
       author="Roberto Alsina",
       author_email="ralsina@kde.org",
       url="//ralsina.me",
       packages=["klogmodules"],
       scripts=["klog.py"],
       long_description="""Long description here """

)

That is enough to build, in­stal­l, cre­ate RPM­s, De­bian pack­ages, in­clude the file in PyP­I, and who knows what else.

Have an­oth­er file in the pro­jec­t? Just toss it in the klog­mod­ules di­rec­to­ry, and it's done!

Of course this is on­ly for python app­s, but I don't see me cod­ing in oth­er lan­guages soon. The on­ly rea­son I got in­to C++ was be­cause there was no de­cent in­ter­pret­ed lan­guage with a de­cent toolk­it!


Contents © 2000-2023 Roberto Alsina