initialising a class by name

2009-01-13 Thread Krishnakant
hello all,
I have a strange situation where I have to load initiate an instance of
a class at run-time with the name given by the user from a dropdown
list.
Is this possible in python and how?
To make things clear, let me give the real example.
there is an inventory management system and products belong to different
categories.
There are predefined categories in the database and for each category
there is a module which contains a class made out of pygtk.
This means what class gets instantiated and displayed in the gui depends
on the choice a user makes in the dropdown.
Now, I could have created a list of if conditions for all the categories
as in 
if categorySelection == "books":
Books = BookForm()

However this is a problem because when there will be more than 100
categories there will be that many if conditions and this will make the
code uggly.
so my idea is to name the class exactly after the name of the category
so that when the user selects a category that name is used to initialise
the instance of that class.
So is it possible to initialise an instance of a class given its name
from a variable?
thanks and 
Happy hacking.
Krishnakant. 

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


Re: initialising a class by name

2009-01-13 Thread Krishnakant
On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote:
> Assuming all the classes are in the same module as the main program:
> 
> instance = vars()[class_name](args, to, init)
> 
The classes are not in the same module.
Every glade window is coupled with one py file (module) containing one
class that has the events for the glade file.
Inshort, there is one class in one module and they are all seperate.
> Assuming the classes are all in the same module "mod", which is
> separate from the main program:
> 
> instance = getattr(mod, class_name)(args, to, init)
> 
Can you explain the difference between getattr and var()?

> Cheers,
> Chris
> 
happy hacking.
Krishnakant.

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


Re: initialising a class by name

2009-01-14 Thread Krishnakant
Hi, 
So should I not use getattr()?
If I have one class in one module, then should I use global?
I found getattr() very easy to use, my only dowbt is that if there is
going to be one class per module then will it be a good idea?
some thing like module, class_name 
happy hacking.
Krishnakantt.
On Tue, 2009-01-13 at 23:55 -0800, Chris Rebert wrote:

> On Tue, Jan 13, 2009 at 11:49 PM, Krishnakant  wrote:
> > On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote:
> >> Assuming all the classes are in the same module as the main program:
> >>
> >> instance = vars()[class_name](args, to, init)
> >>
> > The classes are not in the same module.
> > Every glade window is coupled with one py file (module) containing one
> > class that has the events for the glade file.
> > Inshort, there is one class in one module and they are all seperate.
> >> Assuming the classes are all in the same module "mod", which is
> >> separate from the main program:
> >>
> >> instance = getattr(mod, class_name)(args, to, init)
> >>
> > Can you explain the difference between getattr and var()?
> 
> getattr(x, 'y') <==> x.y
> 
> vars() gives a dict representing the current accessible variable
> bindings (I should have instead recommended the related globals()
> function)
> globals() gives a dict representing the global variable bindings
> For example:
> #foo.py
> class Foo(object):
> #code here
> 
> Foo()
> #same as
> globals()['Foo']()
> #end of file
> 
> Cheers,
> Chris
> 

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


Re: initialising a class by name

2009-01-14 Thread Krishnakant

Hi steevan,
I liked this idea of dispatchTable.
is it possible to say some thing like 
inst = dispatchTable{"ham"}
according to me, inst will become the instance of class ham.
Another thing to note is that all the classes are in different modules.
So where do I create the dict of classes mapped with the name?
happy hacking.
Krishnakant. 
On Wed, 2009-01-14 at 07:50 +, Steven D'Aprano wrote:
> On Wed, 14 Jan 2009 11:16:58 +0530, Krishnakant wrote:
> 
> > hello all,
> > I have a strange situation where I have to load initiate an instance of
> > a class at run-time with the name given by the user from a dropdown
> > list.
> 
> Not strange at all.
> 
> > Is this possible in python and how?
> 
> Of course. Just use a dispatch table. Use a dict to map user strings to 
> classes:
> 
> 
> >>> class Spam(object): pass
> ...
> >>> class Ham(object): pass
> ...
> >>> dispatch_table = {"Spam": Spam, "Ham": Ham}
> >>> dispatch_table["Ham"]()
> <__main__.Ham object at 0xb7ea2f8c>
> 
> 
> The keys don't even have to be the name of the class, they can be 
> whatever input your users can give:
> 
> >>> dispatch_table["Yummy meat-like product"] = Spam
> >>> dispatch_table["Yummy meat-like product"]()
> <__main__.Spam object at 0xb7ea2f6c>
> 
> 
> You can even automate it:
> 
> >>> dispatch_table = {}
> >>> for name in dir():
> ... obj = globals()[name]
> ... if type(obj) == type:
> ... dispatch_table[name] = obj
> ...
> >>> dispatch_table
> {'Ham': , 'Spam': }
> 
> 
> 

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


Re: initialising a class by name

2009-01-14 Thread Krishnakant
On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
> Aside from Steven's excellent idea, to use the getattr() technique
> with your module scheme you'd probably also need to use __import__()
> to dynamically import the right module.
> 
I would generally import all the modules I would need at the top of the
main module.
then would use getattr(module,class_name) will that work?
or do I need to import in some other way?
happy hacking.
Krishnakant.

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


Re: initialising a class by name

2009-01-14 Thread Krishnakant
On Wed, 2009-01-14 at 04:09 -0500, Steve Holden wrote:
> > 
> You don't need to have the names of the classes related to anything in
> the interface. Just use a list of classes, and have the user interface
> return the correct index for each class. Then (supposing the selection
> by the user is seln) use
> 
>   Books = classes[seln]()
> 
> If the classes are all in different modules, import them before creating
> the list of classes.
> 
Is there a way to get the list of all the classes in the package?
I mean is there a way to build a list of modules  from some global
variable which can be accessed and then looped through.
happy hacking.
Krishnakant.

> regards
>  Steve

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


Re: initialising a class by name

2009-01-14 Thread Krishnakant
On Wed, 2009-01-14 at 00:39 -0800, Chris Rebert wrote:
> On Wed, Jan 14, 2009 at 12:36 AM, Krishnakant  wrote:
> > On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
> >> Aside from Steven's excellent idea, to use the getattr() technique
> >> with your module scheme you'd probably also need to use __import__()
> >> to dynamically import the right module.
> >>
> > I would generally import all the modules I would need at the top of the
> > main module.
> > then would use getattr(module,class_name) will that work?
> 
> Yes, that is how you'd do it in that case.
> 
By the way, is there a kind of global list of modules/classes which are
maintained in a package once the program is loaded into memory?
happy hacking.
Krishnakant.

> Cheers,
> Chris
> --
> Follow the path of the Iguana...
> http://rebertia.com

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


confused about publishing more than one class in twisted server.

2009-01-16 Thread Krishnakant
hello,
I am writing a twisted based rpc service where I am implementing a
complete application as a service.
I have many modules which make a package.  Now when we publish a service
in twisted, we have to create one instance of a certain class and then
publish it with the help of reactor.
but in my application, there are more than one class in different .py
files.  Now I want to know how do i create a package where all the
classes in different modules get published so that the entire package
can be used as the rpc server application and the client can be used to
query any module.

for example I have classes to get and set vendor, product, bills etc.
now all this has to be   accessed through the xml rpc service.
Can some one tell me how to manage the entire twisted package as a
service.
happy hacking.
Krishnakant.


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


need help from some one who uses python-ooolib

2009-02-12 Thread Krishnakant
hello all,
Has any one used python-ooolib to create open office spreadsheets?
I want to know the method of merging cells using the library's calc
class.
happy hacking.
Krishnakant.


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


Re: Python interface to ODF documents?

2009-02-15 Thread Krishnakant
hello
look at python-ooolib
it can do what ever is needed and more.
happy hacking.
Krishnakant.
 
On Sun, 2009-02-15 at 21:10 +0100, Tino Wildenhain wrote:
> Hi,
> 
> Dotan Cohen wrote:
> > Is there a Python interface to ODF documents? I'm thinking of
> > something that will import, for example, an ADS spreadsheet into a
> > multidimensional array (including formulas and formatting) and let me
> > manipulate it, then save it back.
> 
> Yes, you have zipfile and a host of xml parsers included in the
> standard lib. This works very well to my experience.
> 
> Not sure if an abstraction layer on top of that exists.
> 
> Regards
> Tino
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list

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


%s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Krishnakant
hello all hackers.
This is some kind of an interesting situation although many of you must
have already gone through it.
I am facing a situation where I have to use psycopg2 and insert rows in
a postgresql table.
That's pritty easy and no need to say that it works well.  But there are
some entries which have an ' in the value.
I have a venders table in my database and one of the values tryed was
"His Master's Voice " 
now the master's word has the ' which is used for starting and ending a
varchar value for postgresql or almost any standard RDBMS.
Does any one know what is the way out of this?
how do you let the ' go as a part of the string?
I have used %s as placeholder as in 
queryString = "insert into venders values ('%s,%s,%s" %
(field1,field2,field3 ) ...
This is not working for the ' values.
can any one suggest a suitable solution?
happy hacking.
Krishnakant.

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


Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Krishnakant
hello all,
thanks for all of your very quick responses.
The problem is that I am using python 2.5 so the 2.6 syntax does not
apply in my case.
secondly, My problem is very unique.
I have created a function called executeProcedure in python which calls
stored procedures in postgresql.
The fun part of this function is that it has just got 3 standard
parameters namely the name of the sp to be called, whether it returns 1
or more records as a result and the list containing the input parameters
which that sp will need for execution.
So no matter what your sp does as in insert update delete or select, no
matter there is one param or 10 all you have to do is pass one string
containing the function name, one boolean and one list of params.
The rest is taken care by this python function.
So now all hackers will understand that the query to call the stored
procedure namely cursor.execute(select * from functname ) will be built
dynamically.
So now in this situation I have to build the querystring and then pass
it to execute of the cursor.
in this case, I get a problem when there is ' in any of the values
during insert or update.
If any one wants this code, Please let me know.  You all can get a lot
of utility out of the function.
This only becomes a problem when an ' comes in the value.
So I need help to fix the problem with the given context.
happy hacking.
Krishnakant.
On Mon, 2008-12-15 at 07:21 -0600, Lamonte Harris wrote:
> sorry about that
> 
> queryString = "insert into venders
> values('{0}','{1}','{2}')".format(field1,field2,field3)
> 
> On Mon, Dec 15, 2008 at 7:21 AM, Lamonte Harris
>  wrote:
> I had this problem too.  If you've upgraded to python 2.6 you
> need to use the new sytnax "format
> 
> queryString = "insert into venders
> values('{0}','{1}','{2}'".format(field1,field2,field3)
> 
> 
> 
> On Mon, Dec 15, 2008 at 6:46 AM, Krishnakant
>  wrote:
> hello all hackers.
> This is some kind of an interesting situation although
> many of you must
> have already gone through it.
> I am facing a situation where I have to use psycopg2
> and insert rows in
> a postgresql table.
> That's pritty easy and no need to say that it works
> well.  But there are
> some entries which have an ' in the value.
> I have a venders table in my database and one of the
> values tryed was
> "His Master's Voice "
> now the master's word has the ' which is used for
> starting and ending a
> varchar value for postgresql or almost any standard
> RDBMS.
> Does any one know what is the way out of this?
> how do you let the ' go as a part of the string?
> I have used %s as placeholder as in
> queryString = "insert into venders values ('%s,%s,%s"
> %
> (field1,field2,field3 ) ...
> This is not working for the ' values.
> can any one suggest a suitable solution?
> happy hacking.
> Krishnakant.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 

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


Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Krishnakant
Hi steve.
you are right.
Thanks for all you who helped to understand how to and *not* to pass
queries through psycopg2 which is a module based on python dbapi.
the following query worked.
cursor.execute("insert into vendors values(%s,%s)", lstParams)
lstParams contained all the values and yes one had an ' in it.
thanks again for all the help.
happy hacking.
Krishnakant.
On Mon, 2008-12-15 at 12:35 -0500, Steve Holden wrote:
> Lamonte Harris wrote:
> > I had this problem too.  If you've upgraded to python 2.6 you need to
> > use the new sytnax "format
> > 
> > queryString = "insert into venders
> > values('{0}','{1}','{2}'".format(field1,field2,field3)
> > 
> Will all readers of this thread kindly regard this as an example of how
> *not* to generate and execute SQL queries in Python. Study the
> cursor.execute() method, and provide parameterized queries and a data
> tuple instead.
> 
> Please also note that the above technique explicitly continues to
> generate SQL syntax errors in Krishnakan's case where the data values
> themselves contain apostrophes.
> 
> regards
>  Steve

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


Re: Python is slow

2008-12-21 Thread Krishnakant
With my current experience with java, python and perl, I can only
suggest one thing to who ever feels that python or any language is slow.
By the way there is only one language with is fastest and that is
assembly.
And with regards to python, I am writing pritty heavy duty applications
right now.
Just to mention I am totally blind and I use a screen reader called orca
on the gnome desktop.  I hope readers here can understand that a screen
reader has to do a lot of real-time information processing and respond
with lightenning speed.
And Orca the scree reader is coded totally in python.
So that is one example.
So conclusion is is how you enhance your program by utilising the best
aspects of python.
happy hacking.
Krishnakant.
On Sun, 2008-12-21 at 16:33 +, MRAB wrote:
> Marc 'BlackJack' Rintsch wrote:
> > On Sat, 20 Dec 2008 14:18:40 -0800, cm_gui wrote:
> > 
> >>> Seriously cm_gui, you're a fool.
> >>> Python is not slow.
> >> haha, getting hostile?
> >> python fans sure are a nasty crowd.
> >>
> >> Python is SLOW.
> >>
> >> when i have the time, i will elaborate on this.
> > 
> > You are not fast enough to elaborate on Python's slowness!?  :-)
> > 
> > cm_gui is slow!
> > 
> > Ciao,
> > Marc 'BlackJack' Rintsch
> > 
> Correction:
> 
> cm_gui is SLOW! :-)
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: Python's popularity

2008-12-22 Thread Krishnakant
hello hackers.
Python is best at high level calculations and as an indication, Please
note that I am leading a team on developing an accounting software which
will be modular and would suit the economic conditions of developed and
almost developed countries like India.
I find that number crunching and heavy calculations is shear programming
bliss in python.
At the front end we are using pygtk and find it very light and zippy.
And we are going to use twisted for middle layer and reportlab for
reporting.
And the development so far is pritty smooth and our programmres who
learned python for the first time are just amaised about the fact that
how easily python can do a certain thing.
So i don't know what others think but python is not just a good
scripting language (not that being a good scripting language is some
thing bad ) but also a complete enterprise ready language with given
frameworks like twisted.
happy hacking.
Krishnakant.
On Mon, 2008-12-22 at 12:59 -0500, Tommy Grav wrote:
> On Dec 22, 2008, at 12:48 PM, walterbyrd wrote:
> >> Now since Python *is not* the only language on it's block, we have to
> >> compete with our main nemesis(Ruby) for survival
> >
> > I think both python and ruby will "survive." I think python is also
> > competing with perl in the sysadmin space - although I see perl as
> > being much more popular there.
> 
> Python is making great headway in the physical sciences. Especially
> in astronomy Python has become a real player as not only a tool for
> quick and dirty calculations, but more serious number crunching using
> the great numpy and scipy libraries. With Cython, I, think it will  
> even start
> taking over some of the speed critical niche from C and Fortran.
> 
> Cheers
>Tommy
> --
> http://mail.python.org/mailman/listinfo/python-list

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


searching for an easy library to create OpenOffice spreadsheets

2009-03-06 Thread Krishnakant
Hello all,
I am looking out for a python library which does the followingg.
1, create and manipulate openoffice spreadsheets.
2, allow for cell formatting including merging cells.
3, allow for colouring cells and formatting data as bold italics etc.
4, alignment of data should be possible.
I looked at ooolib but did not find a method for merging cells.

any ideas?

happy hacking.
Krishnakant.
 

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


last and final attempt to search for python ods library.

2009-03-08 Thread Krishnakant
hello all,  Sorry for the frustrated mail.

This is my last attempt to search for a nice python library for creating
open document spreadsheet.

I tryed python-ooolib but did not find a few features like merging cells
(may be I am missing out some thing stupid ).

I have asked for some help before on this topic but seems there is no
such library in python.

Pritty strange that python can't do this much.

So please tell me if any one knows of a good solution for my problem
else I am forced to give up python for my task.

happy hacking/
Krishnakant.



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


Re: last and final attempt to search for python ods library.

2009-03-09 Thread Krishnakant
Hi Terry,

Well, You did reply i know, but seems i lost that mail some where,
My mail client must have messed up the mail.

any ways thanks for your reply,
Right now I am stuck very badly.

The problem is that I am trying python-ooolib and did find the library
pritty good.
But the problem is that library is missing a major feature from my
requirement context.
I need to merge cells in a spreadsheet and this library won't do that.

Do you know how I can work around this?

I tryed searching for py2odf but did ont find any results.

Do you want me to continue on the previous thread (I will try and dig
that out ).


happy hacking.
Krishnakant.

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


Re: last and final attempt to search for python ods library.

2009-03-10 Thread Krishnakant
On Mon, 2009-03-09 at 15:55 -0400, Terry Reedy wrote:
> I think you are confusing process and result.  The result is a cell that 
> spans more than one column or row *when displayed*, thus hiding the 
> cells that would otherwise be displayed. This is, I am 99.9% sure, 
> controlled by an attribute of the visually expanded cell.
> 
That might be the case imho, But I tried increasing the width of the
column using python-ooolib and i could not get the effect of a merged
cells.

I am now trying odfpy and hope it will do what I want.


> In OOCalc, the process is to mark a block of cells and select Format / 
> Merge Cells.  But still, the result will be a change in the upper left 
> attribute.  Thus I suggested you make a .ods file with expanded cells 
> and then read the xml to see what cell element attribute is set thereby. 
> Any decent odf library will be able to set element attributes.
> What did you mean by the upper left attribute, are you asuming that the 
> merged cells are in the top row? In my case that's actually the case beacuse  
> because I want my python script to generate an ods file with the cells in the 
> top row merged from let's say a1 to d1.
Talking about the xml, which file should I look at to see the effect of
merging cells?




> If the about-to-be hidden cells are not empty, OOCcalc gives you the 
> option of converting all cell contents to strings and joining them into 
> one string in the expanded cell.  If you create .ods from scratch, you 
> should never need to do this.  If you edit an existing .ods, something like
>' '.join(str(cell.contents for cell in merge_group))
> possibly in a function that also sets the attribute, should be easy 
> enough to write.  And, of course, you will be able to do things other 
> than the one option OOCalc gives you.
> 
This is exactly what I was trying to achieve with the python-ooolib
module but could not do it.
The library did have a cet_cell_property function but did not allow for
merging.

> In other words, I do not think you *need* an existing cell-merge function.
> 
But the library I use does not allow me to try the method you suggested.
Seems that I will have to look at the xml and write my own module.

> > Do you know how I can work around this?
> 
> See above.
> 
> > I tryed searching for py2odf but did ont find any results.
> 
> Whoops. odfpy at
> http://opendocumentfellowship.com/development/projects/odfpy
> 
> but I strongly suspect you can do what you want with python-ooolib.
> 
No buddy, I tryed with ooolib but now given up unless some one points
out what I am missing.
happy hacking.
Krishnakant.



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


Re: last and final attempt to search for python ods library.

2009-03-10 Thread Krishnakant
On Tue, 2009-03-10 at 00:27 -0400, Terry Reedy wrote:

> In any case, api-for-odfpy.odt has
> 
I am going through the documentation for odfpy but finding it pritty
complex right now.
> 5.17.12 table.CoveredTableCell
> Requires the following attributes: No attribute is required.
> Allows the following attributes: booleanvalue, contentvalidationname, 
> currency, datevalue, formula, numbercolumnsrepeated, protect, 
> stringvalue, stylename, timevalue, value, valuetype.
> These elements contain table.CoveredTableCell: table.TableRow.
> The following elements occur in table.CoveredTableCell: dr3d.Scene, 
> draw.A, draw.Caption, ...
> 
So merged cells are refered to as covered cells is it?
> so odfpy, at least, can create such elements.
> 
Do you have any code sample done in odfpy which I can browse throu and
run it to see the results.

> > 
> > Here's an example of 2 merged ranges: A1:C2 contains the text "foo"
> > and D1:D2 contains "bar"
> > 
> > 
> > -  > table:number-columns-spanned="3" table:number-rows-spanned="2">
> >   foo
> >   
> >   
> > -  > table:number-columns-spanned="1" table:number-rows-spanned="2">
> >   bar
> >   
> >   
> > - 
> >   
> >   
> > 
> > Aside: If you are wondering where the cell addresses (D1 etc) are,
> > they're in the reader's current_row and current_col variables :-)
> > Perhaps this was intended to save space, but what of table:number-
> > columns-repeated="4" ??
> 

I guess I got the point, but still can't figure out how I could actually
implement this because I find the documentation of odfpy pritty complex
and does not have the kind of example which shows what you explained in
the above code.

And the problem is that I got a bit confused in the above code because
my merging happens only in the top row and spanns columns not rows.

I would be very happy if I could get the code wich creates a set of
merged cells in a single row with some data in it.

I managed to do the odt part in the odfpy because the examples were
there and well documented.

happy hacking.
Krishnakant.
 

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


Re: last and final attempt to search for python ods library.

2009-03-10 Thread Krishnakant

> > any ways thanks for your reply,
> > Right now I am stuck very badly.
> >
> > The problem is that I am trying python-ooolib and did find the library
> > pritty good.
> 
> There's another one called ooolib-python; have you had a look at that?
> 
Can you provide the url?  Actually I think I saw this library but it
seems it is not well maintained and the author is no more active.

I think it is supporting old formats if I am talking about the same
library.  So please send me the link so that I confirm my doubts.

> > But the problem is that library is missing a major feature from my
> > requirement context.
> > I need to merge cells in a spreadsheet and this library won't do that.
> >
> > Do you know how I can work around this?
> 
> Here's a radical suggestion: Ask the author directly, or pop a note in
> the suggestion box on the sourceforge tracker [hint: don't use your
> mail client for this].
> 
I did send him a message but did not get any reply for the email.

I will put this request on sourceforge.net as per your suggestion any
how.

> >
> > I tryed searching for py2odf but did ont find any results.
> >
> > Do you want me to continue on the previous thread (I will try and dig
> > that out ).
> 
> Nah, just hijack a third thread :-)
> 
Thanks for that suggestion, I am not that multi threaded *smile*.
I have fixt my mail problem now so every things seems to be fine (untill
i hyjak another thread by accident LOL!).

happy hacking.
Krishnakant.


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


Re: last and final attempt to search for python ods library.

2009-03-10 Thread Krishnakant
Hi John,

I tryed this same library to begin with.

python-ooolib is very good except that it misses a major feature of cell
merging (spanning ).

That is the point from which I started the thread.
I even thought the author of that library will respond back but did not
happen.

Seams it is a very old library and no development happens on it.

happy hacking.
Krishnakant.


On Tue, 2009-03-10 at 23:44 +1100, John Machin wrote:
> On 10/03/2009 10:35 PM, Krishnakant wrote:
> >>> any ways thanks for your reply,
> >>> Right now I am stuck very badly.
> >>>
> >>> The problem is that I am trying python-ooolib and did find the library
> >>> pritty good.
> >> There's another one called ooolib-python; have you had a look at that?
> >>
> > Can you provide the url?  Actually I think I saw this library but it
> > seems it is not well maintained and the author is no more active.
> > 
> > I think it is supporting old formats if I am talking about the same
> > library.  So please send me the link so that I confirm my doubts.
> 
> http://ooolib.sourceforge.net/ calls it ooolib-python, but in 
> topsy-turvy land 
> (http://packages.debian.org/unstable/python/python-ooolib) it's called 
> python-ooolib but all you need in the end is import ooolib.
> 
> Three are one and one is three :-)
> 
> 

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


finally successful in ods with python, just one help needed.

2009-03-12 Thread Krishnakant
Hello all specially John and Terry.

I finally got my way around odfpy and could manage the spreadsheet to
some extent.

However I now have a small but unexpected problem.

I would be very happy if some one could help me understand why is the
text not getting centered in the spreadsheet I create.

The cell merging is happening but no text centering in those merged
cells.

If any one is interested I can send my part of code snippid.
to just tell in short, it just has the sudo code as 
create document

create a style to set centered text 

create table and add rows to which cells are added.
the cell has a p (paragraph ) element with the style of centered text
applied.

cells are merged 

but no centering happens.

Please let me know if any one wanted me to send the code off the list.

Even better, if some one has a code snippid which can just do that.

happy hacking.
Krishnakant.




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


Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread Krishnakant
On Thu, 2009-03-12 at 14:49 -0700, John Machin wrote:

> I see that you haven't had the evil spirits exorcised from your mail/
> news client ... it's hijacked a thread again :-(
> don't worry, won't happen this time.

It seams I did some thing wrong with the settings and it drops out
mails.
Now the problem is sorted out.

> >
> > The cell merging is happening but no text centering in those merged
> > cells.
> >
> > If any one is interested I can send my part of code snippid.
> > to just tell in short, it just has the sudo code as
> > create document
> >
> > create a style to set centered text
> >
> > create table and add rows to which cells are added.
> > the cell has a p (paragraph ) element with the style of centered text
> > applied.
> >
> > cells are merged
> >
> > but no centering happens.
> >
> > Please let me know if any one wanted me to send the code off the list.
> >
> > Even better, if some one has a code snippid which can just do that.
> 
> You might like to try:
> (a) checking that you can get text centred in an UNmerged cell
Tryed, it works perfectly.  The text gets centered in an unmerged cell.

> (b) using Calc, creating a small ods file with your desired
> formatting, then comparing the XML in that ods file with the one your
> script has created
This is the first thing I tryed and even got some insight into the xml.
However when I apply the same elements and attributes to the one I am
creating with odfpy, I get "attribute not allowed " errors.
If some one is interested to look at the code, please let me know, I can
send an attachment off the list so that others are not forced to
download some thing they are not concerned about.

> (c) contacting the author/maintainer of the odfpy package

Done and awaiting the reply for last 4 days.

It was then that I came to this thread.

happy hacking.
Krishnakant.


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


Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread Krishnakant

Hi David,
based on your code snippid I added a couple of lines to actually center
align text in the merged cell in first row.

Please note in the following code that I have added ParagraphProperties
in the imports and created one style with textalign="center" as an
attribute.

*** code follows ***

import sys

from odf.opendocument import OpenDocumentSpreadsheet
from odf.style import Style, TableColumnProperties, ParagraphProperties
from odf.table import Table, TableRow, TableColumn, TableCell,
CoveredTableCell
from odf.text import P
class makeods:
def make_ods(self):
ods = OpenDocumentSpreadsheet()

col = Style(name='col', family='table-column')
col.addElement(TableColumnProperties(columnwidth='1in'))
tablecontents = Style(name="Table Contents", family="paragraph")

tablecontents.addElement(ParagraphProperties(textalign="center"))

table = Table()
table.addElement(TableColumn(numbercolumnsrepeated=3,
stylename=col))
ods.spreadsheet.addElement(table)

# Add first row with cell spanning columns A-C
tr = TableRow()
table.addElement(tr)
tc = TableCell(numbercolumnsspanned=3)
tc.addElement(P(stylename=tablecontents, text="ABC1"))
tr.addElement(tc)
# Uncomment this to more accurately match native file
##tc = CoveredTableCell(numbercolumnsrepeated=2)
##tr.addElement(tc)

# Add two more rows with non-spanning cells
for r in (2,3):
tr = TableRow()
table.addElement(tr)
for c in ('A','B','C'):
tc = TableCell()
tc.addElement(P(text='%s%d' % (c, r)))
tr.addElement(tc)

    ods.save("ods-test.ods")
m = makeods()

m.make_ods()


Still the text in the cell is not centered.

happy hacking.
Krishnakant.


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


Re: finally successful in ods with python, just one help needed.

2009-03-17 Thread Krishnakant
Hi David and John.
Thanks a lot, the problem is solved.

David, your idea was the key to solve the problem.
Actually John in his code and the explanation made it clear that the
wrong attributes were being used on wrong elements.

david's code confirmed the fact.  The center style which david had in
his code solved the problem for me because we don't need paragraph
alignment styles but the merged cells to be having center alignment for
the text contained in those cells.

This implied that the centering aught to happen in the cells when they
are created. So that style was applied to the cells in david's code.

The other mistake was that after merging 4 cells I had to actually add 3
cells to be used by the merged (spanned ) cells.  after those cells I
could start my next set of merged cells.
Initially the mistake I was doing was adding a cell which could span 4
cells and try to add another cell just after the code that created that
merged set of cells.

But later on I realised that once cells are merged we have to physically
add the blank cells to fill up the merged space else the next few cells
won't show up with the other text.

Now the code works fine and if any one would ever need this, please do
write to me.

Thanks to all again, specially David and John.

happy hacking.
Krishnakant.



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


Re: Python + PostgreSQL

2009-03-17 Thread Krishnakant
hello,

On Tue, 2009-03-17 at 09:46 -0700, Lobo wrote:
> Hi,
> 
> I am new to this newsgroup (and new to Python and PostgreSQL). My
> experience (17+ years) has been with Smalltalk (e.g. VAST) and Object
> databases (e.g. Versant, OmniBase).
> 
Welcome to the world of monty pythons,
/\/\/\:

> I now have a new project to develop web applications using the latest/
> best possible versions of Python (3.x?) with PostgreSQL (8.x?, with
> pgAdmin 1.10?).
> 
It is still a better option to go with python 2.x latest releases IMHO.

> I hope to get some hints as of what frameworks/modules to use for this
> specific combination (Python + PostgreSQL)?, should I use django,
> zope, web2py, psycopg module, others?, what are their pros/cons?.
> 
With regards the web apps, zope is the best server I ever saw in my 10
years of II.T curier.

Python-psycopg2 is the most commonly used DBAPI implementations for
postgresql.

happy hacking.
Krishnakant.


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


confused with creating doctest in xmlrpc server

2009-04-03 Thread Krishnakant
hello all,
I am thinking of using the doctest module for my unit testing code in
python.
I have no problems doing this in usual classes but I am a bit confused
with my twisted based rpc classes.

given that I directly take the output of running functions on a python
prompt for the dockstrings, how do I get them for my twisted class which
has a published object?

What I mean is that in normal classes I would just start the python
prompt, import the module, create the object and run the methods to get
the output.

Then I take the output and put it into a file and then use those
dockstrings for my tests.
As you all know an rpc server app can't be run like this.  To my
knowledge an rpc server is a service that listens on a port on the given
ip address.

So how do I extract the dockstrings from the functions inside my xmlrpc
class?
obviously it is not run on a python prompt, so what is the solution?

happy hacking.
Krishnakant.




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


Re: Can someone explain about the usage of unittest.TestSuite?

2009-04-09 Thread Krishnakant

On Thu, 2009-04-09 at 12:35 +0530, srinivasan srinivas wrote:
> Hi,
> I would like to know about the unittest.TestSuite clearly like at what 
> situations i can use this TestSuite? I am not getting the clear difference 
> between this and unittest.TestCase.
> 
> Thanks,
> Srini
> 
Isn't that pritty simple and streight?
test suite is used when you want to combine the different test cases.


you can find more insight into this at
http://www.eecho.info/Echo/python/test-driven-development-in-python/
happy hacking.
Krishnakant
 

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


Re: need to start a new project , can python do all that ?

2009-04-15 Thread Krishnakant
On Wed, 2009-04-15 at 05:22 -0700, Deep_Feelings wrote:
> I want to start programming a new program (electronic health care
> center) in python and before start learning python i wanna make sure
> that python does have all the features i need to accomplish this
> project so i wanna ask you does python able to support these
> features :
> 
Python of course fits such projects and due to the fact that it is fast
and zippi, it becomes the bes choice.
> 1- cross platform (windows + linux)
Very much.
> 2- mysql database access
The python-mysql module complies with the python db api and talks to
mysql.
As a side note, postgresql is a really scalable, robust and powerful
database and python has a very matured library for talking to it as
well. 
> 3- 2D graphs (curves)
Possible with many libraries.
> 4- support of international languages
> 5- can access a scanner and input pictures from it.
> 
Internationalisation is there in almost every language these days and
python is no exception.

happy hacking.
Krishnakant.


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


can python access OS level features like bash scripting?

2009-04-19 Thread Krishnakant
Hello all,
Right now I am a bit confused on a final stage of my project.

I need to create an installer and an executable file for my python
program for gnu/linux.

The install script has to put the package into site-packages folder
where all other libraries reside.  Then put the executable file
into /usr/bin as other files.

The installer must also do the basic task of creating the database and
setting up password for on postgresql.
now here comes the main problem.
I believe putting files into proper places is pritty easy (may be some
one will instantly reply to the issue of putting the executable file and
libraries in place ).  But to do the database based activities, I need
python-psycopg2 module for postgresql in the first place.  So is it
possible for python to self download and install all the necessary
modules on to the client machine?

What further complicates the system is the fact that I want in future to
create 2 deb files, one for installing the gtk based client application
and the other to install the server side app made in python-twisted for
rpc.  Now the obvious problem is that first my python installation
(either 2.5 or 2.4) must check for itself if the modules are present or
not and if they are not present, my install utility must either download
it from net or if that's not the recommended approach then compile the
module from the source.

how do I achieve all this in python?
I know bash could be used to do such things but I don't want to use bash
because it is to clunky and won't run easily on windows.
Moreover I want to create a deb file as I said before so I want to keep
it as simple as possible.

Even regarding the executable, I am confused on using bash as the script
for writing the executable which can then do some thing like python -c
and call the modules, or write this executable code in a main.py and put
that file into the executable path i.e /usr/bin.

Please clear this mater so that I can go ahead.

I know the python list is pritty busy and I must thank all the members
who keep the spirit of the community and the professional organisations
alive so may be I will get a solution to my problem soon.

happy hacking.
Krishnakant.


  







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


Re: can python access OS level features like bash scripting?

2009-04-19 Thread Krishnakant

sorry, but I was not replying to another thread.

My mistake.

happy hacking.
Krishnakant.



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


Re: can python access OS level features like bash scripting?

2009-04-19 Thread Krishnakant
hi very sorry for that 

On Sun, 2009-04-19 at 14:50 +0200, News123 wrote:
> Hi,
> 
> I think you got lost in the wrong thread.
> Though your subject line is correct your post threads under "Is there a
> programming language, that . . . "
> 
> Perhaps you 'replied' to above thread and changed 'just' the subject line.
> 
> Chances to get an answer might be higher if you repost your question
> without replying to an existing thread.
> I did not mean to do so, may be just missed out on removing the lines of the 
> previous thread.

sorry again.
I hope this becomes a new thread now and I get some productive reply.
happy hacking.
Krishnakant.




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


Re: Python interpreter speed

2009-04-19 Thread Krishnakant
I don't mean to start a flame war, but a productive debate will be
wonderful.  I have been writing heavy applications in java for a few
years untill recent past.
My experience is that python is not just fast but also zippy and smooth
when it comes to running the applications.

Infact I have a couple of softwares which were re coded in python for
this very reason.  So I would like to know real facts on this arguement.

Let me mention that out of these 2 apps one is a distributed application
with an rpc layer and other is a normal back and front end database
driven software.  both have heavy load on them and do a lot of number
crunching and complex calculations.

happy hacking.
Krishnakant.

On Sun, 2009-04-19 at 18:11 +0200, Ryniek90 wrote:
> Hi.
> 
> Standard Python interpreter's implementation is written in C language. C 
> code while compilation, is compilled into machine code (the fastest 
> code). Python code is compiled into into byte-code which is also some 
> sort of fast machine code. So why Python interpreter is slower than Java 
> VM? Being written in C and compilled into machine code, it should be as 
> fast as C/Asm code.
> What's wrong with that?
> 
> Greets and thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: can python access OS level features like bash scripting?

2009-04-19 Thread Krishnakant
On Sun, 2009-04-19 at 14:55 -0300, Gabriel Genellina wrote:

> Write a setup.py script using the distutils package:
> http://docs.python.org/distutils/index.html
> 
So that can distutil do the work of setting up the database and can it
find for itself if psycopg2 and other related libraries are installed?
I am going to create a deb file, so is it a good idea to some how have
the deb rules execute the setup.py file of the distutils?

Besides, I will also like to create a single file containing all the
modules i need as dependencies so even if a user does not have internet,
we can still install the package on that machine.

So will it be a good idea to let distutils do every thing I had
described about putting files in the place and having the script copyed
to /usr/bin etc?

happy hacking.
Krishnakant.
 


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


Re: Python interpreter speed

2009-04-20 Thread Krishnakant
On Mon, 2009-04-20 at 20:12 +0100, Tim Wintle wrote:

> 
> I can't remember Java properly, but...
> 
> Firstly, speed will depend on what you're writing. I dont' actually know
> how much slower python is, but I'm sure there are some things that run
> faster in python.
> 
I know many instences which eventually show that python is faster.

Compare eclipse and glade.  I am not a hard core hacker on compiles or
interpriters but as an end-user, I see almost all java programs r pritty
heavy on memory and python is pritty fast and zippy.


I for example use a screen reader called orca, because I am totally
blind.

Guess what, the screen reader moniters every event that happens in the
OS (gnu) and also extracts all the information of every widget and keeps
track of the location of the focus and many more things and also
constantly streems output to a speech synthesizer as it take the
information from the desktop.

All this should happen at run-time without any latency.  This software
is in python and it delivers what it is supposed to at great speed.

Further, I have an accounting software which was previously in java, but
now in python and the performance gain is ausom.

Yes it depends on how we write the code but comparing the 2 at least at
the middle layer and front-end (pygtk) python is faster than java.
Infact I am most certain that swing is not even 50% as fast as pygtk or
pyqt.

These are my personal observations and should not be taken as
generalisations.

happy hacking.
Krishnakant.


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


confused with so many python package locations for imports

2009-04-24 Thread Krishnakant

hello all,
I was doing my first complete python packaging for my software and I am
totally confused.
I see, /usr/local/lib/python-2.6/site-packages and also dist-packages.
Then I also see a directory called pyshare, then again site-packages in
usr/lib/python (I am not even remembering correct paths for many such
locations ).

Now my question is, which the perfect place?  I would like to know if I
write a distutils based setup.py for my application, then which is the
place which I should choose?

happy hacking.
Krishnakant.


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


Re: confused with so many python package locations for imports

2009-04-25 Thread Krishnakant
On Sat, 2009-04-25 at 14:16 +0900, David Cournapeau wrote:
> Some of those locations are OS specific - pyshare is specific to
> debian I think, for example.
> 
My Basic question is that, what package directory is Standard as far as
all gnu/linux distros are concerned?
In other words I would like to know if there is some package   directory
which is searched by default  for installed packages?  I believed it
was /usr/local/lib/python2.6/site-packages.  
In the case of python 2.5 it must be the same, but correct me if I am
wrong.  I want my distutils setup.py to setup the package so that an
import statement can import the package no matter what distro of
gnu/linux we are running.

happy hacking.
Krishnakant.



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


Re: confused with so many python package locations for imports

2009-04-25 Thread Krishnakant
On Sat, 2009-04-25 at 18:31 +1000, Ben Finney wrote:
> Python has a habit of generating, and expecting to find,
> platform-specific files (‘foo.pyo’ extension modules), compiled bytecode
> files (‘foo.pyc’), and module source files (‘foo.py’) necessarily in the
> same directory for purpose of locating them at import time.
> 
Thanks a lot for this information.
So now if I say for example choose ubuntu and debian for my testing
purpose, should I put all the packages I make
into /usr/local/lib/python2.6/site-packages?  Will this be a safe choice
for at least debian and Ubuntu?

I will later on think of fedora etc.

happy hacking.
Krishnakant.
 


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


Re: Connecting/talking to OpenOffice Base files

2009-04-28 Thread Krishnakant
hi,
On Tue, 2009-04-28 at 05:24 -0700, deostroll wrote:
> Hi,
> 
> I was wondering if the python interpretor can talk to files with
> extension *.odb (OpenOffice Base files). They are like flat database
> files, similar to Microsoft Access files. I want to store data into
> them as well as extract data out of them.
> 
This is done either  using ooolib if you want to do some simple read and
write tasks or then use odfpy which is a complete library.

I had asked the same question a few months back and come from the same
path you are coming.

But odfpy was initially difficult for me and would take a while to
understand.
It is a kind of wrapper around the xml structure of an odf document.

happy hacking.
Krishnakant.

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

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


problem with money datatype based calculations in python

2009-05-02 Thread Krishnakant
hello all,
I am using postgresql as a database server for my db application.

The database is related to accounts and point of sales and many
calculations involve money datatype.

The application logic is totally done in python.  Now the problem is
that there is a situation where we calculate tax on % of the total
amount on the invoice.  The  percentage is in terms of float but the
eventual amount has to be in a money datatype.

The product cost comes in money datatype from postgresql and the tax %
comes in float.  So I would like to know if python supports some thing
similar to money datatype so that I can cast my total amount (in money )
divided by tax% (in float ) so money divided by float should be the
result and that result should be in money datatype.
For example a product x has the cost Rs. 100 which is stored in the
tabel as money type.  and in the tax table for that product the VAT is
5% and this 5% is stored in float datatype.  So after using both these
values the resulting total 105Rs. should be in money type and not float.
I awaite some reply,
Thanks in advice.
happy hacking.
Krishnakant.

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


interesting float to money conversion problem

2009-05-02 Thread Krishnakant
hello all,
> > I am using postgresql as a database server for my db application.
> > 
> > The database is related to accounts and point of sales and many
> > calculations involve money datatype.
> > 
> > The application logic is totally done in python.  Now the problem is
> > that there is a situation where we calculate tax on % of the total
> > amount on the invoice.  The  percentage is in terms of float but the
> > eventual amount has to be in a money datatype.
> > 
> > The product cost comes in money datatype from postgresql and the tax %
> > comes in float.  So I would like to know if python supports some thing
> > similar to money datatype so that I can cast my total amount (in money )
> > divided by tax% (in float ) so money divided by float should be the
> > result and that result should be in money datatype.
> > For example a product x has the cost Rs. 100 which is stored in the
> > tabel as money type.  and in the tax table for that product the VAT is
> > 5% and this 5% is stored in float datatype.  So after using both these
> > values the resulting total 105Rs. should be in money type and not float.
> > I awaite some reply,
> > Thanks in advice.
> > happy hacking.
> > Krishnakant.
> > 
> > --
> > http://mail.python.org/mailman/listinfo/python-list

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


Re: problem with money datatype based calculations in python

2009-05-02 Thread Krishnakant
On Sat, 2009-05-02 at 11:57 -0400, D'Arcy J.M. Cain wrote:
> And if you use PyGreSQL (http://www.PyGreSQL.org/) to connect to
> the database then the money type is already converted to Decimal.
> d'arcy, I visited the home page for pygresql and discovered that you wrote 
> the library.
I am happy that you also included a non-dbapi (postgresql classic
interface ) along with the standard DBAPI module.

I would like to know if it has been tested with postgresql 8.3 and are
there any known bottlenecks while using this driver module on large
scale database opperations?
Is this actively maintained?
Perhaps this might be off topic but may I ask, how is pypgsql, 
>  
Has any one used pgsql for any postgresql based software?
and between pygresql and pypgsql which one is more maintained?

the system I am developing is a mission critical financial application
and I must be pritty sure about any module I am using.

happy hacking.
Krishnakant.



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


Re: problem with money datatype based calculations in python

2009-05-03 Thread Krishnakant
On Sun, 2009-05-03 at 03:20 +, D'Arcy J.M. Cain wrote:
> Sorry, I should have mentioned my bias.  :-)
> No problems at all.  It is a very good library.  I get an impression that it 
> is realy a mature module and a very powerful set of API. 

> > I would like to know if it has been tested with postgresql 8.3 and are
> 
> The current version of PyGreSQL has been tested with Python 2.5 and
> PostGreSQL 8.3. Older version should work as well, but you will need
> at least Python 2.3 and PostgreSQL 7.4.
> 
Ah, I am using python 2.6 and postgresql 8.3

I am really impressed with the library.  I want some manual or tutorial
for the same and if possible can you write me off the list with a small
tutorial for things like connecting to the database, sending queries,
and working with the resultset at the client site.

I will be really happy if this library also supports calling a stored
procedurs directly.  Psycopg2 does not have such a feature and I had to
create one small module which does that work.

What it does is that you just give the name of the procuedure procedure
as the first parameter and a list of arguements as the second parameter.
That's all, you will get the result because the query  for the call is
created inside the module and the programmer need not worry about what
the sored procedure looks like.

Never the less I am expecting that pygresql has some infrastructure for
making calls to the stored procedures.  Please send me some tutorial off
the list.

happy hacking.
Krishnakant.


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


Re: Which python version do I use with "virtualenv"?

2009-05-07 Thread Krishnakant
I have another question in this same context.
I have python 2.6 and want to set up a vertualenv
in /opt/turbogears/python2.5.
Then use this for all the things a turbogears based application would
need for project execution.

so I have decided that I will download python 2.5 and compile it
with ./configure --prefix=/opt/turbogears/python2.5 and then install
turbogears.  Is this possible?  will this kind of python compilation
help me to create a vertualenv in the place where I have python2.5?

or is there any other way to do this?  I really need vertualenv and
would want to use python2.5 because I feel easy install won't work with
python2.6

happy hacking.
Krishnakant.




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


Re: Which python version do I use with "virtualenv"?

2009-05-07 Thread Krishnakant

> You are confusing virtualenv with a custom-build python. You can of course
> use VE with a custom-build python, but then there isn't as much use for it,
> as you then have a distinct python-instance already - unless you are going
> to share it amongst projects, which then leads to the question why you
> don't use VE *without* the custom-build python.
Well, Turbogears works perfectly with python2.5, although there are
people who use it with 2.6 as well.
I have to keep 2.6 because my screen reader orca giave me some problem
with 2.5.

So I have no option but to keep a seperate python2.5 in some different
directory and have ve use it.

would just like to know how I can get ve to use that installation and
not the one on my system by default.

happy hacking.
Krishnakant.
  



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


Re: How can i use Spread Sheet as Data Store

2009-05-18 Thread Krishnakant
Hi Kaliyan,
It is very simple.
There is a library called odfpy which you can use to read and write odf
documents.  I highly recommend using open formats so that the API is
clear and you can ask help if needed.
The odfpy library has modules to create spreadsheets and read or write
by row or sell etc.

happy hacking.
Krishnakant.
 
On Mon, 2009-05-18 at 16:31 +0530, Kalyan Chakravarthy wrote:
> Hi All,
>  I have data in Spread Sheet ( First Name and Last Name),
> how can i see  this data  in Python code ( how can i use Spread Sheet
> as Data Store ) . 
> 
> -- 
> Regards
> Kalyan
> 

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


Re: issue: Permissions in odfpy

2009-05-19 Thread Krishnakant
Through the python code,
chmod 400 
happy hacking.
Krishnakant.

On Tue, 2009-05-19 at 12:21 +0530, shruti surve wrote:
> hey,
> i am using odfpy and  generating spreadsheet in open office..but
> nobody should modify the file..so can anybody tell me how can we give
> permissions (read only) to spreadsheet in odfpy??..i have change the
> properties of my normal open office spreadsheet file and made it read
> only..n also extracted it..but in conteny.xml also i am not finding
> any property which can be used in odfpy...so please give me some
> solution..
> 
> 
> regards
> shruti surve

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


Re: Performance java vs. python

2009-05-19 Thread Krishnakant
On Tue, 2009-05-19 at 10:42 -0700, Daniel Fetchinson wrote:
> Benchmarks always test for a given feature. The available benchmarks
> will most likely not test the feature relevant for your particular
> application simply because there are about a gazillion different ways
> of using a web framework. So the best you can do is simply test the
> bottleneck part of your application and see for yourself, 
Bingo! there will be hundreds of threads on this mailing list and many
others which exactly do that.  And it also serves as a great food for
those bashing birds who just need a spart to start a flamewar.

Till date I have worked with both languages into their core as will as
with many libraries for different tasks.

Fortunately I have some assessment for web frameworks which is based
mostly on my personal experience and partially on some obvious facts.

At the outset, I have seen that python's syntax is pritty clean and as
some previous mail said on this thread, it needs just a few hours and
the language is compact enough to fit in your head.
Readers might ask, "so how is this associated with performance boosting
etc?"  
Quite a good question.  You see, the scope for making quick and suttle
changes in the code should be wide enough and easy to do as wel.

Since python has such easy and clean syntax and with the idea of
"battries included ", it is much more quicker and easier to tune the
application for many things including performance.

Since I feel comfortable with the language I am confident enough that my
code won't break too much when I try to do some serious alteration to
the code.  This alteration might now be to change the logic but to
improve performance.  This is the challenge and python is such a
language that manipulating to this level is pritty doable in short
period of time.

Secondly, Java it seems comes with a lot of bagage which might be the
case with python as well.  But some how I don't know, python seems to be
much light weight then java.
May be there are many technical reasons for this and at the web
application side it seems to be compact zippi and fast.  Again this
might be my personal assessment,and specially with database driven
application, no language can be absolutely better than the other and as
rightly suggested, test it on the bottleneck issues and fine tune that
particular part.  I have seen many apps migrating from ejb based
framework to python, particularly one I remember in pylons and the
feedback has been positive.
 
Another thing is that I personally like to use OOP *only* when needed.
Java would force me to write classes (add the over doing with static
functions ) for every thing I do including a small function just for
returning a connection object.

This again is a major reason for me to stick to python.

In addition python also can do the kind of work, j2ME can do and so I
don't think there is any serious reason for choosing java over python.
I am currently developing a major application and it is currently using
the twisted library for xmlrpc and there is a thin client in pygtk.
Right now we are in the process of moving it to turbogears2 and so far
performance on both the ends have been good.

happy hacking.
Krishnakant.

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


Re: Are Python-based web frameworks reliable enough?

2009-05-25 Thread Krishnakant
On Mon, 2009-05-25 at 20:49 +0200, Gilles Ganault wrote:
> Hello
> 
>   Until now, the modest web apps I wrote were all in PHP because it's
> available on just about any hosted server.
> 
> I now have a couple of ideas for applications where I would deploy my
> own servers, so that I'd rather write them in Python because I find
> the language more pleasant to write with.
> Certainly, You will be much much more productive if you use python provided 
> you are not going to do it the old "cgi " way.

> I read that the traction for the mod_python module isn't as strong as
> mod_php, so I guess I should consider the alternative, which is
> writing a long-running process with some framework like TurboGears or
> Django.
> 
Why not give a try to pylons?  While turbogears is great and very
powerful, it any ways uses most of pylons and pylons is not just rock
solid and robust, it also has very very good documentation.
Not to mention the fact that heavy production applications are today
running pylons.

> To make an informed choice, I'd like your feedback on this:
> 
> 1. Is mod_python a bad choice today? If yes, are there other PHP-like
> modules available, ie. the Python code is hosted in pages that are
> loaded every time a user calls them?
> Even if it was a good choice, cgi method of programming is no more suitable 
> in today's www, because the requirements of a web developer today are much 
> beyond just oepning a connection to a database and sending some processed 
> response in plain old html.
Today's web applications do much more than that so a web framework is
almost always a better choice.

>   
> 2. If you think I should consider long-running processes, are the
> frameworks reliable enough so that I shouldn't fear crashes every so
> often?
> 
No not really, although it is always a better idea to run your
production web app behind apache.  This will keep the server up on very
heavy loads and you will not have to worry about http requests and
responses.  let that be taken care by the best tool (apache ) and let
your application handle how to manage the logic and send out views.

> 3. What about performance as compared to equivalent PHP/MySQL apps?
> 
Performance is very good if you use the right tool in the right place.
This is the biggest advantage of some web frameworks like pylons or tg
over other.
happy hacking.
Krishnakant.



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


Re: Help in wxpython

2009-12-02 Thread Krishnakant
On Wed, 2009-12-02 at 00:20 -0800, madhura vadvalkar wrote:
> Hi
> 
> I am trying to write an  PAINT like application where on the mouse
> click a circle is drawn on canvas. I am new to python and using
> wxpython to create this.
> 
> here is the code:
> 
> import wx
> 
> class SketchWindow(wx.Window):
> 
> def __init__ (self, parent,ID):
> 
> wx.Window.__init__(self, parent, ID)
> 
> self.panel =wx.Panel(self, size= (350,350))
> self.pen=wx.Pen( 'blue',4)
> self.pos=(0,0)
> self.InitBuffer()
> self.Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown)
> 
> def InitBuffer(self):
> 
> size=self.GetClientSize()
> self.Buffer=wx.EmptyBitmap(size.width,size.height)
> dc=wx.BufferedDC(None,self.buffer)
> dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
> dc.Clear()
> self.Drawcircle(dc)
> self.reInitBuffer=False
> 
> def OnLeftDown(self,event):
> self.pos=event.GetPositionTuple()
> self.CaptureMouse()
> 
> def Drawcircle(self,dc):
> pen=wx.Pen(colour,thickness,wx.SOLID)
> dc.SetPen(pen)
> dc.DrawCircle(self.pos.x,self.pos.y,r)
> 
> class SketchFrame(wx.Frame):
> def __init__(self, parent):
> 
> wx.Frame.__init__(self, parent, -1, "Sketch Frame",size=(800,600))
> self.sketch = SketchWindow(self, -1)
> 
> if __name__=='__main__':
> app=wx.PySimpleApp()
> frame=SketchFrame(None)
> frame.Show(True)
> app.MainLoop()
> 
> I am getting the following error:
> 
> Traceback (most recent call last):
>   File "C:/Python26/circle.py", line 42, in 
> frame=SketchFrame(None)
>   File "C:/Python26/circle.py", line 38, in __init__
> self.sketch = SketchWindow(self, -1)
>   File "C:/Python26/circle.py", line 12, in __init__
> self.InitBuffer()
>   File "C:/Python26/circle.py", line 19, in InitBuffer
> dc=wx.BufferedDC(None,self.buffer)
> AttributeError: 'SketchWindow' object has no attribute 'buffer'
> 
> Please tell me what I am doing wrong.
> 
> Thanks
Madhura, Sorry to be a bit off-topic, but, I would really recommend you
to use pygtk instead of wx.
For one thing, the developers at pygtk are very active (they have their
mailing list as well ) and it comes by default with python on almost all
linux distros.  You can also easily install it on windows.

Most important, the api for pygtk is closely similar to wx.
Not to mention the quick responses you will get with pygtk related
problems.

Happy hacking.
Krishnakant.

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


Re: twenty years ago Guido created Python

2010-01-01 Thread Krishnakant
On Fri, 2010-01-01 at 03:25 -0800, J Peyret wrote:
> On Dec 31 2009, 2:06 pm, Steve Howell  wrote:
> > FYI:
> >
> > http://twitter.com/gvanrossum
> >
> > Python is a truly awesome programming language.  Not only is Guido a
> > genius language designer, but he is also a great project leader.  What
> > an accomplishment.  Congratulations to everybody who has contributed
> > to Python in the last two decades!
> 
> Notwithstanding all of the above, which are all true, having met
> Guido, I say he is a genuinely nice human being.  Go BSD derivatives.

Indeed,
python is a great programming language.
May be it was not marketted as much as languages like java or not as
much as platforms like rails.
But who cares?  I must mention here that I am totally blind and the
talking software (screen reader ) I use on GNU/Linux called Orca is also
programmed using python.

And I make web applications and off late started to use pylons (  again
centered around python).
I see that python is for 2 kind of programmers.
one which are absolute beginners to programming itself who want to learn
the scientific art of programming and the second is the extreme experts
who need the power and performance nicely balanced.

Great work!

happy hfacking.
Krishnakant.


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


Re: Business issues regarding adapting Python

2009-09-27 Thread Krishnakant
On Sun, 2009-09-27 at 00:13 -0700, Nash wrote:
> Hello everyone,
> Salam Valicum.
I am Krishnakant from Mumbai India and in our country case was exactly
the same but now pritty different in just a matter of few years.
I have answered your queries inline with your questions so read on. 
> I'm a big time python fan and it has helped me write code fast and
> push it out quickly. We have a medium sized telecom product written
> 90% in Python and 10% in Java. The problem is, in the place where we
> work (Pakistan), we can't find Python developers. I asked HR to send
> me figures on how many people do we have available who have worked
> with C++, Java, PHP and Python with 2-3 years of experience. They did
> a search on available candidates on Pakistan's biggest jobsite and
> this is what they sent:
> 
> Almost no-one shows up with Python experience when we put out a job
> opening and now it is becoming a real hurdle. Despite our liking and
> cost savings with the language, we are thinking about shifting to
> Java.

Well, As I said this was a case in India just a few years back.
But now we pritty well find programmers in languages like python or ruby
or php.  The main reason for such growth in the number of python
programmers is the awareness people like myself create amongst the
masses of new computer programmres.
Moreover the industry itself is slowly realising the time and resulting
cost saving by making use of python.


> 1. Have any of you faced a similar issue? How did you resolve it?
I currently lead the development of an accounting software called
GNUKhata ( http://gnukhata.gnulinux.in ) which is totally developed in
python.
Let me tell you that none of the developers working on this project were
python programmers.
It took me about 15 days to train them till intermediate level.  The
trick here is to take good programmers who have good logical sence and
have the fundamental idea of programming in some other language.  For
example the coordinator of this project knew .net pritty well and today
she is a much better python programmer than me.
> 2. Do you think it makes sense to hire good programmers and train them
> on Python?
Exactly.  Look at my anser to your question number 1.
> 3. If we do train people in Python for say a month; are we just
> creating a team of mediocre programmers? Someone who has worked with
> Python for over an year is much different than someone who has worked
> with Python for only a month.
Firstly, that's true with all programming languages.  Whether you will
create good efficient programmers in python depends on how well you use
my trick of taking good programmers proficient in any other language,
and yes they should be open to learning new languages.
May I repeat, including GNUKhata, the accounting software I lead, all
the projects I worked on, we hardly had python programmres.  But we
trained them by making them do porting work and also do some bug fixing.
So the other hack is that you make the new python programmres port the
code from let's say some module in Java.  Now if you hire java
programmers and decide to train them in python for example, then this
trick works very well because they alredy know the language of the
source module and now portint it to python.

Now due to many such projects being done in huge companies in India, we
have a good repository of python programmers.
Remember that popularity of a programming language directly depends on
how much you involve the programmers.

> 4. Any suggestions or idea? Related posts, articles etc would
> certainly help!
> I think you can find that your self.

> I know that going Java will probably mean a 3x increase in the number
> of people that we have and require time for Python component
> replacement with Java ones. But for Business Continuity sake,
> management doesn't mind.
> 

Well, If you take my words as coming from an experienced person, I
highly recommend you to believe in what your inner feelings say about
this decision.
If you feel python will svae cost and time then just go ahead and train
programmers in python.  From your own experience you might have realised
that trainning people in python for a month will be not as bad as
trainning new programmers in java for a month.
I mean the learning curve is very very narrow in python.

Khuda Hafiz.
Krishnakant.


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


Re: Business issues regarding adapting Python

2009-09-27 Thread Krishnakant
On Sun, 2009-09-27 at 10:57 -0400, Simon Forman wrote:
> On Sun, Sep 27, 2009 at 10:48 AM, Nash  wrote:
> > On Sep 27, 4:13 pm, "Martin P. Hellwig" 
> > wrote:
> >> Nash wrote:
> >>
> >> 
> >> I think normal market rules will apply to Pakistan too, if your desired
> >> trade has not the quantity you wish, the price per item should get
> >> higher. Net result should be that more quantity will be available due to
> >> increased interest.
> >>
> >> --
> >> MPHhttp://blog.dcuktec.com
> >> 'If consumed, best digested with added seasoning to own preference.'
> >
> > If I rephrase the question: In an absense of steady Python Developers;
> > can there be a viable strategy involving training? Or will it be much
> > safer going with an already common developer pool.
> >
> > Please note that my goal is not to promote python but to make a sound
> > business decision. Using Python is not an absolute requirement.
> >
> > I appreciate all the feedback thus far, please keep it coming in,
> > thanks everyone!
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> Hire good programmers, they can pick up python rapidly.
> Bingo!  That's the point even I mentioned to Nash in my last email.
When I take interviews of programmres aspiring for a job, I never ask
them which programming language they know and never take them on the
basis of how good they are in comparison to that language for my
projects (in python for example ).

> It's widely acknowledged that hiring good people is a (the?) crucial
> factor in the success of programming endeavors.  "Good" programmers,
> almost by definition, will be able to handle learning python without
> problems.

+ the easy and power of python.
Happy hacking.
Krishnakant.


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


Re: Python book

2009-09-30 Thread Krishnakant
On Wed, 2009-09-30 at 17:38 +0530, Parikshat Dubey wrote:
> "Learning Python" and "Python in a nutshell" from O'Reilly
>  
> Regards
> Parikshat Dubey
> 

How to think like a computer scientist in python is a good book to go
from beginner to intermediate level.
another good book is dive into python.
> 
Mail me off the list if you want the soft book in compressed format.

Happy hacking.
Krishnakant.

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


Re: segmentation fault

2009-10-15 Thread Krishnakant
On Thu, 2009-10-15 at 14:44 +0530, ankita dutta wrote:
> hi, 
> i am relatively new to python programming,
> i am facing the following problem:
> 
> i am tring to simply  obtain data from a file ( "B.txt" ,  data in
> this file are in single column and floats)
> and plot a graph between those values and thier index.  ( for example
> if in file , if at 2nd position valuse is 9.34 ,  x=9.34 and y=1).
> .
> .
> .
> ln1=open("B.txt","r+")
> lines5=ln1.readlines()
> exp=[ ]
> c1=[ ]
> for i in range (0,len(lines1)):
> f1=lines1[i].split()
> c1.append(float(f1[0])) 
> exp.append(i) 
> c1.sort(reverse=1)
> 
> lines=plt.plot(c1,exp,'ro')
> plt.show() 
> .
> .
> .
> 
> but every time its showing the following error:
> 
>   is dumped
> segmentation fault
> 
> 
> can anyone kindly help me out

Ankita,
Do you get same result on many machines?
If you can send the code to me off list I would check it for you.

happy hacking.
Krishnakant.



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


Re: python and Postgresq

2009-11-23 Thread Krishnakant
On Mon, 2009-11-23 at 11:22 +0100, Diez B. Roggisch wrote:
> Andy dixon wrote:
> 
> > Hi,
> > 
> > Does anyone have a link to, or can provide an example script for using
> > python-pgsql (http://pypi.python.org/pypi/python-pgsql/) or if someone can
> > recommend an alternative, that would be fantastic.
> 
> I'd recommend psycopg2. 
> 
> This is an introduction:
> 
>  http://www.devx.com/opensource/Article/29071
> 
> But google yields tons more. And make sure you read the python db api 2.0
> spec, this should give you the general idea on how to work with Python &
> RDBMS, which is nicely abstracted away from the actual database.

Python-pgsql is a much better choice when it comes to big applications,
specially if you are going to deal with xml-rpc.  I have found that
python-pgsql handles integers and other such postgresql datatypes
better.

Happy hacking.
Krishnakant.


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


Re: Python & OpenOffice Spreadsheets

2009-11-23 Thread Krishnakant
On Mon, 2009-11-23 at 11:12 +, Paul Rudin wrote:
> Gerhard Häring  writes:
> 
> > Is there a *simple* way to read OpenOffice spreadsheets?
> >
> > Bonus: write them, too?
> >
> > I mean something like:
> >
> > doc.cells[0][0] = "foo"
> > doc.save("xyz.ods")
> >
> >>From a quick look, pyodf offers little more than just using a XML parser
> > directly.
> 
> 
> Depends on exactly what you mean by "simple" - but pyuno allows you to
> read and write openoffice spreadsheets.


Odfpy is a good module and is easy too.
http://kk.hipatia.net/public/gnukhata/gnukhata-client/ has a deb package
I built for ubuntu 9.04.
I can even provide you the distutils tarball off the list (because I
can't recall the url from I downloaded it, may be sourceforge ).
Happy hacking.
Krishnakant

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


Re: copy a file

2009-07-14 Thread Krishnakant
On Tue, 2009-07-14 at 12:27 +0530, amr...@iisermohali.ac.in wrote:
> Dear all,
> 
> Can anyone tell me that suppose i want to copy few lines from one text
> file to another then how can i do that.Looking forward for soon reply.
> 

very simple.  open one file and open the source file.
seek till to the point where u want to start copying and loop till the
end with readline function.
then write it to the destination file.

To find the starting point, keep looping through the content and come
out of that loop when you find a match to the word you are looking for.
happy hacking.
Krishnakant.

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


Re: select lines in python

2009-07-15 Thread Krishnakant
On Tue, 2009-07-14 at 23:03 +0530, amr...@iisermohali.ac.in wrote:
> Dear all,
> 
> Can anyone tell me that suppose i have a file having content like:
> 
> _Atom_name
>   _Atom_type
>   _Chem_shift_value
>   _Chem_shift_value_error
>   _Chem_shift_ambiguity_code
>  1 1   PHE   H H  8.49 0.02 1
>  2 1   PHE   HAH  4.60 0.02 1
>  3 1   PHE   CAC 57.83  0.3 1
>  4 2   LEU   H H  8.23 0.02 1
>  5 2   LEU   HAH  4.25 0.02 1
>  6 2   LEU   HB2   H  1.54 0.02 1
>  7 3   ASP   H H  8.10 0.02 1
>  8 3   ASP   HAH  4.52 0.02 1
>  9 3   ASP   HB2   H  2.65 0.02 1
> stop
> 
> 
> now what i want that instead of copying all the lines it will just write
> the information about PHE and ASP then how i acn do that using python
> programming.Kindly tell me the command for that.

Dear Amrita,
No one will tell you commands for your program.
We can give you logic and the way to implement it.
It is recommended that you write the code your self.
For our problem you keep a list and do a readlines() function and get
the content in your list variable.
then start looping through that list like for line in lines: where the
lines variable is your list.
Now keep comparing each line against your expected phrase and the moment
you find one, do the actions you need such as writing to a file.

happy hacking.
Krishnakant.
 

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


challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-22 Thread Krishnakant
hello all,
This is a real challenge and I don't know if a solution even exists for
this or not.

I am writing an application which I run as my usual user on ubuntu.
the usernake is let's say kk and it has sudo permission (meaning the
user is in the sudoers list ).


now when i do python myscript.py, the script has to change to another
non-privileged user for some tasks.
let's say for example switch to the postgres user which is dedicated for
postgres and has no other privileges.

I have tryed doing os.setuid(112) where 112 could be the uid of the user
I want the script to swith over.


but I got opperation not permitted.

I tryed using subprocess but that did not help me either.  I tryed sudo
su into the Popen command but it throws me into the terminal (shell)
with postgres as the user.

But that's now my desired result.
what I exactly want is that the script now continues to execute under
postgres user till the end.

I don't know how to achieve this iffect.

Infact I will need this during a serious deployment because i would have
my application run as a demon as a dedicated user.

I am finding some code for deamonising a python application but don't
know how to tell the script to change user.

happy hacking.
Krishnakant.


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


Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread Krishnakant
On Thu, 2009-07-23 at 00:17 +0200, Piet van Oostrum wrote:
> Being a sudoer is not a privilege to issue the os.setuid system call. It
> is only a permission to use the sudo command.
> 
Yes, So I would like to know if python can change the user to some other
non-privileged user during the script execution?

> >K> I tryed using subprocess but that did not help me either.  I tryed sudo
> >K> su into the Popen command but it throws me into the terminal (shell)
> >K> with postgres as the user.
> 
> You could execute the command:
> sudo -u postgres required_command
> with subprocess.
> 
Ok, but the problem is much more complex.
What if I want to do the following.
1, change the user for a particular script to the postgres user.
2. now execute the python code for connecting to the postgresql
database.
In the second point I actually want to execute python code not shell
level command so will the sudo -u in the subprocess.Popen change the
user in the script?
In short I would just like to have the script run under another user
let's say postgres as long as a certain action is going on, for example
connecting to the postgresql database.

 
> You have another problem then: your password must be supplied unless the
> NOPASSWD flag is set in the sudoers file.
> 
That is clear, the only problem is that I want the script to run as
postgres user although it was started by the user kk.


happy hacking.
Krishnakant.


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


Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread Krishnakant
On Thu, 2009-07-23 at 13:50 +0200, paul wrote:

> If the user running python program is allowed to call setuid() then yes.
> 
NO, i don't think i can do that.  I am getting opperation not permitted.

Any ways I think probably subprocess will have to sort it out.

> Did you try running "sudo -u postgres blabla" with subprocess?
> 
Yes, but still not got the intended result which is now obvious.
> > 2. now execute the python code for connecting to the postgresql
> > database.
> > In the second point I actually want to execute python code not shell
> > level command so will the sudo -u in the subprocess.Popen change the
> > user in the script?
> No, as the name "subprocess" suggests you are spawning a new process 
> which gets another uid through sudo. This does not affect the parent 
> process.
> 
Ok then here is the work-around which I am thinking to try, Plese tell
me if it is correct.
I will let that subprocess start python inthe background and execute the
connecting code to postgresql including importing the pygresql library.
Then I will create the connection and cursor objcts in that subprocess.
But my concern is, will the connection object in the child process
(subprocess) be available to the parrent process?


happy hacking.
Krishnakant.


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


Re: Building / making an application

2009-08-02 Thread Krishnakant
On Sun, 2009-08-02 at 20:21 +0100, Peter Chant wrote:
> What is a good way to do this?  There are instructions on making modules at:
> 
> http://docs.python.org/distutils/setupscript.html
> 
> however, what do you do if you don't want a module?  I'm thinking of where
> I'd like to split the code into several files and have a build / setup
> script put it together and install it somewhere such as /usr/local/bin. 
> I'm interested in what the standard way of doing this is.
> 
Have you considered creating a deb or rpm package for your application?
Most of the documentation for deb or rpm will talk about make files.
But even a distutil based python package (with a setup.py) can be made
into a deb package.
Then the your requirement will be satisfied at least for most gnu/linux
based distros.

happy hacking.
Krishnakant.



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


a newbi problem: can't find complete python curses library

2006-11-02 Thread krishnakant Mane
hello,
I am a new member to this list.
I am Krishnakant from India, Mumbai.
I have been coding in python for quite some time and now I am at the
intermediate level of programming as far as python is concerned.
I am going to develop a accounting software that can work on the
console and accessed through ssh from other terminals.
I will like to use the curses or ncurses library for the menus and the
input forms with add, save, delete, update and cancel buttens.
I also need to create drop down menus with a top level menu bar.
I read a few articles about python wrapping curses but can't find some
thing very comprehencive.
my question is,
does python possess a complete wrapper to ncurses and its related
libraries like menu, panel and form?
if yes then where can I find documentation?
I read the python documentation and could manage to find out the
window object but nothing on menus and panels and forms.
thanks and regards.
Please help,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Secure Python

2006-11-16 Thread krishnakant Mane
after reading all the mails on this thread, I have the following observations.
I am relatively new to python at its development side but very old as
far as using python is concerned.
firstly, talking about gnu/linux there is no question about security.
python, if at all it is non-secure wont harm a linux machine much any ways.
secondly with OS like windows, things will be non-secure, no matter what you do.
and it will be un stable and un secure no matter what language you use.
how far then is python secured or non-secured in its absolute sence?
I need to use python for a very mission critical project.  may be I
will also use zope.
so I will like to know how far I can trust python for security in its
absolute (platform independent ) sence?
I mean running unwanted code at run-time etc.
thanks.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


how to print pdf with python on a inkjet printer.

2006-11-16 Thread krishnakant Mane
hello all.
I am developing an ncurses based python application that will require
to create pdf reports for printing.
I am not using py--qt or wx python.
it is a consol based ui application and I need to make a pdf report
and also send it to a lazer or ink jet printer.
is it possible to do so with python?
or is it that I will have to use the wxpython library asuming that
there is a print dialog which can open up the list of printers?
if wx python and gui is the only way then it is ok but I will like to
keep this application on the ncurses side.

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


python and accessibility issues.

2006-11-16 Thread krishnakant Mane
this question is streight forward, short and sweet.
I am developing some applications and being blind myself, expect that
including me, all other blind people must be able to use it.
so my question is,
is wx python complying with Microsoft Active Accessibility or MSAA for short?
I will use wx python or any other gui library that is having support
for MSAA built in.
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to print pdf with python on a inkjet printer.

2006-11-17 Thread krishnakant Mane
On 17/11/06, Tim Roberts <[EMAIL PROTECTED]> wrote:
> Making the PDF is easy.  Go get ReportLab from www.reportlab.org.  I
> consider it the best Python PDF solution.
wow! you solved my major problem before I even asked it.  seams that
python programmers also have dynamic mind reading capability *smile*.
> Printing is more complicated, because you actually need something that can
> RENDER the PDF.  The most common such renderer is the Acrobat Reader, and
> you can actually call the Acrobat Reader from a command line with a
> parameter that tells it to print the file automatically.  The only
> disadvantage is that using that method will only print to the "default"
> printer.
double wow!  as it is my customer wants me to print to the default printer.
can you please help me with the command for rendering the pdf to the
printer with acrobat using python?
that essentially solves my most important problem.
else I was thinking to create an excel spreadsheet as a last alternative.
out of my curocity, I want to know if there are libraries that can
create excel spreadsheets?

I also wanted to know if there is a common dialog for listing out
printers under windows?
so in future if I make this software in GUI, I can at list help the
user select the printer from the list.
thanks,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to print pdf with python on a inkjet printer.

2006-11-17 Thread krishnakant Mane
On 17/11/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:

>  http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html
>
> or possibly:
>
>  http://www.planetpdf.com/forumarchive/49365.asp
I can't figure out where is the win32api module in my system.
I think I need to download it.
I tried to search but did not find it.
what is the url for this module and does it also have documentation.
thanking you.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


please help me choose a proper gui library.

2006-11-18 Thread krishnakant Mane
hello all.
after finishing a project in record time using python we have taken up
one more project.
this time however, we need to do a gui based project  which will run
on windows xp and 2000.
now My question is which gui toolkit should I choose?
I had initially raised some doubt about accessibility (which is very
important for me ), and with the answers and all the pointers given, I
know that wxpython is quite out of question.
now my next choice is PyQT.
can some one give me information on the following points?
1.  do I first need to install the pure c++ based QT library both on
the developer machine and the client's user machine?
2.  I need an executable binary installer for windows xp.  is it
available for python24?  I searched but found one for python25.  else
kindly guide me what should I do to install the source.  I read the
documentation but did not get the clear idea whether I must have qt
installed first or not.  if yes are there binary installers of PYQT
which can also install qt?
3. if I need to upgrate to python25, should it be considered safe?
4.  I don't want to use the qt IDE and this point is nothing to do
with qt, I need a good windows based python editor.
5.  if I am supposed to also distrubute qt with PYQT, how do I plan
the deployment of my ready software?
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me choose a proper gui library.

2006-11-18 Thread krishnakant Mane
On 18/11/06, Phil Thompson <[EMAIL PROTECTED]> wrote:

> You have to install Qt first. You only need to install the run-time elements
> (ie. the DLLs) on the client's machine. Unless your application is licensed
> under the GPL (and you are using the GPL version of Qt and PyQt) then there
> are components of Qt that you must not install on the client's machine.
Yes, the software is licensed under gpl.  how do I determine what
run-time elements I need to install on the clien'ts machine and what
is supposed to  be skipped?

> The only binary installer provided is for the GPL version of PyQt. Qt has
> separate installers. It's easy enough to use something like NSIS to create
> your own installer for your application that includes everything that it
> needs.
that's exactly what I am planning, only need to figure out what all do
I need to package apart from the application executable.  by the way I
will be using cx_freze for creating executables.  so I hope I will not
require to also ship the PYQT modules?
> PyQt fully supports Python 2.5.
but my problem is that I will only be able to use python 2.4, is that
ok?  the PYQT installer asks "you seam to have a version older than
python25, would you still like to continue?"  is it safe to do so?  I
did not find a gpl binary for PYQT that is made for python24.  please
give the URL if possible.
> Google for the different ones and try them out.
which is the best editor which I can consider simple, does auto
indentation and has some kind of auto completion features?  it is ok
if I don't get a gui designer.
> In addition to your application you need to distribute the Qt DLLs (and
> plugins if you use them), the corresponding PyQt .pyd files and sip.pyd. If
> you are using the GPL version of Qt then you may also need to consider the
> MinGW DLLs. Finally you need to consider if you need to distribute Python
> itself.
>
> You might like to look at tools like PyInstaller for creating single
> executables.
this is all confusing for me right now.  can you please give me any
links possible for having a binary qt installer that will also install
dlls required by PYQT?
and how will I be able to determine what dll files and what other
components I will need to ship with my installer?
thanks.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help me choose a proper gui library.

2006-11-18 Thread krishnakant Mane
On 18 Nov 2006 12:40:57 -0800, sturlamolden <[EMAIL PROTECTED]> wrote:
> It's a matter of taste. I would recommend PyGTK (yes it runs on
> Windows). You can design the GUI in a fly with GLADE, and import it as
> an XML resource in Python with one single line of code.
I also have to consider the issue of accessibility.
I am blind myself and need to know what I am coding.  and as a policy
matter our company always makes use of accessible libraries just in
case any client is also handicap.  some laws have also made it
mandatory.


>It will save
> you an awful lot of work; all you have to code is the event handlers.
that will be great provided it is accessible on windows.
> Additionally you get the GUI design out of you code, which makes
> maintenance a lot easier. You can redesign the GUI without changing or
> breaking your existing Python code.
that is great but I don't want to use glade.
I will like a simple ide where I can do hand coding.
I am going to try python with eclipse.


thanks,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


question on pygtk and accessibility on windows.

2006-11-30 Thread krishnakant Mane
has any one tried py gtk on windows?
I tried to do a google search for accessibility related issues but did
not find any thing specific to pygtk and windows accessibility.
I even tried to search for just gtk and windows accessibility but
again no result.
so I am now posting this message as a last hope to at least get a "yes
" or "no " answer on whether py gtk is accessible with windows.
thanks.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs java & eclipse

2006-12-01 Thread krishnakant Mane
just used the py dev plugin for eclipse.
it is great.
auto indentation and intellisence.
and all other things.
so now how does it look from this end?
python + productivity and eclipse + productivity = double productivity!
only problem with the plugin is that I find it difficult to manage the
script running.
I open a command prompt and run the scripts manually.
any suggestion for this.
for example I had name = raw_input("please enter your name") and the
moment I type the first letter on the keyboard the code execution
moves over to the next statement.  should it not wait for the return
key as it always does?
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: good documentation about win32api ??

2006-12-01 Thread krishnakant Mane
On 1 Dec 2006 09:56:09 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> http://msdn.microsoft.com covers the API itself, although you need to
> transliterate from the C code to python.
Exactly! that's where the problem lyes.
I am pritty well to do with windows API, I am an a good python
programmer, but I can't find the link between the two.
there are modules but no good documentation.
krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs java & eclips

2006-12-01 Thread krishnakant Mane
may be emacs can provide code completion (intellicense)
I have not used it so far so can't say.
but the main reason I use eclipse is for the above feature.
and yes indentation happens in eclipse python-mode so that is not a
major feature eclipse offers any way.
syntax highlighting is a very common feature again.
so if there is an editor which will give me auto code completion, I
will happily give up using eclipse.
by the way, there is one problem I am finding with eclipse and py dev.
the following snippad of code is a mesterious problem.
name = raw_input("please identify your self ")
if name == "tom":
   print "hello and welcome"
else:
   print "I don't know you"

just run this script and you will find that you always get "I don't
know you", even if you entered tom.
I then figured out that length of name actually comes to 4 even when I
entered tom.  that's why it always goes in the else claws.
but when I ran the same script from a command promt the length of name
returned 3 when tom was entered and the code worked fine.
I can't understand why is this happening?  why is eclipse putting an
extra character in the name variable?


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


can't figure out how to create menus in urwid

2006-12-01 Thread krishnakant Mane
hello,
I have been trying out urwid for creating ncurses based applications.
I will like to know if any one has ever tried to create menu bar with
drop down menus using urwid?
any suggestion?
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


evaluating gui modules, any experience on tkinter?

2006-12-02 Thread krishnakant Mane
hello all,
I seam to have noticed this a bit late but it appears to me that
tkinter is being used very widely for gui development on all platform?
is that right?
since fredric lundh has written a very good introduction to tkinter
(was that just an intro?), I have got keen interest to know the
following.  may be fredric himself might put some light on these
points.
1. I seriously don't intend to start a flame war but does tkinter
stand up to the standards of heavy gui development?  can I have an
entire mdi application working fine with tkinter?  I know wxpython can
do it and I have heard enough about pyqt, but tkinter seams to be very
rich in gui objects.
2.  as usual I always look out for accessibility when it comes to gui
design.  will tkinter be useful for blind people?  I mean, are gui
apps in tkinter accessible on windows?
3.  I don't know if I need any thing else as dependencies on my
windows machine.  I am using python24 and I did not find any thing
about installation in the introduction to tkinter.  can some one give
me the process of installing tkinter and all necessary things?
4. is tkinter absolutely compatible with windows gui?  does it call on
native api for native look and feel?  in that case I think
accessibility issue is automatically solved.
I am looking out gui library for some serious application development.
 one is an erp system and the other is a customer relation management
system.
so I am confused between wxpython pyqt and now tkinter.
out of the 3 I only found qt talking extencively about accessibility,
but did not find a way to install qt in the first place.  I could not
compile qt nor did I find any run-time dlls for mingw so that I can
use it out of the box.
wxpython is the poorest in documentation and tkinter seams to be best at that.
please give me some advice.
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


wxpython worked out but can't find api docs for download.

2006-12-02 Thread krishnakant Mane
hello all.
finally I got the accessibility issue out from wxpython.  actually
almost got it out, but that's another story.
now my problem is that I can't gind a downloadable version of wxpython
api reference for the latest version or the latest api reference at
least.
I found the on-line version so please don't provide the same link.
when I opened it on line, it took about 8 minuts to get the wx package
come up on screen with over 600 links.
I need to have some off line reference for the wxpython api.
I have enough documentation to get started but I don't have the
extencive api references for events and other methods, properties and
attributes.
can some one point me to a .zip or .tar.gz version of the api docs for wxpython?
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython worked out but can't find api docs for download.

2006-12-02 Thread krishnakant Mane
On 03/12/06, hg <[EMAIL PROTECTED]> wrote:
> http://www.wxpython.org/download.php

I had the wxwidgets documentation on my computer as well.
and I also have the demos.
but I was wondering if there is some api reference on wxpython itself.
the problem is that wx widgets is such a huge library that every time
I want to look up some reference material, I need to first look into
the c++ version of the library and then make a mentel translation of
the same into python.
I know it is not a good thing to do always.  and then it does not do
justice to the writers of wxpython.  after having such a beautiful
library as a wrapp around the c++ equivalent, it is rather unjustified
to look at the c++ version of documentation isn't it?
so if there is a api reference similar to the one available on-line,
please provide the url for the same.
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: evaluating gui modules, any experience on tkinter?

2006-12-02 Thread krishnakant Mane
On 03/12/06, Gian Mario Tagliaretti <[EMAIL PROTECTED]> wrote:
> hg wrote:
>
> Tkinter is fine under *nix and Windows for a large range of applications.
 > I think it has drawbacks and advantage compared to other toolkits. The
 > major advantage being bundled with python, and the drawbacks include (I
 > think) ... look and feel, printing support, imaging, documentation.
>
well, I am looking seriously at wxpython.

I found pyqt very good but can't figure out where to get dynamic
run-times for qt.
I don't want to compile it myself.
if that is available then I could as well go for it.
but talking about wxpython, I found it very easy.  and after reading a
few articles at devshed.com I am up and running with wxpython.
but problem is that as I emailed on another thread, I am falling short
of api documentation and reference for wxpython.
there is the reference and all the docs for wx widgets.  but what is
the point in first studying the c++ version and then translating the
same back to python when a library is already been translated and
there to be used?
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython worked out but can't find api docs for download.

2006-12-03 Thread krishnakant Mane
hi pol,
thanks for your helpful suggestion.
I tried it but nothing seams to work.
I can't get the folder containing html files as you suggested.
can you kindly attach a .zip archive of your generated folder as a
privat email to me?
I will be really thankful.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


problem formatting dates from text fields.

2006-12-03 Thread krishnakant Mane
hello all.
thanks for the help and for pointing me to the proper url for wxpython
related issues.
I am so happy that I now have a very easy gui library that can do
practically every thing with such ease (no flames intended but I was
never at so much ease with java swing ).
I however have a problem with dates.
I am tired searching for some good tutorial that can explain the basic
functionality of wx.datetime class and the datetime picker.
I want to display the date in dd/mm/ format and allow the user to
change the dates.
I then will like to take the value (the entire date) and put into a database.
now this is my first question.
the other problem is even more tough to solve with my given knowledge
of wx.datetime and related classes.
unfortunately the database given to me has a text field for date and
the data is neetly entered.
but when I get the data back from that text field I some how want to
convert it back to actual date in the same dd/mm/ format and send
this as a value to my date time picker.
how can I achieve this?
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


please provide urls for some python success stories.

2006-12-03 Thread krishnakant Mane
hello all.
actually I have been recently appointed as a technology consulltent at
a huge company.
and I have couple more such projects in the pypeline.
unfortunately the officials out here are too much in favour of java
and I have personally worked with both and find that python is heaven
in syntax and makes it very easy to do complex things.  on speed?  I
think experts on this list can give better answer, but efficiency and
maintainance wise there is nothing like python I believe.
the problem here is that I am from India and all indians on this list
can correct me if I am wrong, very few people know about python here.
infact a vast majority of programmers ask me "python? what is that!"
they don't even know that it is a programming language, let alone using it.
but I am amongst the very few who have actually used both java and python.
I need some strong evidence to prove to these stupid and java oriented
officials that there is some thing better than java called python.
can some one provide me some urls or may be share some personal
experience on this issue?
I saw a couple of blogs and a few success stories on the python web site itself.
but the common answer I am getting is "y! even java can do this and
java is much faster!"
I am really adicted to python due to its superiority and efficiency
and the  amount of libraries.
but I need some strong official efidence.
Please help me, I don't want to leave python.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem formatting dates from text fields.

2006-12-03 Thread krishnakant Mane
On 04/12/06, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>   You don't show us what format is used in the database, so there is
> nothing to base a conversion on. Is it year/month/day, month/day/year;
> months numeric or alpha (abbreviated or spelled out). Fields separated
> by space, comma, -, :, or /
>

the format in the text field is dd/mm/ which is perfect for what I need.
but the problem as I said is to get this text into a value that can
fit into a date time picker.
can this be done?
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem formatting dates from text fields.

2006-12-03 Thread krishnakant Mane
is there a soft copy of wxpython in action available for free download?
I saw the book on my book store but since I am totally blind, I have
to depend on soft copies.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


is there a tutorial for creating packages in python?

2006-12-08 Thread krishnakant Mane
hello all,
I have got a lot of sets of functions and classes that do related
work.  so just like we get python libraries I too need to create such
libraries often called packages.
I want to put my code to re-use so will create these libraries and put
in the site-libs folder.
can any one suggest me a good tutorial on line which can teach me to
develop python packages and modules and most importantly to put them
in libraries?
I saw the official python tutorial and I think chapter 6 has quite a
bit on that.
but not what I could term as some thing complete in knowledge that one
needs to create libraries as huge as wxpython etc.

thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need guidance on sending emails with attachment with python.

2006-12-11 Thread krishnakant Mane
hi jonathan,
it is understandable from your point of view I wont say you were rood.
but my question was different.
I am very new to doing programmed emails.
all I need to know is that will I need to use outlook or any thing to
send emails to pop3 or smtp?
I want to know because I wont like to make use of outlook or any thing
to do my work.
I know the python libraries are there but I want to know what these
libraries will make use of on my windows machine.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need guidance on sending emails with attachment with python.

2006-12-11 Thread krishnakant Mane
On 11 Dec 2006 04:54:04 -0800, Bernard <[EMAIL PROTECTED]> wrote:
> here's the function I've been using for while :P
>
thanks indeed for the function Bernard.
I will have a windows machine up tomorrow.  but do I need to install
any thing over and above the python libraries needed?
is it necessary that I install outlook or do I need to install any
server/ client on the machine where your function is to be used?
> import smtplib
> from email.MIMEMultipart import MIMEMultipart
> from email.MIMEBase import MIMEBase
> from email.MIMEText import MIMEText
> from email.Utils import COMMASPACE, formatdate
> from email import Encoders
>
> def sendMail(arrRecipients, sender, subject, message, files=[]):
> """ Sends email with attachements """
> # SMTP address
> smtpserver = '' # provide a smtp here in string format
> # authentification section
> AUTHREQUIRED = 0 # if you need to use SMTP AUTH set to 1
> smtpuser = ''  # for SMTP AUTH, set SMTP username here
> smtppass = ''  # for SMTP AUTH, set SMTP password here
>
> # Building the body of the email
> mssg = MIMEMultipart()
> mssg['From'] = sender
> mssg['To'] = COMMASPACE.join(arrRecipients)
> mssg['Date'] = formatdate(localtime=True)
> mssg['Subject'] = subject
> mssg.attach( MIMEText(message) )
>
> # attachments
> for file in files:
> part = MIMEBase('application', "octet-stream")
> part.set_payload( open(file,"rb").read() )
> Encoders.encode_base64(part)
> part.add_header('Content-Disposition', 'attachment;
> filename="%s"' % os.path.basename(file))
> mssg.attach(part)
>
> session = smtplib.SMTP(smtpserver)
> if AUTHREQUIRED:
> session.login(smtpuser, smtppass)
> smtpresult = session.sendmail(sender, arrRecipients,
> mssg.as_string())
>
> if smtpresult:
> errstr = ""
> for recip in smtpresult.keys():
> errstr = """Could not delivery mail to: %s
>
> Server said: %s
> %s
>
> %s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
> raise smtplib.SMTPException, errstr
>
> krishnakant Mane a écrit :
>
> > hello,
> > I am a bit confused.
> > I want to make a program that will take some data from a database and
> > make a string of text.  and send it to the respective email id of a
> > person.
> > next I also want to send an attachment of a photo along with the email.
> > I will be required to make this program run on windows xp.
> > can some one guide me as to how I can achieve this?
> > what I will need on windows to send emails?
> > I believe yahoo, gmail, rediff and msn supports pop3 and smtp?
> > correct me if I am wrong on this.
> > secondly what library is used on windows to do this?
> > I know there must be python libraries to do this,
> > but apart from that I don't know what all I will need on my windows
> > machine to send emails to mostly yahoo, gmail and msn.
> > Please give me some idea about it.
> > Krishnakant.
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


issues with making a package. where do classes link?

2006-12-11 Thread krishnakant Mane
hello all,
I am struggling a bit in making python packages.
when I am doing a project I want to create all my python modules
inside a single package.
I want to know when I make a package, what are the basic things I must
generally do in the __init__.py file?
and how do I link all the modules in my project with each other?
like when I make a compilation unit in java under a package, the first
like of that file will read "package mypackage".
I did not find any such thing in python that can say that this xyz
file is in the abc package.
if I want to use one module into another in my same package I can't
figure how python figures it out?
I want every thing in a single package.
so that's my confusion.
thanks.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


can't find a suitable application server

2006-12-30 Thread krishnakant Mane
hello,
I have read about zope and found it very good.
but right now I am a bit confused about one project I have just procured.
it is supposed to be a simple 3 tear application.  the front end will
be a thin client which we will develop using wxpython.
We are using MySQL for the database and I need to find out a suitable
application server where I can do just the following.
1. write my business logic which will actually be the workhorse.
2.  send data to the thin client in form of either text or lists or
tuples as required.  I want my thin client just to take the data and
recieve the data.
3.  an application server that will process data coming from the thing
client.  this layer will fire the queries etc.
4.  send the processed results in the forms mentioned in point number
2 (sorry if I am redundent).
I thought zope is too heavy and complex for this task and zope is
generally used in places where the data is too dynamic and the system
very complex.
I am any ways using MySQL for the rdbms which is more than sufficient
so no need for a object oriented database like what zope has.
can any one suggest me what to do?
right now I get an impression that I must create sockets and send and
receave data through that socket to the thin client and put the actual
business logic on a seperate machine or on the database server what
ever.
thanking all.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


inspite of proper package structure, no module named xyz error.

2007-07-12 Thread krishnakant Mane
hello all,
can some one suggest me the best solution for a package?
I have a package folder called idm and there are the following files in there.
__init__.py which is right now empty.
mainwindow.py which has a single class called MainWindow which is an
MDI Parent frame from wxpython.
student.py which is a child frame which gets called from the main menu.
exam.py, another child frame.
now when I try to run mainwindow.py file with the "import
idm"statement, I get the following error.
no module named idm.
what could be the problem?
I have imported all the necessary modules in mainwindow.
kindly help.
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


how good does PyGTK work on windows?

2007-07-16 Thread krishnakant Mane
hello,
I will be writing some code in PyGTK to run on linux.  but I want to
know if there are any installers or distutils available for PyGTK on
windows?
I have heard that installing gimp or even pygtk is next to impossible
and is very tedious if at all one gets success.
can any one share their experiences with installing and running pygtk on windos?
any links for downloading proper packages will be highly appreciated.
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


is there a module to work with pickled objects storage in database?

2007-05-04 Thread krishnakant Mane
hello all,
I am trying a very complex kind of a task in a project.
I have a knowledge management system where I need to store a lot of
objects (pickled).  I have to store mostly lists and dictionaries into
a rdbms.
mostly I will be using mysql.  I want to know if there is any module
that can help me store a pickled object inside a blob field instead of
a file.  I know that pickle.dump() can store an object into a file but
I can't find a way to transfer pickled objects into a database.
I so far tried to read a dumpped file for pickled object and directly
right the contents of the file to the blob field in my database.
but that does not seam to give the right result.
I first dump the object into the file through pickle.dump and then
open the file in read mode.
then I read the contents of the file and then store what ever comes
out into the blob field.
I know this is not right and there should be ways of storing a pickled
object other than file.
Please guide me on this issue.
regards.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


problem with quoted strings while inserting into varchar field of database.

2007-05-06 Thread krishnakant Mane
hello,
I finally got some code to push a pickled list into a database table.
but now the problem is technically complex although possible to solve.
the problem is that I can nicely pickle and store lists in a blob
field with the help of dumps() for picklling into a string and then
passing the string to the blob.
I am also able to get back the string safely and do a loads() to
unpickle the object.
but this only works when list contains numbers.
if there is a list such als
lst = ["a","b","c"] then after a dumpls I get a pickled object into a
string but when I try to insert this into the blob field it refuses to
get into the table.
there is an sql syntax error.
I further discovered that the string variable that contains the
pickled object contains a lot of single quots "'" and this is what is
probably preventing the sql insert from succedding.  can some one
suggest how to work around this problem?
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with quoted strings while inserting into varchar field of database.

2007-05-06 Thread krishnakant Mane
On 6 May 2007 11:22:52 -0700, Daniele Varrazzo <[EMAIL PROTECTED]> >
> Every serious database driver has a complete and solid SQL escaping
> mechanism. This mechanism tipically involves putting placeholders in
> your SQL strings and passing python data in a separate tuple or
> dictionary. Kinda
>
> cur.execute("INSERT INTO datatable (data) VALUES (%s);",
> (pickled_data,))
>
I will try doing that once I get back to the lab.
mean while I forgot to mention in my previous email that I use MySQLdb
for python-mysql connection.
I did not find any such reference to storing pickled objects in the API.

any Idea what could be done with the mysql python module I am using?
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Latest errors on pickled objects and blob datatypes in mysql

2007-05-07 Thread krishnakant Mane
hello,
finally the errors for my sql query have changed so I have even
changed the thread subject because I feel now that this is not doable
in mysql and this seams to be a bug, ither in python or the MySQLdb
module or perhaps both.
my table is called testobj and the blob field is called obj.
now following is my query with the cursor named CSRInsert.
CSRInsert.execute("insert into testobj (obj) values (?);",(pickled_object))
the error is,
"type error, not all arguments formatted during string formatting ".

can some one now figure out what could be the problem?
-- 
http://mail.python.org/mailman/listinfo/python-list


which is the comprehencive module for postgresql?

2007-05-18 Thread krishnakant Mane
hello all,
some times having many choices often confuses the users.
can some one plese tell me which is the most comprehencive, well
documented and widely used and tested module to connect from python to
postgresql database?  I looked around PYPgsql but there seams to be
very little documentation.
and seams that PyGreSql is non-free?
please suggest a suitable driver.  by the way I will also be using
bynary large objects.
so that support must be included.
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


problems playing with dates from any month.

2007-08-02 Thread krishnakant Mane
hello,
I have a very strange problem and I can't find any solution for that.
I am working on an accounting package which I wish to develop in python.
the simple problem is that I want to knoe how I can know if the given
date is the nth day of a month.
for example if a customer is supposed to pay his installment on every
5th of all months,
I want to know if today is the fifth day (jan the fifth, feb the fifth
etc) for any given month.
I have not found any such function.
if I have looked (or over looked ) in the wrong places I am really sorry.
secondly I also want to know the way in which I can convert a given
string to a date object.
for example if I have a string "29/09/2005", I know it is a valid date
although it is in a string form.
now I want to convert the above string into a real date object.
how can I cast it this way?
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >