Need to call functions/class_methods etc using string ref :How
Hi, First of all, since this is my first mail to Python-List, I want to say "Hello world!" After that; I am stuck in a project. Actually I am writing a module (for testing now), which takes URL, parses it, finds which modules and then which method to call or which class to initiate and which string to load. So far, I have done some basic URL manipulation and validation and extracted the name of modules in a dict { 'ModuleName-1': None, 'ModuleName-2': None --ETC-- } Now I want your help about how to call the function i.e _render() in the module. I have to iterate it calling all modules/also Class.methods and assinging the values in dict for each key as modulename. Means, just take that moduleName is a string which contains the name of module to load. FuncName is the string which contains the name of def to call clName is the string which contains the name of the Class, which is to init and get returned object. means everything in string. ALso, if there are multiple methods to do it, if you provide a little pros/cons and comments, it would really be very nice of you. Before I came here, I have searched Google, and found a way hasattr()/getattr(), but that confused me a little and didnt worked for me. I am missing something I know, so please ENLIGHTEN Me :) Thanks in advance EVen you read this mail :P -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
any Templating system help
Hi, I am stuck a little. I am working on a demo site to propose for the my company. Using mod_python and several python technologies. But the website is simply using publisher handler, i dont want to use any framework such as DJango etc. so the main idea is, i made many python files which has several defs inside, such as index, getList, submitForm etc now everything is working nice, means calling them in url. I need a templating system now. But not slow and complex. The only things in templating system i need is: fetching all the names of variables/placeholder in template. (i can then call the suitable defs from files and apply the wrapper on it and return to main caller) setting the values Please suggest some ideas. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: any Templating system help
I havent looked much into string.template . I think i will have to now. I went trying MAKO, Cheetah, Genshi and some others too. But in less time, I got confused. I didn;t need a total language. Rather I just want to write my xHTML/CSS/JS in a page with embedded placeholders like ${variableName} or ${ModuleName.functiontoBeCaller(args, ...)} etc. And that should return the lists of all placements, so i can call them conditionally. If they have such feature to call the req function by themself, it would be good. So please suggest me some better thing. On Nov 29, 2007 7:56 PM, Yoram Hekma <[EMAIL PROTECTED]> wrote: > On Thu, Nov 29, 2007 at 06:48:10PM +0530, Ravi Kumar wrote: > > Hi, > > I am stuck a little. I am working on a demo site to propose for the my > > company. Using mod_python and several python technologies. But the > website > > is simply using publisher handler, i dont want to use any framework such > as > > DJango etc. > > > > so the main idea is, i made many python files which has several defs > inside, > > such as index, getList, submitForm etc > > now everything is working nice, means calling them in url. I need a > > templating system now. But not slow and complex. The only things in > > templating system i need is: > > > > fetching all the names of variables/placeholder in template. (i can then > > call the suitable defs from files and apply the wrapper on it and return > to > > main caller) > > setting the values > > > > Please suggest some ideas. > > > > > > > > -- > > -=Ravi=- > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > Well, I personally like Genshi (http://genshi.edgewall.org/), but > offcourse there are others (myghty, cheetah) and I know you can use the > Django templating system apart from the framework (never did this > though. > > But personally, when I only need a templating system and nothing more > (for some html-reports for instance) I tend to use genshi. > > Yoram > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.6 (GNU/Linux) > > iD8DBQFHTswm6Y3ORTnySxURAvh3AKCtfxKGpHibuvxbw0p+DUZqZJ1LqQCfUDIz > /c3cHk8FHqaja2vHCuRoPRY= > =9cSn > -END PGP SIGNATURE- > > -- > http://mail.python.org/mailman/listinfo/python-list > -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: Need to call functions/class_methods etc using string ref :How
WOW, Thanks a lot. I got many options to do, and play with. Each one having its own pros and cons. But for my requirement in project, i will go with hasattr/getattr/callable and then calling the ref method. It seems fit for the problem. Thanks a lot :) again. On Dec 1, 2007 12:45 AM, Bruno Desthuilliers < [EMAIL PROTECTED]> wrote: > George Sakkis a écrit : > > On Nov 26, 2:04 pm, Bruno Desthuilliers > > > > <[EMAIL PROTECTED]> wrote: > > > >>Donn Ingle a écrit : > >> > >> > I see someone already showed you eval. Eval is evil. Don't use it. > Especially if the functions are coming to you from a public URL! > >> > >>>Yes, I suggested to him (by email) this: > >> > >>>thisinstance = SomeObject.__class__.__dict__ > >>> > >> > >>This will only get attributes defined in SomeObject.__class__ - not the > >>one defined in the parent classes. Nor methods dynamically bound to a > >>specific instance. > >> > >> > >> > >> > >>>for f in yourlist: > >>> if f in thisinstance: eval(f)(params) > >> > >>>Which would vet the functions too. > >> > >>You *still* don't need eval here. > >> > >>target = > >>for funcname in funclist: > >> func = getattr(target, funcname, None) > >> if callable(func): > >> func(*args, **kwargs) > >> > >>I've almost never had a real use case for eval (or exec) in 7 years. > > > > > > That's not to say there aren't any. > > Indeed. But most of the time, I found that Python provides a more > appropriate solution. > > > In one project I'm using exec to > > parse user provided function bodies from a web interface into real > > python functions (the function signatures are auto generated). > > A problem I've never had to solve so far, so you're the expert here - > but what about compiling the source with compile, then instanciating a > function object from it ? > > (snip) > -- > http://mail.python.org/mailman/listinfo/python-list > -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
[OT] Guide me on Apache Virtual server+mod_python
HI, I am sorry for OT here. But I search google, could not quench my thrist, so came here, and for single question, I don't want to subscribe in Apache Newsgroup. The problem is : i wwant to implement a mod_python based Website + Reporting Application on my system. In the domain, my system is : mysys.domain.com Now, I want to implement two subdomains on my apache server: http://www.site.com http://report.site.com Means two or multiple subdomains on same Apache Server. Only one IP Address and NIC is allocated in System (can't go for two IPs). Network has CISCO Routers . So can you please guide me a little, on how to do it. I just need some pointers and I will start finding them on Google. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Guide me on Apache Virtual server+mod_python
thanks a lot. I am still trying to get it working. I think i will have to register those subdomains in CISCO as the hostame of same ip somehow. For the same configuration, I can have those subdomains.domain.ext open in my localhost, but from other system, I can't access it. No comments or error discriptions right now from my side. I would like to work a little more to get to some point and then let you all know what exactly the problem is. Again, thanks a lot for the help. On Dec 5, 2007 7:31 PM, Ravi Kumar <[EMAIL PROTECTED]> wrote: > HI, > I am sorry for OT here. But I search google, could not quench my thrist, > so came here, and for single question, I don't want to subscribe in Apache > Newsgroup. > The problem is : > i wwant to implement a mod_python based Website + Reporting Application on > my system. > > In the domain, my system is : mysys.domain.com > Now, I want to implement two subdomains on my apache server: > http://www.site.com > http://report.site.com > Means two or multiple subdomains on same Apache Server. > Only one IP Address and NIC is allocated in System (can't go for two IPs). > Network has CISCO Routers . > So can you please guide me a little, on how to do it. I just need some > pointers and I will start finding them on Google. > > > -- > -=Ravi=- I am definitely not an expert, but no one else answered so here is how I did it. Look in the apache2 directory: 'conf'. then the subdirectory: 'extra' for the file: httpd-vhosts.conf. It contains sample code that you can use. This may not be exactly like your installation. I am using Apache2Triad. What you want is something like this: ServerName report.site.com ServerAlias report.site.com DocumentRoot /apache2triad/htdocs/www.domain.com ServerAdmin [EMAIL PROTECTED] ErrorDocument 403 http://www.site.com/403.htm ErrorDocument 404 http://www.site.com/404.htm There are some other related code changes. Just search httpd.conf and the vhosts file for virtual and hosts and you should find all the code you need commented. Also, google has many tutorials. I did this about 6 years ago so I don't remember where I got the information, but there were many references. Note that you can have as many virtual hosts as you want with one IP, but (to my knowledge) you cannot have SSL on more than one web site with one IP unfortunately. Some guru needs to do this. - Show quoted text - - Original Message - From: "Ravi Kumar" <[EMAIL PROTECTED]> To: Sent: Wednesday, December 05, 2007 6:01 AM Subject: [OT] Guide me on Apache Virtual server+mod_python HI, I am sorry for OT here. But I search google, could not quench my thrist, so came here, and for single question, I don't want to subscribe in Apache Newsgroup. The problem is : i wwant to implement a mod_python based Website + Reporting Application on my system. In the domain, my system is : mysys.domain.com Now, I want to implement two subdomains on my apache server: http://www.site.com http://report.site.com Means two or multiple subdomains on same Apache Server. Only one IP Address and NIC is allocated in System (can't go for two IPs). Network has CISCO Routers . So can you please guide me a little, on how to do it. I just need some pointers and I will start finding them on Google. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to protect my new commercial software.
> > 1. Put all the compiled Python bytecode in a heavily encrypted binary > file. Consider using a hardware hash in the key. > > 2. Program a small binary executable (.exe file) in C or C++ that: > > 2a. Reads the binary file. > > 2b. Decrypts it to conventional Python byte code. > > 2c. Embeds a Python interpreter. > > 2d. Executes the bytecode with the embedded Python interpreter. > > 3. Protect the executable with a licence manager such as Flexlm or > SoftwarePassport. > > I will not make reverse engineering impossible, but it will be > extremely difficult. > > As noted, the only completely safe solution is to provide a web > application instead of distributing your program. > > > > -- > http://mail.python.org/mailman/listinfo/python-list > Guidelines are good. but as you stated, web application instead of desktop apps. Well, the main aim and interest here was to protect it against piracy and web application are easier to be get shared and pirated than desk apps. And there is no foolproof method known to me. Even Flexlm used in Acrobat(Adobe) is cracked in easy manner. The best thing to me looks like none. You can go with anything, and always fear that if the app is needed by many others, it will be cracked. Othewise, the method stated above is good to go. Get app core into python, encrypt-assemble the compiled python code with some key. When launched, get it reversed to python bytecode and there you go,. Now, since your apps loader is built in C, you can apply available methods for C/C++/ Remember, since python is readable easily, you fear so. But no language exists which humans can't read. At worst level, they will have to go for Assembly Level decompiling, but thats possible too -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
.NET and Python Integration Problem and PDF Library (Need Help and Suggestions)
Hi. First I am explaining the Problem so it would not get messed up. :) == PROBLEM I have to integrate a small part in .NET Projects. .NET project is actually all Web-based application, user interface is Web-page for multiple actions. But a backend component of project needs PDF File manipulation. Manipuation is limited to splitting pages, removing certain pages, joining pages, finding certain text information (Title/Author/No. of Pages/Orientation of each page etc), and page orientation maipulation (rotating pages clockwise and anticlockwise, on degree parameter, left/right/flip etc). .NET guys are failing here, so I proposed to do that component in Python. But problem is, how to integrate Python in .NET Web Application. I am looking on IRONPYTHON, and thats the only point seemed to me. Also, as I am not an expert in Python, I have transition from Perl and PHP to python. So right now, my applciation architecture would little bit be inexperienced and not enterprise ready. But every component in project is being worked on Enterprise grade. Now, I want to integrate Python implementation for PDF works, and that would be called from .NET (C#) processes supplying required parameters. Since the whole application would be implemented on MS Windows Server, so I am bit lacking the freedom of library usage as in Linux. Also looking for best PDF library which doesn't have any or many dependencies and that dependencies can be successfully installed. I will also need an XML Library to write down the logs and instructions+information for next component which handles Printing. = Therefore, I am seeking all the precious (even small or one-liner) advices from you. Please suggest me every possible things that come in your mind. Things on high priorities right now are: -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)
In continuation of last mail [since pressing tab+space sent the mail :( ] Things on high priorities right now are: - How to integrate Python calling from .NET - Any suggestions for optimizations that would prevent overburden to application due to IronPython interpretation calling, if any, or does such things happen. - Pointers to good resources - Any step in such kind of situation, so to make it Enterprise Grade application components - your opinion with available PDF Libraries, that are best among. Also which library to use for Windows server platform (there is limitation on installing long chain libraries that include other deep dependencies too). A pure python PDF library would be good, but which one. -Which XML Library is pure python based. More questions will follow up :) And I hope, people will reply me. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)
> Joshua: > PDF library: ReportLab. But that is most generation of PDFs. For reading, > splitting, etc, you may have to look at their commercial offering I will have to research on it, i think time to list the best available libs, and finding all's dependency. > On Dec 19, 2007 6:10 AM, Boris Borcic <[EMAIL PROTECTED]> wrote: > Everybody will tell you "reportlab", but AFAIK the open-source kit does not > provide manipulation of existing pdf file contents - "only" creation. Besides > it's targeted at CPython and it isn't 100% clear it runs perfectly on other > implementations; so have a look at itextsharp - it might better fit your needs > if you decide to use IronPython. > iTextSharp look very promising. But i am unable to find any good documentation. I think i will have to buy the book, so that I can have API docs just beside me for reference. One thing I am stuck at right now. the IronPython 1.0.2467 on .NET 2.0.50727.42 is installed on my Ubuntu, so does CPython 2.5 libraries can be called in it without any problem. In ipy shell, >>> sys.path ['/home/rskumar', '/usr/lib/ironpython/Lib', '/usr/lib/python2.4', '/usr/lib/python2.4/site-packages'] >>> so it uses Python 2.4 libs. I am fearing to mix the 2.4 and 2.5 libs. I need to load CPython 2.5 libs by adding it in site.py file of ironpython. Maybe I should go experimenting and let you people know about it. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)
> > If I had to do something like this I would host a Python web > server listening on some port and let .NET application talk to me > using HTTP requests preferably or SOAP if I really had to. > It could be a Paster or Cherrypy or Twisted based server. > Google for instruction on how to package it using py2exe > into a windows service. > The service could be hosted on the same server as .NET or a separate > box Thats is the best solution to me also, but restrictions are I cann't consume extra service for it. I need tight integration and no remote service calls, thats why it seems bit tricky to me., and i am working to integrate Python implementation in .NET. So where the .NET application has to work with PDF part, it will invoke the IronPython Engine, pass required configurations and parameters, and get the result+exceptions etc. > > http://pybrary.net/pyPdf/ Noted for my reference. Thanks :) > > -Which XML Library is pure python based. > > > > ElementTree So ElementTree solved one part. thanks friend. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
how to protect directory traversal in mod_python based custom apps
hi :) I was trying to develop a custom mod_python based web-site, just today. the problem I got though i liked the mod_python's feature of mapping and calling functions in python script by parsing the url. I mean, http://localhost/site/member/list?no=100 would call site/member.py page's function list with arguments no=100. Thats a feature i liked. But PROBLEM 01: i have included in index.py a css link to say something media/base.css now when same page comes with URL index.py/index the URL becomes false. I am finding some better way to overcome this. Placing all CSS as static served is not a good idea,(like if CSS is dynamically generated). So according to you, what should be a better approach to this problem. PROBLEM 02: How can I prevent directory traversal. Take the case, i have five subdirs in dir 'site' named : components modules config templates and a file loader.py when a request comes as loader.py/pagename?renderType=xhtml it would call the function pagename which loads the pages from subdir 'templates' resolves the added components in pages from subdir 'components' where components uses custom modules from 'modules' and so on. Configuration subdir contains various configuration files in .py and .xml I don't want visitors to traverse and get list of all those subdirs. Those sub-dirs actually should no way be traversable online. Though I can prevent it using apache .htaccess and access directives in apache config. But many hosting server, apache config can't be edited (or maybe some situation). Then how can i block traversing the directory (what sort of implementation) Referring to CodeIgnitor PHP Framework, they places index.php in every dir. thats doesn't seem a good idea, and if a person calls the pages providing the right path, they are able to execute files in the framework, though since those configs and other files doesn't return anything, tere is no result. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
CVS access with Python
I have to design a Web-based CVS client. I could not find any module, cvs-binding in python. I have investigated all sort of Web Interface, including Sandweb, and ViewCVS etc. But these provide Read-only access and features. I need to provide almost all sort of basic features a developer frequently need in it. So please guide me. I found javacvs project in Netbeans project repository which seems a nice library, but since I am not a java programmer, this fails to me. Other problem is its implementation. Say, there is a repository of some projects with many modules. Now, when one developer wants to checkout, I can get the revision Sources to Web-server temporary sandbox, and create an archive (tar.gz/zip) and put that for downloading by the user. Since there is many-to-many relation between projects and developers, it will consume a lot of disk space on Web-server, creating 'n' copies of a single project for 'n' users, and assume all developers are checking out all sources. God knows. So is there any good implementation for such situation. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Weight Problem
An Interesting problem, """ A man has only 4 bricks of different weights, lies between 1-40KG, Also, the total weights of Brick A, B, C, D (ie A+B+C+D) is 40KG. The man uses that brick to calculate every possible weight from 1 KG to 40 KG in his shop. (only whole numbers 1KG, 2KG etc, not like 2.3KG) """ I thought it would really be good to solve it by python, and right now on the mid-way solving using very dirty approach. But I feel, using SETs with python in such would solve it better. Can anyone come with good solution, and maybe solution showing usage of Sets. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Plugin based feature adding to web-application
I need an architecture in a project using Django and Python + MySQL, so that when I put a python script in specified directory, that should be loaded and its methods/functions can be used. As far as i have thought on this, I am going to scan that particular directory, list out the files, import them if they exists, NOw I need the functions list defined in that module. Is there any way to get it. I also need to find which class in defined in that python file. Please suggest me over architectures and best practices. Any suggestion would be really helpful. Thanks Rav! -- http://mail.python.org/mailman/listinfo/python-list
Re: "Pythoner",Wish me luck!
> > Hi, > I'm also begginer in python; > i did few basic programs about graph etc.. > > my question is : what benefit is using interactive intrepreter ? > > the IDLE interractive python IDE is best comparing to any other most advanced IDE available in world. Really, if you are learning the python at any level, go for IDLE. What you do, you write every step of statements and that is executed as soon as you finish the block. So you have chance to understand the things step by step. Just like learning by debugging.. Try it self, no one's review can satisfy you. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
libgmail through proxy
HI, I was trying to use libgmail. I used that successfully, fetched mail to some extend (thought after some mails, it threw exceptions on NonIterable Int). But when I used the same package from my office where I have to use the proxy, it failed. I used idle, then I also set os.ENVIRON['http_proxy'] to the same settings which I use, but I could not succeed. The login() method reports error about no addreess associated with it. Please help me solve it. I used the proxy settings, but it didnt work. so any workaround, and what sort of thing I am missing. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
GUI app on Windows for WMI digging
Hi, I am working on an application, which retrieves Windows system info (Hardware / Software / Drivers / OS) and write to an xml. For the GUI, I selected PyQT4, and for system info using WMI, I am using WMI Package (http://timgolden.me.uk/python/wmi/index.html) and popular pywin32. To package the binary, I am considering py2exe. I need to package these in binary package (though single binary output was preferred, but could not find any examples online to achieve this). Also, I took PyQT4, but I can switch to PyGTK if it is possible to get it in single DLL/libs. Overall, I need suggestions on: - which XML library is better/lightweight on Windows?I think pure python based xml processing libs would work (so lxml is out of option). - Can I get these in single binary (not installer), or if not, then how can I get in minimum files. Py2exe results many files. - Is QT4 better or GTK? No war/flaming over this, since least widgets are needed, which are available on both. Since the GUI is just 3-4 screens/dialogs with minimum widgets, so speed does not matter. The only thing that matter is least files/libs (no seperate installation, file can provided with binary package). -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list
Re: "EURO GIRLS" "MISS EUROPE" "MISS FRENCH" "FRENCH" "PRETTY GIRLS" "SEXY FRENCH GIRLS" on www.sexyandpretty-girls.blogspot.com "SEXY RUSSIAN GIRLS" "SEXY GREEK GIRLS" "SEXY DUTCH GIRLS" "SEXY UK G
On Sat, Mar 20, 2010 at 7:27 PM, Brian J Mingus wrote: > Moderating this stuff requires moderating all messages. It would take a > team of volunteers. > You are right... Form the team of volunteers. More people in it, better it would be - since no one would have to be dedicated. -- -=Ravi=- -- http://mail.python.org/mailman/listinfo/python-list