I can work on this angle,

I've deployed multiple projects in just about every system including ASP, PHP, Perl, Java/Tomcat, and even some lesser known systems like Perlscrip via ASP, ASP via Perl, and too many C/C++ CGI's.

There are two main schools.
People from ASP / PHP need to be show how Webware encourages cleaner code & namespaces.

People from Java / ASP-COM need to be shown how they can maintain the clean code and benefit from rapid development w/o loosing any flexabilities or access to Com/ActiveX libs. I am not sure if you can access Java from Python directly - I played w/ Jython for a while but could not get an earlier Webware to run under it.

-Aaron

Ian Sparks wrote:
rdg raises and excellent point, different people approach WebWare from different angles and that clouds your judgement on what Webware can do for you and how it can do it.
I've done some ASP and ISAPI development in the past, some primer on "Webware for ASP programmers" would be a great help and would likely cover the 7 ASP objects (request, response, application, session, server, ASPError, ObjectContext) and their equivalent idiom in WebWare.

Similar texts are probably appropriate for folks coming from other web technologies.

I wish I knew more about webware and ASP to contribute.

- I.

-----Original Message-----
From: r g [mailto:rdg_w@;lycos.com]
Sent: Wednesday, October 30, 2002 4:32 PM
To: Webware-Discuss (E-mail)
Subject: RE: [Webware-discuss] dbPool usage


Aaron --

2nd vote for excellent example. I believe that these are
important examples to be included in reworked documentation.
Not all Webware users are escaping from the Java/Tomcat world. Like myself, I skipped the pain of Java/Tomcat and just started with Python/Webware --- but be sure, that is a tough hill to climb.

-rdg

--

On Wed, 30 Oct 2002 11:08:13 Ian Sparks wrote:

Excellent example, thanks.

- I.

-----Original Message-----
From: Aaron Held [mailto:aaron@;MetroNY.com]
Sent: Wednesday, October 30, 2002 10:48 AM
To: Ian Sparks
Cc: Webware-Discuss (E-mail)
Subject: Re: [Webware-discuss] dbPool usage


in configuration.py :


from MiscUtils.DBPool import DBPool
from pyPgSQL import PgSQL

DEBUG=1
if DEBUG:
   print 'before datapool'
# set up the database connection pool
datapool = DBPool(PgSQL, 5, 'localhost::comsci:user:passwd)
clientpool['testing']=DBPool(PgSQL,2,localhost::testing:user:passwd')
clientpool['metrony']=DBPool(PgSQL,2,'localhost::metrony:user:passwd')
if DEBUG:
   print 'after datapool'

---
in servlet:


from configuration import datapool

.....
def login(self , username=None, passwd=None):
conn = datapool.getConnection()
c = conn.cursor()
c.execute('''SELECT "eMail" FROM "users" where "eMail"=%(username)s AND passwd=%(passwd)s ''',{'username':username,'passwd':passwd})
r = c.fetchone()
c.close()
conn.close()
if (r):
user= self.getUser(username)
print 'validated user in CSUserManager'
return user
else:
print 'User not logged in'
return None

Although I would not call the database from the servlet directly. Just put webware in PYTHONPATH and write a module like:
UserManager.py
#
# CSUser factory
#


from CSUser import CSUser
from configuration import datapool

class CSUserManager:
.....
def login(self , username=None, passwd=None):
conn = datapool.getConnection()
c = conn.cursor()
c.execute('''SELECT "eMail" FROM "users" where "eMail"=%(username)s AND passwd=%(passwd)s ''',{'username':username,'passwd':passwd})
r = c.fetchone()
c.close()
conn.close()
if (r):
user= self.getUser(username)
print 'validated user in CSUserManager'
return user
else:
print 'User not logged in'
return None
....
if (__name__=="__main__"):
print 'Start Main'
UM = CSUserManager()
user=UM.login('[EMAIL PROTECTED]','vector')
aaron=UM.login('[EMAIL PROTECTED]','vector')
print 'Logged in :%s: ' % user.name
user2=UM.getUser('[EMAIL PROTECTED]')
print 'UserName= %s' % user2.name
print 'UserRole= %s' % user2.role
user=UM.requestUserByName(user,user2.name)
print '''requested '[EMAIL PROTECTED]' got: ''', user
user.passwd='adasdasas'
print user.company
print UM.requestUserList(aaron,0,'a')
userList= UM.requestUserList(aaron)
print 'Total', userList.pop(0)[0]
print userList
print 'groups' , user.groups
print 'notes', user.notes
user.groups="newnaksdjkasja"
user.notes='notes'
user.phone='5551212'
UM.updateUser(user,user)

else:
UserManager=CSUserManager()

The idea is that if I call the module directly from a python command line it will import configuration.py and do some basic unit testing. If I call it as a module (from a servlet) it will put an instance of itself in memory.

Then from the servlet you can use the database as follows:


from CSUserManager import UserManager #<-- pull in the data class

class loginUser(FormValidator):
def validate(self,fieldDict): user=UserManager.login(fieldDict['userName'],fieldDict['password'])

-Aaron


Ian Sparks wrote:

Where would I set up my dbPool or other "application wide" objects in webware?

Guess : In contextInitialize of __init__.py? in the MyContext directory?

Do I need to do anything to attach the pool to the application :

application.dbpool = DBPool(....) ?

If someone could post a simple example of setup/usage I'd appreciate it.

Thanks!

- Ian Sparks.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss



__________________________________________________________
Outgrown your current e-mail service? Get 25MB Storage, POP3 Access,
Advanced Spam protection with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus


-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss


-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss



-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to