easy_install from svn

2007-06-19 Thread Rob Cowie
Hi all,

I currently use easy_install to install packages from a custom,
locally hosted package_index. The index consists of a single html doc
with a list of package names and urls. All works well.

I would like to get a little more sophisticated and install a package
from subversion.

My package is structured as described in the setuptools docs.

Simply pointing the url in my package index to svn://my/repo/package/trunk
works, but I would like - and I get the impression it is possible - to
be able to specify a revision number, or a tag and have that version
installed.

Is it simply a case of appending a fragment to the url?
Would anyone be so kind as to provide a working example?

cheers,

Rob Cowie

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


Re: easy_install from svn

2007-06-19 Thread Rob Cowie
On Jun 19, 8:13 pm, Stefan Behnel [EMAIL PROTECTED] wrote:
 Rob Cowie wrote:
  I currently use easy_install to install packages from a custom,
  locally hosted package_index. The index consists of a single html doc
  with a list of package names and urls. All works well.

  I would like to get a little more sophisticated and install a package
  from subversion.

  My package is structured as described in the setuptools docs.

  Simply pointing the url in my package index to svn://my/repo/package/trunk
  works, but I would like - and I get the impression it is possible - to
  be able to specify a revision number, or a tag and have that version
  installed.

  Is it simply a case of appending a fragment to the url?
  Would anyone be so kind as to provide a working example?

 This is how we do it for lxml:

 http://cheeseshop.python.org/pypi/lxml/1.2.1

 Stefan

Thanks.

I guess I was wrong in thinking that one could add a revision number
to the url fragment and have easy_install get that revision.
Instead, I should explicitly specify the urls in the package index
(and/or setup.py) and identify them with the fragment.

So, to make a head version and a tag available, the following urls
must be in the package index:

svn://svn/my/repo/package/trunk#egg=package-dev
svn://svn/my/repo/package/tags/r1.0#egg=package-1.0

and install them thus...

easy_install -i http://may/index package==dev | package==1.0

cheers,

Rob Cowie

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


Re: Documenting a package with Pydoc

2006-08-19 Thread Rob Cowie
Anyone?

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


Re: Documenting a package with Pydoc

2006-08-19 Thread Rob Cowie

Gabriel Genellina wrote:
 At Friday 18/8/2006 11:45, Rob Cowie wrote:

 Pydoc seems to be capable of writing documentation for all modules
 within a package by simply pointing it to the package on the command
 line...
 
 pydoc -w packagename_without_/
 
 Certainly, the method writedocs() appears to descend into a directory
 and create docs for each importable object.
 
 Perhaps I'm doing something wrong but when I do this, pydoc reports
 that no Python documentation can be found for each of the contents of
 the package. Of course, if I point pydoc directly to the modules, it
 succeeds.
 
 Am I doing something wrong?

 That appears to be a bug. In pydoc.writedocs, when iterating over the
 package directory contents, it uses inspect.getmodulename(path). That
 returns the bare filename (without path nor extension) (is it ok???),
 and later the resolve() function can't load the module because it
 lacks package information.

I don't think this is a bug; inspect.getmodulename(path) does indeed
return a bare filename, but this is later augmented with the pkgpath.

I also can't find a resolve() function. Perhaps we have different
versions? I have revision 1.38.

 For simple cases this patch may work: In writedocs, add the following
 line at the beginning:
  if pkgpath=='' and ispackage(dir): pkgpath = os.path.basename(dir) + '.'

 This works for top level packages located at sys.path, but not for
 packages located elsewhere.

 By example, I can generate now the docs for pychart:

 python c:\apps\python\lib\pydoc.py -w c:\apps\python\lib\site-packages\pychart



 Gabriel Genellina
 Softlab SRL


Thanks,

Rob C



 __
 Preguntá. Respondé. Descubrí.
 Todo lo que querías saber, y lo que ni imaginabas,
 está en Yahoo! Respuestas (Beta).
 ¡Probalo ya! 
 http://www.yahoo.com.ar/respuestas

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


Documenting a package with Pydoc

2006-08-18 Thread Rob Cowie
I have searched this group and the wider net to find an answer to this,
but I haven't been successful.

Pydoc seems to be capable of writing documentation for all modules
within a package by simply pointing it to the package on the command
line...

pydoc -w packagename_without_/

Certainly, the method writedocs() appears to descend into a directory
and create docs for each importable object.

Perhaps I'm doing something wrong but when I do this, pydoc reports
that no Python documentation can be found for each of the contents of
the package. Of course, if I point pydoc directly to the modules, it
succeeds.

Am I doing something wrong?

Cheers, Rob C

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


Re: Type conversion?

2006-08-18 Thread Rob Cowie

KraftDiner wrote:
 I have the following code...

 import array
 len32 = array.array('L')
 len16 = array.array('H')

 len32.append(0)
 len16.append(0)

 y = len32[0]
 print y.__class__
 type 'long'
 z = len16[0]
 print z.__class__
 type 'int'

 how can I change Zs type to long?

z_long = long(z)
type(z_long)
type 'long'

 Or how how can I change an arrays type?

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


Re: how can I avoid abusing lists?

2006-07-07 Thread Rob Cowie
Just forget the lists...

counters = {0:0, 1:0, 2:0, 3:0, 4:0}

def increment(value):
counters[value] += 1

increment(1)
increment(1)
increment(3)
increment(4)

print counters[0]
 0
print counters[1]
 2
print coutners[2]
 0
print counters[3]
 1
print coutners[4]
 1

The increment function should probably include a try:...except:
statement to catch KeyErrors that would arise if you passed a value
that is not a key in the counters dictionary.

Rob C

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


Re: how can I avoid abusing lists?

2006-07-07 Thread Rob Cowie
No, your question was clear. With hindsght and a more thorough read of
your post I see my error ;^)

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


Calling every method of an object from __init__

2006-06-19 Thread Rob Cowie
Hi all,

Is there a simple way to call every method of an object from its
__init__()?

For example, given the following class, what would I replace the
comment line in __init__() with to result in both methods being called?
I understand that I could just call each method by name but I'm looking
for a mechanism to avoid this.

class Foo(object):
def __init__(self):
#call all methods here
def test(self):
print 'The test method'
def hello(self):
print 'Hello user'

Thanks,

Rob C

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


Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Rob Cowie
John Machin wrote:
 On 10/06/2006 7:49 AM, Rob Cowie wrote:
  Hi all,
 
  I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba',
  'abb', 'abc' etc. all the way to 'zzz'.
 
  How would you construct a generator to acheive this?
 
  A simple, working but somewhat inelegant solution is...

 You're not wrong.

 
  alpha = ['a','b','c','d'] #shortened for brevity

 Hope you remember the alphabet correctly.
Not sure I understand your point. Why would I forget the alphabet?

 Why type all that punctuation?
What punctuation?

 Any reason this cruft is global (i.e. not local to the generator)?
No


  alpha2 = ['a','b','c','d']
  alpha3 = ['a','b','c','d']

 Hope you get the redundant copy/paste right.
Again, I don't understand what you mean


 
  def generator():
for char in alpha:

 Why stop at two spaces? One-space indentation is syntactically correct :-)
As are 3, 4 and 5 space indentation. Yet again, what is your point?


  for char2 in alpha2:
for char3 in alpha3:
  yield char + char2 + char3
 
  x = generate()

 Did you meant generator?
Yes, made a mistake

  x.next() # etc, etc, etc,
 

 | def generator():
 ... import string
 ... alpha = string.ascii_lowercase
 ... for char in alpha:
 ... for char2 in alpha:
 ... for char3 in alpha:
 ... yield char + char2 + char3
 ...
 | x = generator()
 | the_lot = list(x)
 | len(the_lot) == 26 ** 3
 True
 | [the_lot[i] for i in (0, 1, 25, 26, -27, -26, -1)]
 ['aaa', 'aab', 'aaz', 'aba', 'zyz', 'zza', 'zzz']

 Cheers,
 John

I'm aware the code I posted is not great - it isn't code I would
consider using. It was only intended to serve as an illustration of the
task at hand in case my explanation wasn't sufficient.

I'm grateful to you for using list(generator) in your example. I was
not aware this could be done (I haven't yet fully read the generator
documentation).

Rob C

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


Most elegant way to generate 3-char sequence

2006-06-09 Thread Rob Cowie
Hi all,

I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba',
'abb', 'abc' etc. all the way to 'zzz'.

How would you construct a generator to acheive this?

A simple, working but somewhat inelegant solution is...

alpha = ['a','b','c','d'] #shortened for brevity
alpha2 = ['a','b','c','d']
alpha3 = ['a','b','c','d']

def generator():
  for char in alpha:
for char2 in alpha2:
  for char3 in alpha3:
yield char + char2 + char3

x = generate()
x.next() # etc, etc, etc,

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


Re: Standalone Python functions in UML?

2006-04-04 Thread Rob Cowie

Roman Susi wrote:
 Hi!

 Out of curiosity, how do I draw functions outside classes with UML? How
 module could be drawn in this case?

I would say that within a class diagram, you can't. In other UML
diagrams (such as sequence interaction), the function is simply used as
if it were a method belonging to an object. If you need to make it
clear where this function is located within the code, use a note on the
diagram.

Remember, UML is not able to accurately capture all implementation
details of a system; It's not meant to.


 More theoretical question is if I create classes on the fly, how UML can
 reflect that?

Again, don't try to depict fine-grained implementation details. If the
dynamically generated class is important to the class diagram, include
it but don't include all of it's internals (methods etc.). Use a note
to exaplin how/when/why it is generated.


 (I know that Python code itself is best at communication design ideas,
 but there are some people which prefer to talk UML.)

 (Have not found anything relevant with google)
 
 Thanks!
 
 Regards,
 Roman Suzi

Rob C

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


Re: Installing PySQLite on OS X 10.4

2006-03-16 Thread Rob Cowie
Cheers. I should have read the installation notes more carefully :)

Rob C

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


Installing PySQLite on OS X 10.4

2006-03-15 Thread Rob Cowie
Hi all,

I'm having difficulty installing pysqlite 2.1.3 on Mac OS X 10.4.4

There are some notes on the pysqlite wiki regarding modification of the
setup.py script and I've followed them to no avail.

Build and install appear to go smoothly but attempting to run the tests
from the python interpreter fails. Likewise any attempt to utilise
pysqlite2 in a python script fails.

Has anyone here successfully installed it?

If you have, do you have any pearls of wisdom that might help me out?

Cheers,

Rob C

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


Re: Installing PySQLite on OS X 10.4

2006-03-15 Thread Rob Cowie

Fredrik Lundh wrote:
 Rob Cowie wrote:

  There are some notes on the pysqlite wiki regarding modification of the
  setup.py script and I've followed them to no avail.
 
  Build and install appear to go smoothly but attempting to run the tests
  from the python interpreter fails. Likewise any attempt to utilise
  pysqlite2 in a python script fails.

 it's might be a bit easier to help if you what you did when attempting to use
 the library, and how things failed.

 (if you get an ImportError, are you importing the right thing?  where did the
 setup.py install step put the modules ?  is that directory on the Python 
 path ?)

 /F

True... I should have included this stuff.

the output from setup.py install indicates that an egg is constructed
and copied to
/Library/Python/2.3/site-packages/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg.

At the python prompt, I can import pysqlite2 with no problems.

However, if I do from pysqlite2 import test as suggested after
installation, I get the following traceback...

Traceback (most recent call last):
  File stdin, line 1, in ?
  File pysqlite2/test/__init__.py, line 25, in ?
from pysqlite2.test import dbapi, types, userfunctions, factory,
transactions
  File pysqlite2/test/dbapi.py, line 26, in ?
import pysqlite2.dbapi2 as sqlite
  File pysqlite2/dbapi2.py, line 32, in ?
from pysqlite2._sqlite import *
ImportError: No module named _sqlite

If I view my site-packages dir in the Finder, the .egg file appears as
a document, instead of a directory as is usually the case with .eggs.
Perhaps this is an indication that the .egg file is not being built
correctly?

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


Re: Installing PySQLite on OS X 10.4

2006-03-15 Thread Rob Cowie

Gerhard Häring wrote:
 Rob Cowie wrote:
  [...]
  However, if I do from pysqlite2 import test as suggested after
  installation, I get the following traceback...
 
  Traceback (most recent call last):
File stdin, line 1, in ?
File pysqlite2/test/__init__.py, line 25, in ?
  from pysqlite2.test import dbapi, types, userfunctions, factory,
  transactions
File pysqlite2/test/dbapi.py, line 26, in ?
  import pysqlite2.dbapi2 as sqlite
File pysqlite2/dbapi2.py, line 32, in ?
  from pysqlite2._sqlite import *
  ImportError: No module named _sqlite
  [...]

 Apparently, you're doing this from the pysqlite sources root directory.
 So the pysqlite2 directory is tried, which does ont include the compiled
 C extension module. Execuring from any other working directory on your
 system should work fine.

 I'll have to check that this is all properly documented before I do the
 next pysqlite release.

 -- Gerhard

Thanks however, now when I try from pysqlite2 import test it
results in:

Traceback (most recent call last):
  File stdin, line 1, in ?
  File
build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/test/__init__.py,
line 25, in ?
  File
build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/test/dbapi.py,
line 26, in ?
  File
build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/dbapi2.py,
line 32, in ?
  File
build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/_sqlite.py,
line 7, in ?
  File
build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/_sqlite.py,
line 6, in __bootstrap__
ImportError:
dlopen(/Users/rob/.python-eggs/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg-tmp/pysqlite2/_sqlite.so,
2): Symbol not found: _sqlite3_transfer_bindings
  Referenced from:
/Users/rob/.python-eggs/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg-tmp/pysqlite2/_sqlite.so
  Expected in: dynamic lookup

I now suspect that this may all be down to the version of sqlite3
installed as part of OS X 10.4. Some people report success when using
this version with pysqlite, others report failure.

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


Re: Separating elements from a list according to preceding element

2006-03-06 Thread Rob Cowie
Thanks everyone. I assumed there was something I had not considered...
list slicing is that thing.

The pyParsing example looks interesting - but for this case, a little
too heavy. It doesn't really warrant including a third party module.

Rob C

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


Separating elements from a list according to preceding element

2006-03-05 Thread Rob Cowie
I'm having a bit of trouble with this so any help would be gratefully
recieved...

After splitting up a url I have a string of the form
'tag1+tag2+tag3-tag4', or '-tag1-tag2' etc. The first tag will only be
preceeded by an operator if it is a '-', if it is preceded by nothing,
'+' is to be assumed.

Using re.split, I can generate a list that looks thus:
['tag1', '+', 'tag2', '+', 'tag3', '-', 'tag4']

I wish to derive two lists - each containing either tags to be
included, or tags to be excluded. My idea was to take an element,
examine what element precedes it and accordingly, insert it into the
relevant list. However, I have not been successful.

Is there a better way that I have not considered? If this method is
suitable, how might I implement it?

Thanks all,

Rob Cowie

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


Re: good library for pdf

2006-01-26 Thread Rob Cowie
Take a look at www.reportlab.org. The ReportLab library includes a
graphics module that might well do what you need. I'm not sure at
present if it allows one to set alpha-channels to achieve transparency.

Also, if you have access to a mac running OS X 10.4, the Automator
application has a prebuilt action that applies a watermark to pdfs.
Transparency, size and placement are all editable. Obviously, no use if
you want to do this with Python, but it might suit your needs.

Rob C

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


Re: Using CGI to interface with an XML-RPC server

2006-01-18 Thread Rob Cowie
Please? I really could do with some help!

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


Re: Using CGI to interface with an XML-RPC server

2006-01-18 Thread Rob Cowie
Python ships with cgi and xmlrpc support (cgi and xmlrpclib, respectively),
so I'm not sure why you even think you have to ask...
1. use cgi to parse form data
2. use xmlrpclib to issue request
3. use print or your favourite html templating library to generate
output

(it might be a good idea to check with your web server admins, though,
to make sure they don't have a problem with outgoing HTTP requests)

So it is possible.

I'm aware of cgi and xmlrpc modules. The reason I have asked is that
there appears to be much difficulty when tying these two things
together. I also wanted to see if anyone mentioned CGIXMLRPCserver
which is part of the stdlib. I am unsure if this is what I am looking
for. I have been unable to fully comprehend the documentation.

Thanks for your help.

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


Using CGI to interface with an XML-RPC server

2006-01-17 Thread Rob Cowie
Hi all,

Assume I have a working XML-RPC server that runs persistently and
correctly accepts remote calls, executes the relevant code and outputs
the XML-RPC result. This is fine when using an XML-RPC client.

However, I wish to provide a web user interface. I gather it is
possible to use PHP as an XML-RPC client but I am unable to do so
because of artificially imposed server constraints. All I am able to
use is good the old CGI.

Is it possible to create python CGI scripts that accept form data in
the usual way, package them as an XML-RPC request, call the server,
receive the response then format this response into valid HTML to be
emitted to the client? Is this desirable (what I mean is... is there an
easier way?).

Is there a better way to use a web browser as what is essentially an
XML-RPC client?

FYI, I know that is seems like using XML-RPC in this case is
pointless.. it isn't, some users do indeed use the server as intended.

Cheers,

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


Re: chi-squared tests in python?

2006-01-17 Thread Rob Cowie
 Matthew
 ps: given the batteries included philosphy, there's a remarkable dearth
 of stats in python...

I think Chi^2 tests fall distinctly in the third-party library category, 
myself.

I don't know... I've often thought the Standard Library should include
a stats package.

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


Invoking Unix commands from a Python app

2005-12-16 Thread Rob Cowie
Hi all,

An idea popped into my head recently for an app that would track how
much time a user spends in a particular piece of software (or at least,
for how long an application is open).

I'm assuming there is a way to do this via the command line and a unix
app, although I haven't yet invesitgated it.

My question is, can a command line application be invoked by a python
program? If so, how does one pass parameters to it and retrieve its
response?

Cheers and Merry Christmas,

Rob Cowie

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


Re: Invoking Unix commands from a Python app

2005-12-16 Thread Rob Cowie
Excellent... just the thing I was looking for. Thanks.

Does anyone know of a unix app that could be used to monitor the
duration of processes etc.? 

Would 'top' do the trick?

Rob C

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


Re: Looking for a Python mentor

2005-10-13 Thread Rob Cowie
I'll gladly give you a hand. I should point out - I'm no expert. I
think I've reached a point a bit beyond yours; I learnt OO programming
principles with java and have spent this last Summer learning python. I
have a good grasp of it.

If you want to get in touch, email  rob_cowie AT mac DOT com

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


Re: noob question Letters in words?

2005-10-08 Thread Rob Cowie
Well.. that put me in my place!

Fredrik Lundh - I hadn't realised that 'is' does not test for
equivalence. Thanks for the advice.

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


Re: noob question Letters in words?

2005-10-07 Thread Rob Cowie
A string can be thought of as a tuple of characters. Tuples support
membership testing thus...

choice1 = raw_input( )

if '1' or 's' or 'S' in choice1:
  #do something
elif '2' or 'e' or E' in choice1:
  #do something

It doesn't seem to me to be a good idea; If the input is 'Start',
option1 is executed, likewise if the input is 'Stop', or any other
string with 's' in it.

Perhaps a better idea is to present the user with a choice that cannot
be deviated from, along the lines of...

def main():
  print 1.\tStart
  print 2.\tSomething Else
  print 3.\tStop

  x = raw_input()
  if x is '1': print 'Start'
  elif x is '2': print 'Something else'
  elif x is '3': print 'End'
  else: main()

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


Re: GUI on Macintosh

2005-10-07 Thread Rob Cowie
FYI... the preinstalled python distributed with OS X 10.4 includes the
Tk and wxPython GUI frameworks. I am unaware of how to get either of
these installed on OS 9.

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


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-03 Thread Rob Cowie
Perhaps with the time saved by using Python instead of C# or some such,
you could help to improve adodbapi.py, ensuring support for the next
version of MS SQLServer, although that might be of little help in the
short term. Just a thought.

Also, have a gander at http://www.object-craft.com.au/projects/mssql/
I have no knowledge of it, but it may prove useful to you.

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


Barcode Recognition

2005-09-19 Thread Rob Cowie
I'd like to be able to take a bitmapped image and identify and decode
any barcodes present within it.

Does anyone know of an existing module for accomplishing this task? Is
there any effort to add this functionality to the Python Imaging
Library?

Can anyone give me an idea of how diffucult an undertaking this is for
someone with no image processing experience?

Cheers,

Rob Cowie

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


Creating BibTex files with XdkBibTeX

2005-09-11 Thread Rob Cowie
I'm looking for a module that is able to create valid BibTex documents.
I'm currently using string substitution to create the content, but it
is not validated in any way.

The only BibTex creation module available in Python (that I can find)
is XdkBibTeX
(http://artis.imag.fr/Membres/Xavier.Decoret/resources/xdkbibtex/). It
is a python wrapper around a C library.

Has anyone used this? More interestingly to me... has anyone
successfully installed it on Mac OS X?

Also, can anyone suggest an alternative?

Cheers,

Rob Cowie

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


Retrieving Filename from Path

2005-08-31 Thread Rob Cowie
Hi,

Given a string representing the path to a file, what is the best way to
get at the filename? Does the OS module provide a function to parse the
path? or is it acceptable to split the string using '/' as delimiters
and get the last 'word'. The reason I'm not entirely happy with that
method is that it is platform specific. I would prefer to use a built
in method if possible.

Cheers,

Rob Cowie

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


Re: Retrieving Filename from Path

2005-08-31 Thread Rob Cowie
Thanks,

os.path.basename(filePath) it is then.

BTW, the help(module) function is new to me! Must have missed it when
reading the tutorial.

Cheers!

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


Re: Web frame systems vs. pure Python

2005-07-22 Thread Rob Cowie
I don't know what your project is, but a web framework might make your
system more scalable and maintainable if it gets larger. They often
provide useful mechanisms for maintaining state and persistance.

Template systems IMHO should be considered separately from App
frameworks (although they may be integrated). If you will frequently be
rendering web pages that are predominantly static but augmented with
dynamically generated/retrieved data, templates are a good way to go.
However, they can confuse if your system is only simple. In that case,
I wouldn't go for a full blown templating engine but 'roll my own'
using python dictionaries and 'string interpolation' (a daft name as it
isn't really interpolation).

Furthermore, app frameworks are sometimes a pain to install on a
webserver, particularly if you do not have control of it.

It all depends on your project size, your willingness to spend some
serious time climbing the learning curve associated with a framework,
and the server you wish to deploy on.

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


Separation of Code in CGI App

2005-07-22 Thread Rob Cowie
Hi,

I need to create a planner/calendar system using python cgi scripts. It
is my first CGI app (beyond a few tutorial examples).

I wish to separate the code according to function. For instance, the
code to handle the DB connection, SQL querying, HTML form variable
retrieval, rendering of HTML via some sort of template system etc. Each
will be a class instantiated when the CGI app is called.

To do this, do I just create each of these classes in one, monolithic
.cgi file? or is it possible to separate these out into different
scripts and have a 'controller' script call them and pass the relevant
parameters/data? I guess I could also store the python code in text
files and use the 'execfile()' function, although it seems to me that
would be an uneccasary performance hit.

If that is possible, is that the right way to go? If not, suggestions
would be gratefully recieved!

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


Re: is this possible?

2005-07-22 Thread Rob Cowie
Yeah, Acrobat Reader is for viewing PDF's, not creating them.

See http://www.reportlab.org/ for a couple of mature PDF libraries.

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


Re: Separation of Code in CGI App

2005-07-22 Thread Rob Cowie
So, do I separate out whatever code I want to into .py modules, then
have the cgi script import them, and utilise them as required?

If so, do I need to put these modules somewhere described in the System
Path? Can I modify the PATH at runtime to point to my modules? How?

Cheers for being patient!

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


Re: Separation of Code in CGI App

2005-07-22 Thread Rob Cowie
Thanks,

I have run through the tutorial - very good. One day, I'd like to try
and organise a similar tutorial involving CGI programming. There are
several very basic examples, but they leave plenty of unanswered
questions such as how to best structure a cgi app, apache permissions,
etc

So to be clear, if a .py module is in the same directory as my python
cgi script, I can import it thus 'import XXX.py'?

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


Re: Create our own python source repository

2005-06-07 Thread Rob Cowie
I'm not entirely sure what the point of your exercise is - if you have
access to the net, ,why do you want to collate code examples? They are
frequently updated in the cookbook so an offline repository would
quickly become out of date.

However you've aroused my interest in something related. We all
know Python is significantly easier   for novice programmers to grasp
than, say, Java - I too am a newbie who started at uni with java and
wished I hadn't.

Tutorials are great, self paced learning is great, BUT, for the
complete beginner a well structured, offline course with examples,
exercises, tips etc. would be a brilliant resource. Python would fit
the bill as a demonstration language to teach Object Orientation, flow
control statements, other common constructs etc. A quick canvas of some
IT teachers I know indicates support for such a thing - perhaps even in
secondary shools (pre-uni).

What does everyone think it would take to start such a project, and
distribute it? or has it been done already?

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


Re: Information about Python Codyng Projects Ideas

2005-06-01 Thread Rob Cowie
Ha,

I've just headed over here to ask the same thing!

Any good ideas not listed on the wiki?

I too am taking a Masters in Computer Science, however my first degree
was not purely CS - mostly microbiology, so I'm not yet what one would
call an expert

Cheers

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


Re: Newbie Here

2005-05-31 Thread Rob Cowie
As a relalative newbie myself I think I can say Python is used for
anything any major programming language is used for. One of its many
strengths is scalability - it can be used to great effect as a
scripting language AND as an object oriented language for creating
large, GUI apps.

Yours is not an easy question to answer - there are as many uses for
python as there are 'computing tasks'.

Go to http://www.awaretek.com/tutorials.html for a load of tutorials
and examples

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


Re: Help with choice of suitable Architecture

2005-05-29 Thread Rob Cowie
Thanks for the comments.

I kind of get the impression that CGI is the way to go for this
application, and that I should forget about adding client-side
scripting based functionality for the sake of accessibility - which I
understand and kind of agree with.

I'll look into the problem of concurrent access to an XML file. I may
get back to the group about this!

Cheers

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


Help with choice of suitable Architecture

2005-05-28 Thread Rob Cowie
Hi,

This is my first post so go easy!

I have been asked (as part of an MSc project) to create a server based
planner for a research group at my uni. It will have a web interface to
interact with data stored in an XML document. Basic functionality is
required such as viewing, searching, editing, creating and deleting
entries for things such as paper submission deadlines, events, funding
application deadlines. I would also like to use AJAX principles in the
web interface.
Additionaly, it must email a BibTex file once a month to a
predetermined address.

I'm totally new to web programming. I have been looking into the best
way to proceed. CGI is of course an option but it seems slow, clunky
and outdated. Twisted provides a rich architecture but might be
overkill. Nevow seems to be very popular.
I suspect I could achieve what I want using PHP but I would really like
to get to grip with Python.

I'm not asking for a comparison of each architecture per se that
seems to be well covered in this group. I would like to know how you
all would set about creating this realtively simple application.

Cheers,
Rob Cowie
Coventry University, Britain

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


Re: Help with choice of suitable Architecture

2005-05-28 Thread Rob Cowie
I agree with the sentiments that a single XML file is not the way to go
for storing data that may be accessed concurrently. However, my hands
are tied.

It seems that CGI is likely to be the most straightforward option. Is
the learning curve likely to be steeper for pure CGI or a web
application architecture such as Nevow?

Paul. I agree that client-side scripting increases the level of
compexity, but did it really go out of fashion with pop-ups? It seems
to be just getting started. Google use it to great effect maps,
suggest etc. I wasn't thinking of using it to deal with any 'business
logic', just to add some dynamism to the interface - use
XMLhttprequests, a bit of DOM scripting etc.

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