[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reimplementation address book program

andrea

1/2/2009 4:37:00 PM

On one of my servers (linux) I have a nice address book over ldap.
It is automatically integrated with thunderbird and other programs,
but none of them is capable of modifying (or at least easily).

Since I want it very simple and error prone I did it myself, but in
PHP.

It works pretty fine but every time I look to the code I get disgusted
and I haven't still added some necessary features, so given that I
want to rewrite it in ruby, I need some hints..

I may use rails in the future but I want to start very smoothly, it
was implemented in php + smarty, and that's fine like approach.

I only need 2 things:
- insert a new record
- modify a record from a list
Sorting searching etc are not really necessary, and integrity checks
should be done with javascript (as it is now).

I want to do it as smart and possible, because mainly I want to learn
and not less important I want to maintain code that I like...
THanks for any hints
7 Answers

andrea

1/2/2009 6:30:00 PM

0

I started to do some searches and I find out I can use net/ldap for
manipulating data and amrita2 to create the templates.
What do you think??

Another thing, what does :: really mean??
Net::LDAP means what? Look in the Net module for the LDAP class??

And why sometimes i find (fake example)
String.join, String#join, Net::LDAP

andrea

1/2/2009 7:13:00 PM

0

Looks like amrita is dead or almost, I find almost no documentation
other than the source code and a readme file.

Should I really go for rails? Otherwise what else??
I only need to generate smartly some forms and get the output of them.
Rails is not directly usable because my "db" is an ldap tree...

andrea

1/3/2009 7:51:00 AM

0

On 2 Gen, 20:12, andrea <kerny...@gmail.com> wrote:
> Looks like amrita is dead or almost, I find almost no documentation
> other than the source code and a readme file.
>
> Should I really go for rails? Otherwise what else??
> I only need to generate smartly some forms and get the output of them.
> Rails is not directly usable because my "db" is an ldap tree...

Is there anybody out there??
I went to haml finally, which looks really nice. It's even too much
powerful, it tempts me to write everything in one page ;)

Richard Conroy

1/3/2009 11:30:00 AM

0

On Sat, Jan 3, 2009 at 7:54 AM, andrea <kerny404@gmail.com> wrote:
> Is there anybody out there??

It might help if you actually posed a question, or phrased your problem
better. I *think* you are trying to make a web based administration interface
to an LDAP directory, but I am not sure.

You might get better information on Rails talk, but your core problem is your
backend - its an LDAP directory not a database, so your problem might be
better served by anything that uses DataMapper, which doesn't restrict your
data sources.

Merb might be a better choice, or possibly even Sinatra, which is simpler and
might put less barriers in your learning (and works very well with Haml, which
you like).

regards,
Richard.

andrea

1/4/2009 7:51:00 PM

0

On 3 Gen, 12:30, Richard Conroy <richard.con...@gmail.com> wrote:
> On Sat, Jan 3, 2009 at 7:54 AM, andrea <kerny...@gmail.com> wrote:
> > Is there anybody out there??
>
> It might help if you actually posed a question, or phrased your problem
> better. I *think* you are trying to make a web based administration interface
> to an LDAP directory, but I am not sure.
>
> You might get better information on Rails talk, but your core problem is your
> backend - its an LDAP directory not a database, so your problem might be
> better served by anything that uses DataMapper, which doesn't restrict your
> data sources.
>
> Merb might be a better choice, or possibly even Sinatra, which is simpler and
> might put less barriers in your learning (and works very well with Haml, which
> you like).
>
> regards,
> Richard.

Actually there were a few question marks and I thought I explained the
problem, but I'll try again..

I need a frontend for the users which enables to modify / add and
pretty view entries from an ldap tree.
I just wanted some hints about what to use / how should I design it.
Couldn't I just use mod_ruby instead of any kind of framework?
I need a framework to interpret the haml code maybe? Or I could use
the Haml::Engine?

This is a first attempt of class structure:

class Entry
@@multiple = ["mobile", "telephoneNumber", "mail"]
@@long = ["description"]

end

class Person < Entry
@@attrs = {
:attributes => ["cn", "sn", "o", "ou", "mobile",
"telephoneNumber", "mail", "description"],
:strict => ["cn", "sn"],
:dn => ["dn"]
}
def initialize(cn, sn)

end

end

class Factory < Entry
@@attrs = {
:attributes =>
["o","telephoneNumber","facsimileTelephoneNumber","l","postalCode","street","description"],
:strict => ["o"],
:dn => ["o"]
}
def initialize(org)

end
end

Depending on what you're loooking you get different attributes, it is
fine to do this check directly in the haml template?

They will be just input boxes or text areas with some strings already
in or empty, it's not so difficult...

Todd Benson

1/4/2009 9:08:00 PM

0

On Sun, Jan 4, 2009 at 1:53 PM, andrea <kerny404@gmail.com> wrote:
> Actually there were a few question marks and I thought I explained the
> problem, but I'll try again..
>
> I need a frontend for the users which enables to modify / add and
> pretty view entries from an ldap tree.
> I just wanted some hints about what to use / how should I design it.

These are hard questions to answer, because they involve many other
questions (like, do you require a certain look or user interface, are
you adverse to learning a new framework, time constraints,
performance, etc.) Rails is pretty heavy duty, but if you plan on
learning it anyway and don't mind a little feature bloat, I suppose it
might work for you.

> Couldn't I just use mod_ruby instead of any kind of framework?
> I need a framework to interpret the haml code maybe? Or I could use
> the Haml::Engine?

Are you stuck with Haml? Maybe take a look at Camping and Markaby if
the requirements for the web-based app are not overly rigorous.

I haven't played with the LDAP library yet, so I can't comment on it.

Good luck!

Todd

andrea

1/5/2009 10:13:00 AM

0

On 4 Gen, 22:08, Todd Benson <caduce...@gmail.com> wrote:
> On Sun, Jan 4, 2009 at 1:53 PM, andrea <kerny...@gmail.com> wrote:
> These are hard questions to answer, because they involve many other
> questions (like, do you require a certain look or user interface, are
> you adverse to learning a new framework, time constraints,
> performance, etc.)  Rails is pretty heavy duty, but if you plan on
> learning it anyway and don't mind a little feature bloat, I suppose it
> might work for you.
>

So I think I will go to rails after, but I like to do things gradually
when I'm learning something.
I'm not in hurry (there's already an interfacean working even if
incomplete)
d I'm firstly interested in learning now.
>
> Are you stuck with Haml?  Maybe take a look at Camping and Markaby if
> the requirements for the web-based app are not overly rigorous.

No Haml is really fine, it was just to know if it could work anyway...
I think
it could, as long as apache calls a ruby file each time and the ruby
file
renders the template
>
> I haven't played with the LDAP library yet, so I can't comment on it.
>

There's active_ldap but I don't get it to work on Leopard and even on
ubuntu 8.04, not a big deal net/ldap is just fine for me.

I don't understand why only here on ruby half of my messages are not
actually
posted even it gives me no errros...
I'll have to remember to write them inside textmate so I can repost
them.

This is a start point of the classes I need (not many in fact)

class Entry
attr_reader :multiple, :long
def initialize(ar1, ar2)
@multiple = ["mobile", "telephoneNumber", "mail"]
@long = ["description"]
end
end

class Person < Entry
# they can just be readonly attributes
attr_reader :attrs, :cn, :sn, :fields
# inside other there is a hash containing all other fields set
def initialize(cn, sn, other)
@attrs = {
:attributes => ["cn", "sn", "o", "ou", "mobile",
"telephoneNumber", "mail", "description"],
:strict => ["cn", "sn"],
:dn => ["dn"]
}
# super
@fields = {:cn => cn, :sn => sn}
other.each_pair do |key, val|
# don't overwrite already compiled fields
if @attrs[:attributes].member?(key) and (not @fields.has_key?
(key))
@fields[key] = val
end
end
end

def to_s
pp @fields
end
end

class Factory < Entry
attr_reader :attrs
def initialize(o)
@@attrs = {
:attributes =>
["o","telephoneNumber","facsimileTelephoneNumber","l","postalCode","street","description"],
:strict => ["o"],
:dn => ["o"]
}
@o = o
end
end

Then there are some methods that retrieve or updates the informations
and
some templates to show everything.