[three]Bean
TW2 Bugsprint; the Final Countdown
Mar 02, 2012 | categories: python, toscawidgets, pyramid, turbogears View CommentsTomorrow marks the start of the toscawidgets2 24 hour bugsprint and I couldn't be more stoked. We haven't even started yet but tw2 development pushed ahead anyways.
We have:
- redesigned the tw2 homepage.
- improved tw2.jqplugins.jqgrid's sqlalchemy integration.
- pumped out one or two miscellaneous fixups to tw2.jqplugins.ui.
- released tw2.jqplugins.elrte.
- released tw2.jqplugins.elfinder (which is amazing).
- released tw2.captcha based on tgcaptcha2.
- released an alpha version of tw2.d3. It's built with WebSocket support in mind. More on that soon!
- been excited to learn that the TurboGears2 team is aiming to standardize on tw2.
- been fielding a lot more support for tw2 in Pyramid 1.3 both on the mailing list and in #toscawidgets. There's a bug still lurking out there for windows+tw2+pyramid users. At this point, if you can reproduce it and tell us about it, that would be helpful.
- got our first reports of people using tw2 with bottle. It worked!
Goal: (solidly) close as many bugs as possible and push as many libraries from beta to release as we can.
Here's to winning that game.
New toscawidgets.org frontpage
Feb 26, 2012 | categories: python, toscawidgets View CommentsThe toscawidgets2 24 hour bugsprint is this coming Saturday! In order to get you excited and to curry all of your favors, I decided to give http://toscawidgets.org a facelift.
The old http://toscawidgets.org site was confusing! 80% of the frontpage was about toscawidgets 1 which, while stable, has a diminishing number of maintainers and no active development. 20% of the page was a "news" bar on the right that pointed users to "Alpha releases" and "new documentation" for tw2, timestamped back in 2010!
I revamped it to more clearly differentiate between the two versions of the framework and to give it a more modern look (if we're building python widget libraries, we better be on top of CSS3 on our project page, right?)
Migrating from wordpress
Feb 14, 2012 | categories: python, blogofile View CommentsI got fed up with wordpress and have moved to the python tool blogofile. I've been intermittently tending to my old blog over at http://threebean.wordpress.com/ and getting traffic I'm happy with. A lot of my old tutorials on tw2 regularly get referred to by google and my new posts get picked up by readers of planet python and occasionally by reddit.
WordPress has become unbearable:
- I have to edit my posts in a clumsy WSIWYG editor.
- My posts appear in planet aggregators without proper links back to my blog and half-truncated.
- My control of styling and javascript is limited.
- I can't embed github gists.
So I'm trying out blogofile:
- It supports both reStructuredText and markdown out of the box.
- My styling and layout are handled by mako templates which I use already elsewhere.
- I can keep my posts in git.
- I can host everything in one place on http://threebean.org
Along the way, I picked up this handy hack from zzzeek on getting syntax highlighting working in reST posts.
I also had to script something up with feedparser to parse my exported WordPress blog's and reimport it to blogofile. Here's what I wrote (It's based heavily on this example from the blogofile github repo:
#!/usr/bin/env python """ WordPress (xml) -> blogofile. Picks up an exported WordPress.com blog in XML format and builds a blogofile ``_posts`` directory out of it. """ import codecs import feedparser import os import re import yaml def get_published_posts(filename): """ Generator over the posts in a wordpress.com XML dump. """ d = feedparser.parse(filename) for entry in d['entries']: if entry.get('wp_attachment_url', None): pass elif entry.get('title', None) == 'About': pass else: yield entry if __name__ == '__main__': #Output textile files in ./_posts if os.path.isdir("_posts"): print "There's already a _posts directory here, "\ "I'm not going to overwrite it." sys.exit(1) else: os.mkdir("_posts") old_prefix = "http://threebean.wordpress.com/" new_prefix = "http://threebean.org/blog/" prepend_links = True post_num = 1 for post in get_published_posts('wordpress-export.xml'): yaml_data = { "title": post['title'], "date": post['wp_post_date'].replace('-', '/'), "permalink": post['link'].replace(old_prefix, new_prefix), "categories": ", ".join([ tag['term'].lower() for tag in post['tags'] ]), "tags": ", ".join([ tag['term'].lower() for tag in post['tags'] ]), } fn = u"{0}-{1}.html".format( str(post_num).zfill(4), re.sub( r'[/!:?\-,\']', '', post['title'].strip().lower().replace(' ', '_') ) ) content = post['content'][0]['value'].replace(u"\r\n", u"\n") if prepend_links: content = "<p>Originally posted at <a href='%s'>%s</a>.</p>" % ( post['link'], post['link']) + content print "writing " + fn f = codecs.open(os.path.join("_posts", fn), "w", "utf-8") f.write("---\n") f.write( yaml.safe_dump( yaml_data, default_flow_style=False, allow_unicode=True ).decode("utf-8") ) f.write("---\n") f.write(content) f.close() post_num += 1
Hacking tw2 resource injection (in pyramid)
Feb 11, 2012 | categories: python, toscawidgets, pyramid View CommentsIn #toscawidgets
this morning, zykes- was asking about how to do the
jquery removal hack I wrote about a month back but in Pyramid instead of
TurboGears2. First I'll summarize the problem, then show you our solution.
toscawidgets2 tw2.*
provides lots of handy web ui widgets
including a wrapper around jquery-ui, jqgrid, and lots of fancy data widgets.
One of the problems it solves for you is de-duplicating resources. Say you're
including two fancy jquery-related widgets. Both of them require that
jquery.js
be included on the page. tw2
includes a
piece of middleware that tracks all the resources required by the widgets being
rendered on a given request, reduces that list to a set with no duplicates,
orders it by dependency, and injects it into the
tag.
Usually this is fine, but in some cases you want an exception to the rule.
Say, like in my previous post, you want to include jquery.js yourself manually
and you'd rather not have tw2
stomping all over your javascript
namespace. You could disable tw2
injection of all
resources, but you want all the others included -- just not jquery.
There is no automatic detection and filtration flag implemented in
tw2
and it would be tough to do in the general case.
tw2
can't guarantee that it's own jquery.js and your jquery.js are
the same, or different, or included, or not included, or anything -- it doesn't
even try.
To get tw2
to not do what you don't want, you need to
un-register tw2
's jquery resource from the middleware
yourself (on each request). Previously we came up with a working
hack that does this in the context of a TurboGears2 app. Here's the same
concept applied to a Pyramid app using a Pyramid "tween".
import tw2.core.core import tw2.jquery def remove_jq_factory(handler, registry): """ Remove tw2 jquery_js from tw2's middleware registry. In order to use this, you need to add the following to your myapp/__init__.py file: config.add_tween('myapp.tween.remove_jq_factory') """ def remove_jq_tween(request): # Send the request on through to other tweens and to our app response = handler(request) # Before the response is modified by the tw2 middleware, let's remove # jquery_js from its registry. offending_links = [r.req().link for r in [ tw2.jquery.jquery_js, ]] local = tw2.core.core.request_local() local['resources'] = [ r for r in local.get('resources', list()) if r.link not in offending_links ] return response return remove_jq_tween
Announcing -- 24 hour tw2 bug sprint for PyCon
Feb 07, 2012 | categories: python, toscawidgets View Comments(First published to the toscawidgets-discuss google group)
It came up in IRC the other day that tw2 has been through many, many beta iterations. So many in fact, that a full on tw2 2.0 release is painfully overdue.
That said, there are still plenty of out-standing issues in our issue tracker:
http://bitbucket.org/paj/tw2core
Before we tag and name the 2.0 final product, I'm proposing -- no, announcing -- a 24 hour tw2 sprint the weekend before PyCon. We'll write docs, we'll automate tests, we'll settle the dispatch dispute and wax philosophic.
I invite you to join me Saturday, March 3rd at 18:00:00 UTC through Sunday, March 4th 18:00:00 UTC. Hop into #toscawidgets on freenode or join me in a hangout on google plus. We'll nail every last bug on deck and still have time for a beer.
Yours in widgetry-
- threebean
« Previous Page -- Next Page »