Netsight Internet Solutions – Zope and Plone Consulting, Bristol, UK
Originally from del.icio.us/tag/plone by
Netsight Internet Solutions – Zope and Plone Consulting, Bristol, UK
Originally from del.icio.us/tag/plone by matsh
plope – Advanced Page Templates
Originally from del.icio.us/tag/plone by shimizukawa
plope – Appendix C: Zope Page Templates Reference
Originally from del.icio.us/tag/plone by shimizukawa
plope – Using Zope Page Templates
Originally from del.icio.us/tag/plone by shimizukawa
OPEN SOURCE SPOTED
Open Source — la mont pagnotte familly
Originally from del.icio.us/tag/plone by camusdesbois
CIGNEX – Plone LIVE Book Offer
Originally from del.icio.us/tag/plone by paulmccarthy
Forums — la mont pagnotte familly regorge d’astuces, totoriaux en tout genres
Forums — la mont pagnotte familly
Originally from del.icio.us/tag/plone by camusdesbois
Plone Visual — nagosui.org
Originally from del.icio.us/tag/plone by o0gasawa
Plone products, Plone content management software directory
Originally from del.icio.us/tag/plone by wx672
In followup to my previous post on form generators, I thought I’d
note some implementation details of the pipeline approach I advocate
there.
So, one thing I proposed is that we have some notion of requiring some
Javascript or CSS from within an HTML element. Let’s say it looks
like: <input type="date" js-require="DateSelect">. There’s a
function find_library_url(name, type), called in this case like
find_library_url('DateSelect', 'js'), and it returns something
like "http://localhost:8080/static/js/DateSelect.js" (we won’t
worry about how it is implemented).
Here’s how you could do this transformation using lxml:
from lxml import etree
from urlparse import urljoin
def resolve_js_require(doc, doc_url, find_library_url):
if isinstance(doc, basestring):
doc = etree.HTML(doc)
script_hrefs = set()
for el in doc.xpath('//*[@js-require]'):
name = el.attrib['js-require']
del el.attrib['js-require']
url = find_library_url(name, 'js')
script_hrefs.add(url)
# Check that we aren't duplicating any explicit <script> tags:
for el in doc.xpath('//script[@src]'):
url = urljoin(doc_url, el.attrib['src'])
if url in script_hrefs:
script_hrefs.remove(url)
try:
head = doc.xpath('//head')[0]
except IndexError:
# No <head>
head = etree.Element('head')
doc.insert(0, head)
# Add in the <script> tags:
for url in script_hrefs:
el = etree.Element('script')
el.attrib['type'] = 'text/javascript'
el.attrib['src'] = url
head.append(el)
return doc
Extending this for CSS is hopefully obvious. You can see the code
with an explanatory doctest in my recipe repository.
Hopefully this example seems easy enough that people will see the
benefit of the technique. lxml is a great library, and would be great
for cleaning up the implementation of things like the
HTMLParser-based monstrosity of htmlfill. (Note: do not use
HTMLParser, it’s not
worth the effort.)
Ian Bicking: lxml Transformations
Originally from Planet Plone