[CPS-users] Adding contacts database

Jose Luis de la Rosa Triviño joseluis.rosa at iavante.es
Wed Jan 17 18:59:57 CET 2007


Hello, 

I think the best way is to use a CPS ZODB Directory (although it depends on your requirements).

The steps to do are:

1. Create schema and layout.
2. Create directory and configure it to use the new schema and layout.
3. Create a python script that is able to read the file and detach each field of a contact (say name, address or whatever).
4. There are two options for the output of the script created in step 3 may be:
	4.1 Push entries to the portal using remote controller
        4.2 Create xml file and use an import step for directory entries.

In my view, the easier way is 4.1 for which the steps are:

4.1.1. Add a new method to the class  Products.RemoteController.RemoteControllerTool.RemoteControllerTool

The method should look like this:


    security.declareProtected(View, 'createDirectoryEntry')
    def createDirectoryEntry(self, directory, entry):
        """ Add a new entry to a directory 
            param directory: The id of the directory
            param entry: The new entry (python dictionary)
        """
        dirtool = getToolByName(self, 'portal_directories')
        dir = dirtool[str(directory)]            
        try:
            dir.createEntry(entry)                      
        except:
            pass



4.1.2. Modify your script to push entries through remote controller like this:

user = 'zopeadmin'      ## Assumed that your credentials are zopeadmin/zopeadmin 
directory = 'contacts'  ## The identifier of the directory created in step 2.
constr = 'http://%s:%s%s@machine/location:8080/iav_portalmir/portal_remote_controller' % \
(user, user, user, )
proxy = ServerProxy(constr)                 
### In this point you should have a list of entries (list of python dictionaries)
for entry in entries:
   proxy.createDirectoryEntry(directory, entry)

4.1.3. Running the script from a console should work.


I hope to have give you some hints. Good luck.

Cheers.

P.D. The python code in this mail was written by my colleague Miguel Sánchez.

JoseLuis de la Rosa Triviño 
Técnico de Desarrollo Software 
FUNDACIÓN IAVANTE 
joseluis.rosa at iavantefundacion.com 
Tel. 951 015 300 

Este correo electrónico y, en su caso, cualquier fichero anexo, contiene información confidencial exclusivamente dirigida a su(s) destinatario(s). Toda copia o divulgación deberá ser autorizada por IAVANTE.
This e-mail and any attachments are confidential and exclusively directed to its adressee(s). Any copy or distribution will have to be authorized by IAVANTE.


-----Mensaje original-----
De: Mário Valente [mailto:mvalente at itij.mj.pt] 
Enviado el: miércoles, 17 de enero de 2007 14:50
Para: Lennart Regebro
CC: cps-users at lists.nuxeo.com
Asunto: RE: [CPS-users] Adding contacts database

 

On 1/12/07, Mário Valente <mvalente at itij.mj.pt> wrote:

>> >>   Right. Why should I need an aditional piece of software to  manage?
>>     
> >
> >Well, if you want to store it in an SQL database, then you need an SQL database to store it in.
> >
>   

  Thats why I'm using Gadfly. Within Zope.





>> >>   What happens with the next table of stuff? Should a  programmer be 
>> >> needed to do this kind of basic stuff?
>>     

> >It is "basic" in the sense that it's simple to do, but at the same time is very non-basic, as it's >quite unusual. After five years in the CMS world this is the first case I've seen of somebody wanting >>to import an excel sheet of contacts. 
>   
>> >>
>>     

  I wont even comment. In 5 years in the CMS world there's never
 been a need to bulk load formatted data? Of any kind? Be it contacts
 or address lists or people lists? You do it by hand every time? I was
 expecting a more credible answer than this.





>> >>   I'm trying to resist the RoR pull.. but with the Zope  "complicate 
>> >> as much as possible strategy"
>>     

> >Well, if what you want is a HTML interface to a bunch of SQL tables, I don't think you should resist >it. If you want a CMS, then you should resist it. CPS and RoR don't compete with each other. They >are quite different technologies solving what is essentially very different problems.
> >
>   


  I want a CMS. I am resisting it. I just want a better way to 
 define a new content type (be it CPSSchema or Archetype) and
 load previous data automatically, instead of inserting thousands
 of records by hand just because "a CMS is not na HTML interface
 to a bunch of SQL tables". I know its not, I dont want it to be; I
 just need to migrate thousands of records into a CMS and cant seem
 to find a simple (not even automatic) way to do it. I've even looked
 at Zope's export/import XML formats but I'm not even going into that
 mess....

   -- MV






_______________________________________________
cps-users mailing list
cps-users at lists.nuxeo.com
http://lists.nuxeo.com/mailman/listinfo/cps-users




This list archive provided by Nuxeo, the leaders of open source ECM. Check out the Nuxeo 5 open source, standards-based ECM project.