Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Phillip B Oldham
Is it possible to automatically run an operation on a object's
attribute when reading? For instance, if I have the following:

class Item(object):
  tags = ['default','item']

item = Item()

desc = item.tags

When I'm reading the item.tags, I'd like to automagically have the
value converted to a string, eg: "default item". I know I could write
a getter to do this for me, but I'd like to avoid that if possible on
this occasion.

Any help would be great! Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Phillip B Oldham
On Mon, Jan 19, 2009 at 12:15 PM, Chris Rebert  wrote:
> Assuming I'm interpreting you correctly (you're going to have to use
> something like a getter):

Thanks, but I'm looking for a way to do it *without* using a getter as
I don't have easy access to the class (its being generated for me
elsewhere). Essentially I'd like to overwrite (if possible) the
default behavior when returning certain attributes on certain objects.
--
http://mail.python.org/mailman/listinfo/python-list


ORM recommendation when using "live"/predefined DB?

2009-01-28 Thread Phillip B Oldham
We're trying to move to Python for a few parts of our application. We
have a live database, which has been modeled for a specific use, and
has other code connecting to and working with it.

We'd like to reduce the amount of work we have to do in terms of
keeping our python code up-to-date with schema changes, and we don't
want python objects to dictate how the database should be structured.

Can you recommend an ORM (or similar) package to look into?
--
http://mail.python.org/mailman/listinfo/python-list


Convert date/time to unix timestamp?

2009-02-10 Thread Phillip B Oldham
Is there a simple way to set a date/time and convert it to a unix
timestamp? After some googling I found the following:

t = datetime.time(7,0,0)
starttime = time.mktime(t.timetuple())+1e-6*t.microsecond

That seems like very long-winded. Is there an easier way? I've read
the docs on the datetime and time modules, but nothing's jumping out
at me.
--
http://mail.python.org/mailman/listinfo/python-list


Will Python 3 be "stackless"?

2008-10-23 Thread Phillip B Oldham
Will Python 3 be "stackless"? Or, rather, will it have any features
similar to stackless' microthreads and channels?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Will Python 3 be "stackless"?

2008-10-23 Thread Phillip B Oldham
On Thu, Oct 23, 2008 at 9:20 PM, Chris Rebert <[EMAIL PROTECTED]> wrote:
> No, it will definitely not.

>From your statement (and I'm terribly sorry if I've taken it out of
context) it would seem that such features are frowned-upon. Is this
correct? And if so, why?

-- 
Phillip B Oldham
[EMAIL PROTECTED]
+44 (0) 7525 01 09 01
--
http://mail.python.org/mailman/listinfo/python-list


Are there any FOSS Python Single-Sign-on Servers?

2008-11-11 Thread Phillip B Oldham
Are there any FOSS Python Single-Sign-on Servers?

We're looking to centralise the sign-on for our numerous "internal"
webapps (across multiple servers, languages, and domains) to speed
user management and application development.

I've searched around but can only seem to find OpenID servers, which
will probably be too "open" for our needs. Coding one up would
possibly take more time than we have, and we'd prefer something
maintained externally to cut dev costs.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any FOSS Python Single-Sign-on Servers?

2008-11-11 Thread Phillip B Oldham
On Nov 11, 9:24 pm, paul <[EMAIL PROTECTED]> wrote:
> Phillip B Oldham schrieb:> Are there any FOSS Python Single-Sign-on Servers?
>
> [snip]
>
> > I've searched around but can only seem to find OpenID servers, which
> > will probably be too "open" for our needs.
>
> So if it is not OpenID, which protocol are you going to implement?

In theory, we could use an OpenID server: our staff could register
with something like MyOpenID, register with each of our individual
webapps, and then gain access with a single sign-on. However, its not
really getting round the problem we have: we need to give our staff
access to all of our apps in one go, give them one place to sign on,
and have the ability to disable their account at short notice. Doing
this with openid would mean we have *no* access to the user account
and therefore would still have the overhead of having to disable
accounts with each webapp we provide. It also opens-up a security
threat in that anyone could register to our "internal" apps with an
OpenID account. Which is bad.

Essentially, we need a SSO server with which we would register our
*webapps* and then create user account, specifying which webapps that
user has access to, and at what level. Essentially something like
OpenSSO but python-based.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any FOSS Python Single-Sign-on Servers?

2008-11-11 Thread Phillip B Oldham
On Nov 11, 11:00 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Phillip B Oldham <[EMAIL PROTECTED]> writes:
>
> > I've searched around but can only seem to find OpenID servers, which
> > will probably be too "open" for our needs.
>
> Please, if you're going to be coding new systems, use established,
> standard, open protocols with actively maintained implementations. For
> single sign-on. OpenID is the one to choose.

I think maybe there's some misunderstanding. The protocol isn't the
issue; I'm happy to use whatever (HTTP, LDAP, SOAP, XMPP, etc). The
issue is that OpenID, by its name, is open. We don't want to allow
anyone with an openid account to register with our webapps, we simply
want to centralise registration and sign-on for our employees.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any FOSS Python Single-Sign-on Servers?

2008-11-11 Thread Phillip B Oldham
On Nov 11, 11:48 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Phillip B Oldham <[EMAIL PROTECTED]> writes:
>
> > I think maybe there's some misunderstanding. The protocol isn't the
> > issue; I'm happy to use whatever (HTTP, LDAP, SOAP, XMPP, etc). The
> > issue is that OpenID, by its name, is open. We don't want to allow
> > anyone with an openid account to register with our webapps
>
> Then don't do that. The OpenID protocol says nothing whatsoever about
> *which* OpenIDs your service will accept.
>
> > we simply want to centralise registration and sign-on for our
> > employees.
>
> Then you should reject any attempt to authenticate with an OpenID that
> you don't accept.

Even with using OpenID in this way, it still doesn't resolve the issue
we have: quick user registration & sign-on. The user will need to
register an OpenID account then register with each service/webapp we
provide. What we're looking for is the reverse: registering our
webapps/services with a SSO service then (upon starting with the
company) registering our new staff members with this service and
specifying which webapps they have access to and what privileges they
have with those apps.

Please understand I have nothing against OpenID; I use it all the time
and think its a great solution. I just don't think its a great
solution for our particular problem. Keep in mind that OpenID is user-
centric. While I don't mind registering my openid account with the
various sites I use, our staff members will have a nightmare spending
their first day initially trying to understand OpenID, then
registering with each of our services, then waiting while the support
team review their registrations and give them relevant permissions.

Since the support team will have to do this, along-side setting up
email accounts, it makes sense for them to have one interface to grant
access & permissions to the various webapps and for our staff to have
one place to sign-on. Since each staff-member already has a unique
email address it again makes sense to use this rather than an openid-
url which could be confusing.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any FOSS Python Single-Sign-on Servers?

2008-11-12 Thread Phillip B Oldham
On Nov 12, 1:12 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Phillip B Oldham <[EMAIL PROTECTED]> writes:
> OpenID is a means of *authentication*, it doesn't mandate any
> particular system of registration or account creation. You presumably
> already have solutions for those; use them, but de-couple the
> authentication process from those systems by using OpenID.

Ah, I see!

> If you write the web application to accept OpenIDs only if they match
> a specific pattern, you achieve the same effect; and you then have the
> option to later choose to allow some other OpenIDs without needing to
> change the authentication protocol.

I think I have some misconceptions about OpenID then.

So, would it be possible to use the user's email address as their
OpenID username/token?

> OpenID is a solution for transporting authentication data, and
> managing the data in a central location under your control. It does
> well at that, because the protocol is mature (solving the transport
> problem) and there are many supported free-software implementations
> for providers and relying parties (allowing you to solve your specific
> centralisation needs).

It's all starting to "click" now. Thanks for being persistent! ;)

> You later revealed that you *also* want a solution for transporting
> authorisation data, and managing it in a central manner. This is a
> separate issue, but OAuth is a similar solution: it is a standard
> transport protocol, with many free-software implementations for both
> ends of the conversation.

OAuth was also something I came across, but discounted as possibly
being too "open".

> Your IT support team should be the ones setting up people's account
> information, and the systems should be automatically providing OpenIDs
> and OAuth profiles for any or all accounts as specified.
> [snip]
> Right, so you should be providing these OpenIDs and OAuth profiles as
> part of whatever other data collection and account set-up needs to be
> done.

Sounds just like what I'm looking for.

So... are there any good OpenID/OAuth servers written in python?
--
http://mail.python.org/mailman/listinfo/python-list


Python shell scripting and errors

2009-02-23 Thread Phillip B Oldham
I've got a python script running as a daemon (using someone else's
daemon module). It runs fine for a while, but will occasionally balk
and die. Since its running in the background, I'm getting no error
from it.

What's the best way to capture the output into a file for later review?
--
http://mail.python.org/mailman/listinfo/python-list


Are there any python libraries/packages like Juicer/Sprockets/bundle_fu?

2009-03-04 Thread Phillip B Oldham
Hi all.

Just wondering whether there are any libraries for python like ruby's
Juicer[1], Sprocets[2], or bundle_fu[3]?

Thanks!

[1] http://www.cjohansen.no/en/ruby/juicer_a_css_and_javascript_packaging_tool
[2] http://getsprockets.com/
[3] http://code.google.com/p/bundle-fu/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any python libraries/packages like Juicer/Sprockets/bundle_fu?

2009-03-09 Thread Phillip B Oldham
On Mar 4, 7:23 pm, Jason Scheirer  wrote:
> Do you have a reason for needing the same thing implemented in Python,
> or are the options in Ruby enough?

I'd rather have things in Python so I don't have to worry about having
Ruby available on the host machines we're using.

I'll take a look at those packages, thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Please help me grok: webserver > python

2009-04-21 Thread Phillip B Oldham
I'm having trouble grok'ing how to get python talking through a
webserver. I've got a lot of experience working with nginx+php-fcgi
(via a unix socket) and I'd like to know what would be the bare
minimum to get python talking in the same way.

Now, I've looked at modules like CherryPy but they're all a little
high level and talk via http. I'd like to know how to mimic the php
setup I'm used to; I've no specific goal other than to become
aquainted with the python environment.

Any examples would be great!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Essential tools for Python development

2009-04-22 Thread Phillip B Oldham
On Apr 22, 5:00 am, Ben Finney  wrote:
> [snip] and code each module so that the
> behaviour is easily introspected and tested from outside the module. If
> I'm not able to easily introspect the code at an interactive prompt,
> that's a clear sign that the code interface is poorly designed. So I fix
> that first.

Could you give a small example of this approach?
--
http://mail.python.org/mailman/listinfo/python-list


Options for creating a statistics screen on a Mac with Python?

2009-05-16 Thread Phillip B Oldham
I've come into possession of a mac mini and a large LCD tv at the
office. I'd like to set it up in the corner to pull statistics from
our various servers (load, uptimes, etc) and display them in a
graphical format, full-screen, with a reasonable refresh rate (say
every 30 seconds). There will be quite a few statistics, and we'll be
adding new servers over time, and since there won't be the option to
scroll a full-screen web-page won't work.

What then would be my options to create a full-screen display of
statistics, and an attractive graphical way, using Python on OS X?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Options for creating a statistics screen on a Mac with Python?

2009-05-16 Thread Phillip B Oldham
On May 16, 2:15 pm, "Diez B. Roggisch"  wrote:
> matplotlib should serve you well.

Thanks, I'll check that out.

> Or you use some web-based solution with a javascript-based chart library.

I'd rather stay away from web-based solutions; since this is going to
be running 24/7 and has a fixed a screen size. I'd prefer something
that has few dependencies, if possible hooking into the OS X platform
for graphics.
-- 
http://mail.python.org/mailman/listinfo/python-list


Advice for a python newbie on parsing whois records?

2008-06-10 Thread Phillip B Oldham
Hi. I'm stretching my boundaries in programming with a little python
shell-script which is going to loop through a list of domain names,
grab the whois record, parse it, and put the results into a csv.

I've got the results coming back fine, but since I have *no*
experience with python I'm wondering what would be the preferred
"pythonic" way of parsing the whois string into a csv record.

Tips/thoughts/examples more than welcome!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Advice for a python newbie on parsing whois records?

2008-06-11 Thread Phillip B Oldham
On Jun 10, 8:21 pm, Miki <[EMAIL PROTECTED]> wrote:
> Hello,
>
> > Hi. I'm stretching my boundaries in programming with a little python
> > shell-script which is going to loop through a list of domain names,
> > grab the whois record, parse it, and put the results into a csv.
>
> > I've got the results coming back fine, but since I have *no*
> > experience with python I'm wondering what would be the preferred
> > "pythonic" way of parsing the whois string into a csv record.
>
> > Tips/thoughts/examples more than welcome!
>
> from os import popen
> import re
>
> find_record = re.compile("\s+([^:]+): (.*)\s*").match
> for line in popen("whois google.com"):
> match = find_record(line)
> if not match:
> continue
> print "%s --> %s" % (match.groups()[0], match.groups()[1])
>
> HTH,
> --
> Miki <[EMAIL PROTECTED]>http://pythonwise.blogspot.com

OK, here's what I've got so far. I'm treating this as a learning
exercise, so the resulting file isn't so important as understanding
and thinking in python (although I believe the results are adequate
for my needs). I'd appreciate the community's comments as this is my
*first* attempt at python and has taken me a couple of hours
(including googling).

#!/usr/bin/env python
import subprocess
import re

src = open('./domains.txt')

dest = open('./whois.csv', 'w');

def trim( txt ):
x = []
for line in txt.split("\n"):
if line.strip() == "":
continue
if line.strip().startswith('WHOIS'):
continue
if line.strip().startswith('>>>'):
continue
if line.strip().startswith('%'):
continue
if line.startswith("--"):
return ''.join(x)
x.append(" "+line)
return "\n".join(x)

def clean( txt ):
x = []
isok = re.compile("^\s?([^:]+): ").match
for line in txt.split("\n"):
match = isok(line)
if not match:
continue
x.append(line)
return "\n".join(x);

def clean_co_uk( rec ):
rec = rec.replace('Company number:', 'Company number -')
rec = rec.replace("\n\n", "\n")
rec = rec.replace("\n", "")
rec = rec.replace(": ", ":\n")
rec = re.sub("([^(][a-zA-Z']+\s?[a-zA-Z]*:\n)", "\n\g<0>", rec)
rec = rec.replace(":\n", ": ")
rec = re.sub("^[ ]+\n", "", rec)
return rec

def clean_net( rec ):
rec = rec.replace("\n\n", "\n")
rec = rec.replace("\n", "")
rec = rec.replace(": ", ":\n")
rec = re.sub("([a-zA-Z']+\s?[a-zA-Z]*:\n)", "\n\g<0>", rec)
rec = rec.replace(":\n", ": ")
return rec

def clean_info( rec ):
x = []
for line in rec.split("\n"):
x.append(re.sub("^([^:]+):", "\g<0> ", line))
return "\n".join(x)

def record(domain, record):

## Records are as follows: [ domain, registrant, registrant's address
registrar, type, registered, renewal, updated name servers ]
details = ['','','','','','','','','']
for k, v in record.items():
try:
details[0] = domain.lower()
result = {
"registrant": lambda: 1,
"registrant name": lambda: 1,
"registrant type": lambda: 4,
"registrant's address": lambda: 2,
"registrant address1": lambda: 2,
"registrar": lambda: 3,
"sponsoring registrar": lambda: 3,
"registered on": lambda: 5,
"registered": lambda: 5,
"domain registeration date": lambda: 5,
"renewal date": lambda: 6,
"last updated": lambda: 7,
"domain last updated date": lambda: 7,
"name servers": lambda: 8,
"name server": lambda: 8,
"nameservers": lambda: 8,
"updated date": lambda: 7,
"creation date": lambda: 5,
"expiration date": lambda: 6,
"domain expiration date": lambda: 6,
"administrative contact": lambda: 2
}[k.lower()]()
if v != '':
details[result] = v
except:
continue

dest.write('|'.join(details)+"\n")

## Loop through domains
for domain in src:

domain = domain.strip()

if domain == '':
continue

rec

Comments on my first script?

2008-06-12 Thread Phillip B Oldham
I'm keen on learning python, with a heavy lean on doing things the
"pythonic" way, so threw the following script together in a few hours
as a first-attempt in programming python.

I'd like the community's thoughts/comments on what I've done;
improvements I can make, "don'ts" I should be avoiding, etc. I'm not
so much bothered about the resulting data - for the moment it meets my
needs. But any comment is welcome!

#!/usr/bin/env python
## Open a file containing a list of domains (1 per line),
## request and parse it's whois record and push to a csv
## file.

import subprocess
import re

src = open('./domains.txt')

dest = open('./whois.csv', 'w');

sep = "|"
headers = ["Domain","Registrant","Registrant's
Address","Registrar","Registrant Type","Date Registered","Renewal
Date","Last Updated","Name Servers"]

dest.write(sep.join(headers)+"\n")

def trim( txt ):
x = []
for line in txt.split("\n"):
if line.strip() == "":
continue
if line.strip().startswith('WHOIS'):
continue
if line.strip().startswith('>>>'):
continue
if line.strip().startswith('%'):
continue
if line.startswith("--"):
return ''.join(x)
x.append(" "+line)
return "\n".join(x)

def clean( txt ):
x = []
isok = re.compile("^\s?([^:]+): ").match
for line in txt.split("\n"):
match = isok(line)
if not match:
continue
x.append(line)
return "\n".join(x);

def clean_co_uk( rec ):
rec = rec.replace('Company number:', 'Company number -')
rec = rec.replace("\n\n", "\n")
rec = rec.replace("\n", "")
rec = rec.replace(": ", ":\n")
rec = re.sub("([^(][a-zA-Z']+\s?[a-zA-Z]*:\n)", "\n\g<0>", rec)
rec = rec.replace(":\n", ": ")
rec = re.sub("^[ ]+\n", "", rec)
return rec

def clean_net( rec ):
rec = rec.replace("\n\n", "\n")
rec = rec.replace("\n", "")
rec = rec.replace(": ", ":\n")
rec = re.sub("([a-zA-Z']+\s?[a-zA-Z]*:\n)", "\n\g<0>", rec)
rec = rec.replace(":\n", ": ")
return rec

def clean_info( rec ):
x = []
for line in rec.split("\n"):
x.append(re.sub("^([^:]+):", "\g<0> ", line))
return "\n".join(x)

def record(domain, record):
details = ['','','','','','','','','']
for k, v in record.items():
try:
details[0] = domain.lower()
result = {
"registrant": lambda: 1,
"registrant name": lambda: 1,
"registrant type": lambda: 4,
"registrant's address": lambda: 2,
"registrant address1": lambda: 2,
"registrar": lambda: 3,
"sponsoring registrar": lambda: 3,
"registered on": lambda: 5,
"registered": lambda: 5,
"domain registeration date": lambda: 5,
"renewal date": lambda: 6,
"last updated": lambda: 7,
"domain last updated date": lambda: 7,
"name servers": lambda: 8,
"name server": lambda: 8,
"nameservers": lambda: 8,
"updated date": lambda: 7,
"creation date": lambda: 5,
"expiration date": lambda: 6,
"domain expiration date": lambda: 6,
"administrative contact": lambda: 2
}[k.lower()]()
if v != '':
details[result] = v
except:
continue

dest.write(sep.join(details)+"\n")

## Loop through domains
for domain in src:

domain = domain.strip()

if domain == '':
continue

rec = subprocess.Popen(["whois",domain],
stdout=subprocess.PIPE).communicate()[0]

if rec.startswith("No whois server") == True:
continue

if rec.startswith("This TLD has no whois server") == True:
continue

rec = trim(rec)

if domain.endswith(".net"):
rec = clean_net(rec)

if domain.endswith(".com"):
rec = clean_net(rec)

if domain.endswith(".tv"):
rec = clean_net(rec)

if domain.endswith(".co.uk"):
rec = clean_co_uk(rec)

if domain.endswith(".info"):
   

Re: Comments on my first script?

2008-06-13 Thread Phillip B Oldham
Thanks guys. Those comments are really helpful. The odd semi-colon is
my PHP background. Will probably be a hard habbit to break, that
one! ;) If I do accidentally drop a semi-colon at the end of the line,
will that cause any weird errors?

Also, Chris, can you explain this:
a, b = line.split(': ')[:2]

I understand the first section, but I've not seen [:2] before.
--
http://mail.python.org/mailman/listinfo/python-list


Functionality similar to PHP's SimpleXML?

2008-06-13 Thread Phillip B Oldham
I'm sure I'll soon figure out how to find these things out for myself,
but I'd like to get the community's advice on something.

I'm going to throw together a quick project over the weekend: a
spider. I want to scan a website for certain elements.

I come from a PHP background, so normally I'd:
 - throw together a quick REST script to handle http request/responses
 - load the pages into a simplexml object and
 - run an xpath over the dom to find the nodes I need to test

One of the benefits of PHP's dom implementation is that you can easily
load both XML and HTML4 documents - the HTML gets normalised to XML
during the import.

So, my questions are:

Is there a python module to easily handle http request/responses?

Is there a python dom module that works similar to php's when working
with older html?

What python module would I use to apply an XPath expression over a dom
and return the results?

--
http://mail.python.org/mailman/listinfo/python-list


Making HEAD/PUT/DELETE requests with urllib2?

2008-06-13 Thread Phillip B Oldham
In my attempt to learn python in a weekend, I've fallen foul at line
10 of my second scripting attempt. Basically I'm writing a simple
spider, but currently I'm unable to find any documentation on making
HEAD requests using the urllib2 library to test whether a file exists
on a remote webserver.

I've checked the docs on urllib2 from docs.python.org, and unless I'm
missing something there doesn't seem to be a way to do *any* request
other than a GET and POST.

Surely this can't be correct? If so, we're all going to have a hell of
a time creating RESTful web apps.

Any help on the matter would be greatly appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Making HEAD/PUT/DELETE requests with urllib2?

2008-06-13 Thread Phillip B Oldham
Thanks for the info. That's working like a charm. Looks as though I'll
be able to handle all request types with that object.

I got a little worried then that the python dev's had missed something
truly important!
--
http://mail.python.org/mailman/listinfo/python-list


Best way to make a number of tests against an object('s attributes) with absence of switch statement?

2008-06-13 Thread Phillip B Oldham
What would be the optimal/pythonic way to subject an object to a
number of tests (based on the object's attributes) and redirect
program flow?

Say I had the following:

pets[0] = {'name': 'fluffy', 'species': 'cat', 'size': 'small'}
pets[1] = {'name': 'bruno', 'species': 'snake', 'size': 'small'}
pets[2] = {'name': 'rex', 'species': 'dog', 'size': 'large'}

What I'd like to do is loop through 'pets', and test each object. Some
of the tests I'd like to perform are:

Is the size 'small' and species not 'dog'?
Is the species 'cat' and name 'fluffy'?
Is the species not 'dog' or 'cat'?

In PHP I'd use a switch statement similar to the following:

foreach( $pets as $pet) {
switch(true) {
case ( $pet['size'] === 'small' && $pet['species'] !== 'dog' ):
// do something
break;
// etc...
}
}

Now, I understand from a bit of googling that python doesn't have a
switch statement, and because of this people rely on python's
polymorphism. Thats great, but I've yet to come across a decent
example which make a "click".

Any thoughts on how to proceed?
--
http://mail.python.org/mailman/listinfo/python-list


FOSS projects exhibiting clean/good OOP?

2008-07-09 Thread Phillip B Oldham
I'm wondering whether anyone can offer suggestions on FOSS projects/
apps which exhibit solid OO principles, clean code, good inline
documentation, and sound design principles?

I'm devoting some time to reviewing other people's code to advance my
skills. Its good to review bad code (of which I have more than enough
examples) as well as good, but I'm lacking in finding good examples.

Projects of varying sizes would be great.
--
http://mail.python.org/mailman/listinfo/python-list


Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Phillip B Oldham
On Jul 9, 9:26 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> This is somewhat subjective... Some would say that Python's object
> model is fundamentally broken and crappy (not MHO, needless to say)
> that Python +  "solid OO principles" is antinomic !-)

Really? Would you happen to be able to provide any further information
on that?
--
http://mail.python.org/mailman/listinfo/python-list


Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Phillip B Oldham
Thanks all - lots to go through there! :D

I'd heard previously that Trac was a nice example, or rather its core
was, but I'd also heard that there were lots of problems with it and
that they were redeveloping it from scratch?
--
http://mail.python.org/mailman/listinfo/python-list


Framework recommendations for web service?

2008-07-16 Thread Phillip B Oldham
We're looking at the next phase of development for our webapp, and the
main focus will be to move the core from the app to a web service so
other systems can use the data we've gathered (we're thinking along
the lines of the XML API of Highrise from 37Signals).

Its possible that we'll extend the service to allow access via vanilla
XML, JSON, and YAML at some point, however we've decided to use
Facebook's Thrift for connectivity initially to support as many techs
as possible and also because our web interface for the app is written
in PHP.

As we're extracting the core we'll be translating it to Python to make
use of the wealth of well-structured libraries and hopefully make the
project shorter. However, we've hit a snag in choosing a framework
around which to rebuild the service.

It seems the more popular frameworks (django, turbogears) are all
focused on providing web content. Since our core will be using thrift
to communicate, we don't need templating, feeds, admin pages (django),
or ajax (turbogears).

What we *do* need is a lightweight, simple framework that will allow
us to create a RESTful interface and throw code together fast. We'll
probably go with SQLObject (unless we can extract the ORM from django
- lazy evaluation would be very useful), and we're just looking for
something fast and light to sit between that and the thrift interfaces
we'll create.

So, can anyone suggest a lightweight python framework which just does
the essentials?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is there any component-oriented (non-MVC) web framework available for Python?

2008-07-16 Thread Phillip B Oldham
On Jul 16, 6:48 pm, Alis <[EMAIL PROTECTED]> wrote:
> Hi
>
> Is there any component-oriented (non-MVC) web framework available for
> Python?
>
> That is something like Apache Wicket, Tapestry or JSF, but I need it
> to be in Python.
>
> Regards,
> Ali

Have you looked at kamaelia?

http://kamaelia.sourceforge.net/
--
http://mail.python.org/mailman/listinfo/python-list


Standard module for parsing emails?

2008-07-30 Thread Phillip B Oldham
Is there a standard library for parsing emails that can cope with the
different way email clients quote?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Standard module for parsing emails?

2008-07-30 Thread Phillip B Oldham
On Jul 30, 2:36 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> What do you mean with "quote" here?
>   2. Prefix of quoted text like your text above in my mail

Basically, just be able to parse an email into its actual and "quoted"
parts - lines which have been prefixed to indent from a previous
email.

Most clients use ">" which is easy to check for, but I've seen some
which use "|" and some which *don't* quote at all. Its causing us
nightmares in parsing responses to system-generated emails. I was
hoping someone might've seen the problem previously and released some
code.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Standard module for parsing emails?

2008-07-30 Thread Phillip B Oldham
If there isn't a standard library for parsing emails, is there one for
connecting to a pop/imap resource and reading the mailbox?
--
http://mail.python.org/mailman/listinfo/python-list


Large production environments using ZODB/ZOE?

2008-08-07 Thread Phillip B Oldham
I've been reading a lot recently on ZODB/ZOE, but I've not seen any
reference to its use in large-scale production envrironments.

Are there any real-world examples of ZODB/ZOE in use for a large
system? By large, I'm thinking in terms of both horizontally-scaled
systems and in terms of data storage size.
--
http://mail.python.org/mailman/listinfo/python-list


Trying ZODB, background in Relational: mimic auto_increment?

2008-08-14 Thread Phillip B Oldham
Hi all. I'm playing with standalone ZODB at the moment trying to get a
better understanding of its use in applications. I come from a
PHP/MySQL background, and I'm taking my first steps with Python at the
same time.

One of the things I'm not understanding about ZODB is assigning
incremental IDs to objects. For instance, if I were to be writing a
support-ticket system I'd want to give each ticket a unique number,
but one that's "human-useable" (otherwise you could just use a UUID -
try giving one of those over the phone!).

Also, how would one add a new item to the db in this way?

For instance:

class Ticket(Persistence):
  def __init__(self):
self.id = '' # How do I add a new incremental ID here?

# and later on in the app

tkt = Ticket()
dbroot[?] = tkt

How would one assign a unique ID to the root at that point?
--
http://mail.python.org/mailman/listinfo/python-list


Event-driven framework (other than Twisted)?

2008-10-01 Thread Phillip B Oldham
Are there any python event driven frameworks other than twisted?
--
http://mail.python.org/mailman/listinfo/python-list


Are there any python micro-frameworks (like ruby's Camping)?

2008-10-01 Thread Phillip B Oldham
Are there any python micro-frameworks (like ruby's Camping)?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Phillip B Oldham
On Oct 1, 9:25 am, Lie Ryan <[EMAIL PROTECTED]> wrote:
> Most GUI package use event-driven model (e.g. Tkinter).

I've noticed that. I'm thinking more for a web environment (instead of
MVC) or as a HTTP server. I know Twisted has TwistedWeb, but I'm
looking for alternatives.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any python micro-frameworks (like ruby's Camping)?

2008-10-01 Thread Phillip B Oldham
On Oct 1, 9:53 am, Sam <[EMAIL PROTECTED]> wrote:
> Did you try WebPy?http://webpy.org/Hum, the website seems to be down today

Not yet - I'm hoping the python community can suggest some examples of
micro/small frameworks (which just supply the basics; no forms/
templating/ORM/etc) so I can compare and select the one which suits my
needs.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any python micro-frameworks (like ruby's Camping)?

2008-10-01 Thread Phillip B Oldham
On Oct 1, 10:29 am, Michele Simionato <[EMAIL PROTECTED]>
wrote:
> How about wsgiref in the standard library? It is as small as you can
> get without resorting to CGI.

Interesting... I'll be sure to check that out also.

Someone also mentioned Paste/WebOb, so now I have 3 to test.

Any others?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Phillip B Oldham
On Oct 1, 4:12 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Please explain what you want to do.

I'm primarily looking for alternatives to MVC frameworks for web
development, particularly SAAS. I've looked around, and some
whitepapers suggest that event-based frameworks often perform better
than MVC. Since I'm looking at SAAS, having a "view" is pretty
pointless since I'll either be using Thrift, returning simple HTTP
headers, or returning some sort of JSON/YAML/XML content (possibly
based on accept headers).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Phillip B Oldham
On Oct 1, 6:53 pm, Lie Ryan <[EMAIL PROTECTED]> wrote:
> In fact, MVC and event-driven is two entirely different concept. You can
> have both, or none. It is, in the end, your choice which one to use or
> whether you want to use both or none.
>
> Event-driven programming is a concept that your programs are entirely
> composed of function definition and binding that function definition to
> events. The rest is handled by a mainloop, which calls the appropriate
> functions when it receives something.
>
> MVC is a separation of concern. In MVC code you want that there is a
> clear boundary between code that handles Model, View, and Controller, so
> it'd be easier to manage the code.

So are there any other patterns that can be used in stead of MVC?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event-driven framework (other than Twisted)?

2008-10-02 Thread Phillip B Oldham
On Oct 2, 1:32 am, "James Mills" <[EMAIL PROTECTED]> wrote:
> http://hg.shortcircuit.net.au/index.wsgi/pymills/file/b7498cd4c6a4/ex...

Thanks for the example, but its not loading.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event-driven framework (other than Twisted)?

2008-10-02 Thread Phillip B Oldham
On Oct 2, 1:28 am, "James Mills" <[EMAIL PROTECTED]> wrote:
> Phillip, I have been developing a rather unique
> event-driven and component architecture library
> for quite some time that is (not twisted). Actually
> it's nothing like twisted, but based on 2 core
> concepts:
>  * Everything is a Component
>  * Everything is an Event
>
> It's currently called pymills.event
> Let me know if you're interested, I probably
> plan to re-package and re-branch this library
> (the event library) at some point.

I'd be very interested in seeing this. Component-based programming is
something which interests me also.
--
http://mail.python.org/mailman/listinfo/python-list


GetPaid module that supports "deferred" payments?

2009-09-28 Thread Phillip B Oldham
Are any of the GetPaid modules able to handle "deferred" payments? As
in, the money to be taken is placed "on hold" in the customer's
account and can be "released" to the vendor at a later date.
-- 
http://mail.python.org/mailman/listinfo/python-list


Help understanding the decisions *behind* python?

2009-07-20 Thread Phillip B Oldham
My colleagues and I have been working with python for around 6 months
now, and while we love a lot of what python has done for us and what
it enables us to do some of the decisions behind such certain
data-types and their related methods baffle us slightly (when compared
to the decisions made in other, similarly powerful languages).

Specifically the "differences" between lists and tuples have us
confused and have caused many "discussions" in the office. We
understand that lists are mutable and tuples are not, but we're a
little lost as to why the two were kept separate from the start. They
both perform a very similar job as far as we can tell.

Consider the following:

>>> x = [2,1,3]
>>> x.sort()
>>> print x
[1, 2, 3]

Now, if the sort operations were unable to affect the original
structure of the list (as in JavaScript) you'd effectively have a
tuple which you could add/remove from, and the example above would
look more like:

>>> x = [2,1,3]
>>> print x.sort()
[1, 2, 3]
>>> print x
[2,1,3]

This make a lot more sense to us, and follows the convention from
other languages. It would also mean chaining methods to manipulate
lists would be easier:

>>> x = [2,1,3]
>>> print x.sort()[0]
3
>>> print x
[2,1,3]

We often find we need to do manipulations like the above without
changing the order of the original list, and languages like JS allow
this. We can't work out how to do this in python though, other than
duplicating the list, sorting, reversing, then discarding.

We're not looking to start any arguments or religious wars and we're
not asking that python be changed into something its not. We'd simply
like to understand the decision behind the lists and tuple structures.
We feel that in not "getting" the difference between the two types we
may be missing out on using these data structures to their full
potential.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help understanding the decisions *behind* python?

2009-07-20 Thread Phillip B Oldham
On Jul 20, 6:08 pm, Duncan Booth  wrote:
> The main reason why you need both lists and tuples is that because a tuple
> of immutable objects is itself immutable you can use it as a dictionary
> key.

Really? That sounds interesting, although I can't think of any real-
world cases where you'd use something like that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Suggestions for Python MapReduce?

2009-07-22 Thread Phillip B Oldham
I understand that there are a number of MapReduce frameworks/tools
that play nicely with Python (Disco, Dumbo/Hadoop), however these have
"large" dependencies (Erlang/Java). Are there any MapReduce frameworks/
tools which are either pure-Python, or play nicely with Python but
don't require the Java/Erlang runtime environments?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestions for Python MapReduce?

2009-07-22 Thread Phillip B Oldham
On Jul 22, 2:23 pm, Casey Webster  wrote:
> I can't answer your question, but I would like to better understand
> the
> problem you are trying to solve.  The Apache Hadoop/MapReduce java
> application isn't really that "large" by modern standards, although it
> is generally run with large heap sizes for performance (-Xmx1024m or
> larger for the mapred.child.java.opts parameter).
>
> MapReduce is designed to do extremely fast parallel data set
> processing
> on terabytes of data over hundreds of physical nodes; what advantage
> would a pure Python approach have here?

We're always taught that it is a good idea to reduce the number of
dependencies for a project. So you could use Disco, or Dumbo, or even
Skynet. But then you've introduced another system you have to manage.
Each new system will have a learning curve, which is lessened if the
system is written in an environment/language you already work with/
understand. And since a large cost with environments like erlang and
java is in understanding them any issues that are out of the ordinary
can be killer; changing the heap size as you mentioned above for Java
could be one of these issues that a non-java dev trying to use Hadoop
might come across.

With the advent of cloud computing and the new semi-structured/
document databases that are coming to the fore sometimes you need to
use MapReduce on smaller/fewer systems to the same effect. Also, you
may need only to ensure that a job is done in a timely fashion without
taking up too many resources, rather than lightening-fast. Dumbo/disco
in these situations may be considered overkill.

Implementations like BashReduce  are perfect for such scenarios. I'm simply
wondering if there's another simpler/smaller implementation of
MapReduce that plays nicely with Python but doesn't require the setup/
knowledge overhead of more "robust" implementations such as hadoop and
disco... maybe similar to Ruby's Skynet.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestions for Python MapReduce?

2009-07-22 Thread Phillip B Oldham
On Jul 22, 5:55 pm, Paul Rubin <http://phr...@nospam.invalid> wrote:
> Phillip B Oldham  writes:
> I usually just spew ssh tasks across whatever computing nodes I can
> get my hands on.  It's less organized than something like mapreduce,
> but I tend to run one-off tasks that I have to keep an eye on anyway.

I'm thinking of repeated tasks; things you run regularly, but don't
need to be blisteringly fast. I'll more than likely use Disco, but if
I were to find something more light-weight I'd take a serious look.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestions for Python MapReduce?

2009-07-28 Thread Phillip B Oldham
In answer to my own question, I came across Octo.py[1] today. Not
tested/played-with/used it yet, however, though it seems simple
enough.

Still welcoming any suggestions for other/similar tools.

[1] http://code.google.com/p/octopy/
-- 
http://mail.python.org/mailman/listinfo/python-list


Most "active" coroutine library project?

2009-08-23 Thread Phillip B Oldham
I've been taking a look at the multitude of coroutine libraries
available for Python, but from the looks of the projects they all seem
to be rather "quiet". I'd like to pick one up to use on a current
project but can't deduce which is the most popular/has the largest
community.

Libraries I looked at include: cogen, weightless, eventlet and
circuits (which isn't exactly coroutine-based but it's event-driven
model was intriguing).

Firstly, are there any others I've missed? And what would the
consensus be on the which has the most active community behind it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Validation in RPC call?

2009-09-07 Thread Phillip B Oldham
I'm building an RPC service, and I need to validate the input and
provide informative error messages to users. What would be the best
way to do this? Simple `if` statements each raising a custom
exception? `assert` statements inside a try/except block to
"translate" the assertion errors into something more meaningful?
-- 
http://mail.python.org/mailman/listinfo/python-list