News aggregator

Pydev

del.icio.us Python bookmarks - 9 hours 28 min ago
Categories: Python News

ZendCasts.com: Creating RSS & Atom Feeds with Zend_Feed

PHP Developer - 10 hours 14 min ago

New on ZendCasts.com this screencast helps you use the Zend Framework's Zend_Feed component to create simple RSS and Atom feeds for your application.

The screencast shows you how to create a basic controller with information for a sample blog post (title, date creates, content, etc) and a simple method to create default posts. A second controller is made to handle the feed creation and two actions are created - one for RSS and the other for Atom. The posts are then parsed and pushed out to views for displaying as feeds.

The site has more great screencasts where this came from so check out their screencasts section for ones on other topics like ZendX_JQuery, working with Zend_Log, and validation with Zend_Validate.

Categories: PHP News

Padraic Brady's Blog: Zend Framework Proposal: ZendHtmlFilter (HTML Sanitisation And Manipulation)

PHP Developer - 11 hours 29 min ago

Padraic Brady has a new post on his blog talking about a new proposal he's made for the Zend Framework about filtering and sanitizing HTML content.

For a while now, I've been keen to build a HTML Sanitisation solution for PHP. Where else would I end up putting it other than in Zend Framework? As I've explored in past articles [1] [2], HTML Sanitisation in PHP is a very inconsistent practice. [...] Isn't it possible to create a sanitiser that is both secure by default and performs well?

He talks about his Wibble tool that's become the base of his idea for a filtering feature built into the framework. It mainly uses the PHP DOM functionality and HTML Tidy for speed and parsing and was benchmarked as performing better than the HTMLPurifier tool. If you're interested, check out his proposal for its inclusion in the Zend Framework 2.0.

Categories: PHP News

Derick Rethans' Blog: Collecting Garbage: Cleaning Up

PHP Developer - 11 hours 45 min ago

Derick Rethans has continued his series on garbage collection in the PHP internals with this second post of the series with a special look at circular references. You can find the first part here.

In this second part of the three part column on the new garbage collecting mechanism in PHP 5.3, we'll dive into a solution to the problem with circular references. If we look quickly back, we found that by using code like the [first example], an in-request memory leak is created.

He goes on to briefly describe the synchronous algorithm (including a few more helpful graphs to show the flow) and how that has worked its way into the PHP garbage collection methods. He also points out that this collection can be turned off and on via the gc_enable and gc_disable functions. Keep an eye out for the next part of the series where he gets into more detail on how this is all integrated into PHP.

Categories: PHP News

Enthought: September Webinar: How do I… solve differential equations with Python?

Planet Python - 11 hours 56 min ago
This Friday, Warren Weckesser will host the first of three webinars in a series on solving differential equations in Python.  We will take a close look at the two tools available for solving ordinary  differential equations in SciPy: the “odeint” function and the “ode” class.  Two examples will be discussed: (1) the famous Lorenz equations that exhibit chaos, and (2) [...]
Categories: Python News

CakeFest 2010: Thats a wrap

PHP Developer - Tue, 2010-09-07 23:16

For those that didn't get to attend this year's CakeFest 2010, The Bakery has put together this summary of some of the things that happened and the presentations that were given.

CakeFest 2010 has come to a close. After 4 days of jam-packed talks, workshops, lightning talks and social outings, we're sad to see it finish. I'd like to thank the community for their ongoing and ever increasing support. Both for the community and for the CakeFest conference itself. Without the passionate community around CakePHP, we couldn't achieve events like CakeFest 2010.

They mention some of the sponsors that made the event possible - like Microsoft, GitHub and ActiveState - as well as some photos from the event and links to twelve of the presentations that were given over the four day event.

Categories: PHP News

Zach Beane: LibCL returns

Planet LISP - Tue, 2010-09-07 21:57

Daniel Herring is reviving development of his LibCL project. Here's the beginning of his announcement to libcl-devel: Hi all,

It has been several months since LibCL saw significant progress. This was a period of small experiments, reflection, and numerous "real-world" distractions.

This past week, I had a bit of free time; and recent rumors of quicklisp focused the need to sieze the moment and put thoughts into action. [Thanks Zach. Honestly, with everything in my head, I couldn't have handled volunteers anyway.]

Here's the result: a revised plan for LibCL, and a skeleton code base ready for contributors.

You can read the rest here.

Categories: LISP News

Ibuildings techPortal: DPCRadio: Web services for consumer devices

PHP Developer - Tue, 2010-09-07 21:48

On the Ibuildings techPortal there's a new post with the latest episode in their DPCRadio series (as recorded at this past Dutch PHP Conference) - Melanie Rhianna Lewis' talk on web services and consumer devices.

A web service is an API provided by a site that allows a remote application to access data and use functionality without having to 'act like a web browser'. [...] The talk will describe how a web service targeted at consumer devices can be implemented. It will look at the different methods of calling remote functionality such as SOAP, XML-RPC, JSON and restful services. It will also consider the limitations of consumer devices, memory restrictions, communications bandwidth restrictions, and so on that have to be considered when designing a web service aimed at consumer devices. Finally it will have a brief look at how to make a service secure.

You can find the slides for the session here and you can either listen to the episode through the in-page player or buy downloading the mp3 directly.

Categories: PHP News

Fabio Zadrozny: Pydev 1.6.2 released

Planet Python - Tue, 2010-09-07 15:58
The latest Pydev version is out.

The Django Templates Editor is the major thing in this release, supporting html files with html, css and javascript.

The current Pydev is now also integrated in Aptana Studio 3, so, a full download where Pydev (with the Django templates editor) is already pre-installed is available at: http://aptana.com/products/studio3/download.

Also noteworthy is that the Python 2.7 grammar is fully supported (and a bunch of bug fixes have been made available).
Categories: Python News

Vinay Sajip: Using logging with multiprocessing

Planet Python - Tue, 2010-09-07 13:37
There can be a few gotchas when using logging with the multiprocessing module. For example, if you want to write rotated log files from your multi-process application, a naïve implementation might just configure a RotatingFileHandler directly. This could lead to multiple processes trying to write to the file concurrently, which will almost certainly lead to the log getting corrupted because of interleaved writes by different processes.

Note that logging to the same rotated files from multiple threads in a single-process application would be fine; the logging package uses threading locks to ensure that no log corruption occurs. There's no equivalent cross-platform synhronisation for processes in the stdlib, however; that's why you can get corruption with multi-process applications.

To circumvent the problem scenario, you can use a multiprocessing Queue and a listener process which listens for logging events sent to the queue. When it sees these events, it pops them off the queue and processes them; as it's the only process which will write to files directly, there are no contention issues which lead to corruption. The other processes just need to configure a QueueHandler, which will send logging events via the queue to the listener process.

The plan is to add QueueHandler to Python 3.2, but the implementation here is simple enough and should be copy-pastable into your own code for use with earlier Python versions.

The script is fairly well annotated so I'll say no more.

#!/usr/bin/env python
# Copyright (C) 2010 Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
"""
An example script showing how to use logging with multiprocessing.

The basic strategy is to set up a listener process which can have any logging
configuration you want - in this example, writing to rotated log files. Because
only the listener process writes to the log files, you don't have file
corruption caused by multiple processes trying to write to the file.

The listener process is initialised with a queue, and waits for logging events

(LogRecords) to appear in the queue. When they do, they are processed according
to whatever logging configuration is in effect for the listener process.

Other processes can delegate all logging to the listener process. They can have
a much simpler logging configuration: just one handler, a QueueHandler, needs
to be added to the root logger. Other loggers in the configuration can be set
up with levels and filters to achieve the logging verbosity you need.

A QueueHandler processes events by sending them to the multiprocessing queue
that it's initialised with.

In this demo, there are some worker processes which just log some test messages
and then exit.

This script was tested on Ubuntu Jaunty and Windows 7.

Copyright (C) 2010 Vinay Sajip. All Rights Reserved.
"""
# You'll need these imports in your own code
import logging
import logging.handlers
import multiprocessing

# Next two import lines for this demo only
from random import choice, random
import time

class QueueHandler(logging.Handler):
"""
This is a logging handler which sends events to a multiprocessing queue.

The plan is to add it to Python 3.2, but this can be copy pasted into
user code for use with earlier Python versions.
"""

def __init__(self, queue):
"""
Initialise an instance, using the passed queue.
"""
logging.Handler.__init__(self)
self.queue = queue

def emit(self, record):
"""
Emit a record.

Writes the LogRecord to the queue.
"""
try:
ei = record.exc_info
if ei:
dummy = self.format(record) # just to get traceback text into record.exc_text
record.exc_info = None # not needed any more
self.queue.put_nowait(record)
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
#
# Because you'll want to define the logging configurations for listener and workers, the
# listener and worker process functions take a configurer parameter which is a callable
# for configuring logging for that process. These functions are also passed the queue,
# which they use for communication.
#
# In practice, you can configure the listener however you want, but note that in this
# simple example, the listener does not apply level or filter logic to received records.
# In practice, you would probably want to do ths logic in the worker processes, to avoid
# sending events which would be filtered out between processes.
#
# The size of the rotated files is made small so you can see the results easily.
def listener_configurer():
root = logging.getLogger()
h = logging.handlers.RotatingFileHandler('/tmp/mptest.log', 'a', 300, 10)
f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s')
h.setFormatter(f)
root.addHandler(h)

# This is the listener process top-level loop: wait for logging events
# (LogRecords)on the queue and handle them, quit when you get a None for a
# LogRecord.
def listener_process(queue, configurer):
configurer()
while True:
try:
record = queue.get()
if record is None: # We send this as a sentinel to tell the listener to quit.
break
logger = logging.getLogger(record.name)
logger.handle(record) # No level or filter logic applied - just do it!
except (KeyboardInterrupt, SystemExit):
raise
except:
import sys, traceback
print >> sys.stderr, 'Whoops! Problem:'
traceback.print_exc(file=sys.stderr)

# Arrays used for random selections in this demo

LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING,
logging.ERROR, logging.CRITICAL]

LOGGERS = ['a.b.c', 'd.e.f']

MESSAGES = [
'Random message #1',
'Random message #2',
'Random message #3',
]

# The worker configuration is done at the start of the worker process run.
# Note that on Windows you can't rely on fork semantics, so each process
# will run the logging configuration code when it starts.
def worker_configurer(queue):
h = QueueHandler(queue) # Just the one handler needed
root = logging.getLogger()
root.addHandler(h)
root.setLevel(logging.DEBUG) # send all messages, for demo; no other level or filter logic applied.

# This is the worker process top-level loop, which just logs ten events with
# random intervening delays before terminating.
# The print messages are just so you know it's doing something!
def worker_process(queue, configurer):
configurer(queue)
name = multiprocessing.current_process().name
print('Worker started: %s' % name)
for i in range(10):
time.sleep(random())
logger = logging.getLogger(choice(LOGGERS))
level = choice(LEVELS)
message = choice(MESSAGES)
logger.log(level, message)
print('Worker finished: %s' % name)

# Here's where the demo gets orchestrated. Create the queue, create and start
# the listener, create ten workers and start them, wait for them to finish,
# then send a None to the queue to tell the listener to finish.
def main():
queue = multiprocessing.Queue(-1)
listener = multiprocessing.Process(target=listener_process,
args=(queue, listener_configurer))
listener.start()
workers = []
for i in range(10):
worker = multiprocessing.Process(target=worker_process,
args=(queue, worker_configurer))
workers.append(worker)
worker.start()
for w in workers:
w.join()
queue.put_nowait(None)
listener.join()

if __name__ == '__main__':
main()
Categories: Python News

mtrack: custom fields, snippets - Wez Furlong

Planet PHP - Tue, 2010-09-07 09:02

It's time for another mtrack update; here's what's new:

  • Add "Snippets" feature; works like pastebin, but allows for comments to be supplied in wiki syntax in addition to the code or text snippet that you're pasting
  • Add Custom Field support. This is implemented by modifying the schema (custom fields always have an "x_" prefix).
  • Improvements to the "custom ticket query" screens, including ability to select which columns (including custom fields) are included in the results
  • Fix an issue with sorting the "Remaining" time column
  • Fix some IE compatibility issues
  • ...
Continue reading on wezfurlong.org
Categories: PHP News
Syndicate content